???
This commit is contained in:
@@ -31,6 +31,11 @@ class DressedItems
|
||||
}
|
||||
}
|
||||
|
||||
private function getDressedItemById($item_id)
|
||||
{
|
||||
return db::c()->query('SELECT * FROM inventory WHERE item_id = ?i AND dressed_slot > 0', $item_id)->fetch_assoc();
|
||||
}
|
||||
|
||||
private function getBonusesFromDressedItems()
|
||||
{
|
||||
try {
|
||||
@@ -45,8 +50,7 @@ SELECT SUM(add_strength) as sum_strength,
|
||||
SUM(add_evasion) as sum_evasion,
|
||||
SUM(add_criticals) as sum_criticals,
|
||||
SUM(add_min_physical_damage) as sum_min_phys_damage,
|
||||
SUM(add_max_physical_damage) as sum_max_phys_damage,
|
||||
SUM(weight) as sum_weight
|
||||
SUM(add_max_physical_damage) as sum_max_phys_damage
|
||||
FROM inventory WHERE owner_id = ?i AND dressed_slot > 0
|
||||
SQL;
|
||||
$this->DBSUM = db::c()->query($query, $this->USERID)->fetch_assoc();
|
||||
@@ -61,8 +65,7 @@ SQL;
|
||||
self::getDressedItems();
|
||||
}
|
||||
while ($row = $this->DB->fetch_assoc()) {
|
||||
$dressed_item[$row['dressed_slot']] = $row;
|
||||
$this->dressedItem[$row['dressed_slot']] = $row;
|
||||
$this->dressedItem[$row['item_type']] = $row;
|
||||
}
|
||||
return $this->dressedItem;
|
||||
}
|
||||
@@ -111,10 +114,6 @@ SQL;
|
||||
{
|
||||
return self::getBonuses()['sum_criticals'];
|
||||
}
|
||||
public function getItemsWeight()
|
||||
{
|
||||
return self::getBonuses()['sum_weight'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Снимает с предмета статус одетого на персонажа в определённом слоте персонажа.
|
||||
@@ -126,8 +125,16 @@ SQL;
|
||||
{
|
||||
self::getItemsInSlots();
|
||||
// Проверяем, что используется один из 12 слотов и наличие предмета в слоте.
|
||||
if (in_array($slot_id, range(1,12)) && $this->dressedItem[$slot_id]) {
|
||||
if (in_array($slot_id, Item::ITEM_TYPES_ALLOWED_IN_SLOTS) && $this->dressedItem[$slot_id]) {
|
||||
db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ?i AND owner_id = ?i', $slot_id, $this->USERID);
|
||||
}
|
||||
}
|
||||
|
||||
public function slotStatus($slot_id)
|
||||
{
|
||||
self::getItemsInSlots();
|
||||
if ($this->dressedItem[$slot_id]) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ class InventoryItem extends Item
|
||||
|
||||
public function printImage()
|
||||
{
|
||||
if (!in_array($this->item_type, [12, 50, 200])) {
|
||||
if (in_array($this->item_type, range(1,12))) {
|
||||
echo "<a href=/main.php?edit=1&dress={$this->item_id} title='Надеть'>";
|
||||
parent::printImage();
|
||||
echo "</a>";
|
||||
|
||||
@@ -2,30 +2,44 @@
|
||||
|
||||
abstract class Item
|
||||
{
|
||||
public $item_id;
|
||||
public $name;
|
||||
public $item_type;
|
||||
public $durability;
|
||||
public $price;
|
||||
public $need_strength;
|
||||
public $need_dexterity;
|
||||
public $need_intuition;
|
||||
public $need_endurance;
|
||||
public $need_intelligence;
|
||||
public $need_wisdom;
|
||||
public $add_strength;
|
||||
public $add_dexterity;
|
||||
public $add_intuition;
|
||||
public $add_endurance;
|
||||
public $add_intelligence;
|
||||
public $add_wisdom;
|
||||
public $add_accuracy;
|
||||
public $add_evasion;
|
||||
public $add_criticals;
|
||||
public $add_min_physical_damage;
|
||||
public $add_max_physical_damage;
|
||||
public $weight;
|
||||
public $image;
|
||||
protected $item_id;
|
||||
protected $name;
|
||||
protected $item_type;
|
||||
protected $durability;
|
||||
protected $price;
|
||||
protected $need_strength;
|
||||
protected $need_dexterity;
|
||||
protected $need_intuition;
|
||||
protected $need_endurance;
|
||||
protected $need_intelligence;
|
||||
protected $need_wisdom;
|
||||
protected $add_strength;
|
||||
protected $add_dexterity;
|
||||
protected $add_intuition;
|
||||
protected $add_endurance;
|
||||
protected $add_intelligence;
|
||||
protected $add_wisdom;
|
||||
protected $add_accuracy;
|
||||
protected $add_evasion;
|
||||
protected $add_criticals;
|
||||
protected $add_min_physical_damage;
|
||||
protected $add_max_physical_damage;
|
||||
protected $weight;
|
||||
protected $image;
|
||||
public const ITEM_TYPES_ALLOWED_IN_SLOTS = [1,2,3,4,5,6,7,8,9,10,11,12];
|
||||
public const ITEM_TYPE_HELMET = 1;
|
||||
public const ITEM_TYPE_ARMOR = 2;
|
||||
const ITEM_TYPE_LEGS = 3;
|
||||
const ITEM_TYPE_BOOTS = 4;
|
||||
const ITEM_TYPE_GLOVES = 5;
|
||||
const ITEM_TYPE_WEAPON = 6;
|
||||
const ITEM_TYPE_SHIELD = 7;
|
||||
const ITEM_TYPE_BELT = 8;
|
||||
public const ITEM_TYPE_RING = 9;
|
||||
const ITEM_TYPE_AMULET = 10;
|
||||
const ITEM_TYPE_CONSUMABLE = 20;
|
||||
const ITEM_TYPE_OTHER = 50;
|
||||
const ITEM_TYPE_TRASH = 100;
|
||||
|
||||
/**
|
||||
* Item constructor.
|
||||
@@ -41,28 +55,28 @@ abstract class Item
|
||||
}
|
||||
|
||||
switch ($this->item_type) {
|
||||
case 1:
|
||||
case self::ITEM_TYPE_HELMET:
|
||||
$this->typename = 'Шлем';
|
||||
break;
|
||||
case 2:
|
||||
case self::ITEM_TYPE_ARMOR:
|
||||
$this->typename = 'Броня';
|
||||
break;
|
||||
case 3:
|
||||
case self::ITEM_TYPE_LEGS:
|
||||
$this->typename = 'Поножи';
|
||||
break;
|
||||
case 4:
|
||||
case self::ITEM_TYPE_BOOTS:
|
||||
$this->typename = 'Сапоги';
|
||||
break;
|
||||
case 5:
|
||||
case self::ITEM_TYPE_GLOVES:
|
||||
$this->typename = 'Перчатки';
|
||||
break;
|
||||
case 6:
|
||||
case self::ITEM_TYPE_WEAPON:
|
||||
$this->typename = 'Оружие';
|
||||
break;
|
||||
case 7:
|
||||
case self::ITEM_TYPE_SHIELD:
|
||||
$this->typename = 'Щит';
|
||||
break;
|
||||
case 8:
|
||||
case self::ITEM_TYPE_BELT:
|
||||
$this->typename = 'Пояс';
|
||||
break;
|
||||
case 9:
|
||||
@@ -83,7 +97,7 @@ abstract class Item
|
||||
public function printImage()
|
||||
{
|
||||
echo <<<IMG
|
||||
<img src="/i/sh/{$this->image}" class="item-wrap-normal">
|
||||
<img src="/i/sh/{$this->image}" class="item-wrap-normal" alt="">
|
||||
IMG;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,13 +32,13 @@ class User
|
||||
public $headArmor = 0;
|
||||
public $chestArmor = 0;
|
||||
public $legArmor = 0;
|
||||
public $free_stat_points = 0;
|
||||
public const STAT_MAXIMUM_AMOUNT = 40;
|
||||
private const ERROR_STAT_IS_MAXIMUM = 'Ошибка: Параметр достиг своего лимита!';
|
||||
private const ERROR_STAT_UNKNOWN = 'Ошибка: Неизвестный параметр!';
|
||||
// Пока несуществующие, для совместимости.
|
||||
public $married = 'Someone или нет.';
|
||||
public $experience = 200;
|
||||
public $stat_points = 1;
|
||||
// Динамически рассчитываемые
|
||||
public $health;
|
||||
//Статусы того, кто смотрит на информацию.
|
||||
@@ -109,7 +109,7 @@ class User
|
||||
if ($isMainWindow) {
|
||||
$this->Bank = new Bank($this->id);
|
||||
$captions = 'Уровень:<br>Здоровье:<br>Сила:<br>Ловкость:<br>Интуиция:<br>Выносливость:<br>Интеллект:<br>Мудрость:<br>Опыт:<br>Очки характеристик:<br>Деньги:<br>Деньги в банке:';
|
||||
$variables = $this->level . '<br>' . $this->health . '<br>' . $this->getStrength(1) . '<br>' . $this->getDexterity(1) . '<br>' . $this->getIntuition(1) . '<br>' . $this->getEndurance(1) . '<br>' . $this->getIntelligence(1) . '<br>' . $this->getWisdom(1) . '<br>' . $this->experience . '<br>' . $this->stat_points . '<br>' . $this->money . '<br>' . $this->Bank->money;
|
||||
$variables = $this->level . '<br>' . $this->health . '<br>' . $this->getStrength(1) . '<br>' . $this->getDexterity(1) . '<br>' . $this->getIntuition(1) . '<br>' . $this->getEndurance(1) . '<br>' . $this->getIntelligence(1) . '<br>' . $this->getWisdom(1) . '<br>' . $this->experience . '<br>' . $this->free_stat_points . '<br>' . $this->money . '<br>' . $this->Bank->money;
|
||||
}
|
||||
|
||||
if ($this->align) {
|
||||
@@ -141,7 +141,7 @@ class User
|
||||
|
||||
public function getStrength($isMainWindow = 0)
|
||||
{
|
||||
if ($this->stat_points && $isMainWindow && $this->strength < self::STAT_MAXIMUM_AMOUNT) {
|
||||
if ($this->free_stat_points && $isMainWindow && $this->strength < self::STAT_MAXIMUM_AMOUNT) {
|
||||
//main.php?edit=1&ups=sila
|
||||
return sprintf('%s <a href="#">[+]</a>', $this->strength);
|
||||
}
|
||||
@@ -150,7 +150,7 @@ class User
|
||||
|
||||
public function getDexterity($isMainWindow = 0)
|
||||
{
|
||||
if ($this->stat_points && $isMainWindow && $this->dexterity < self::STAT_MAXIMUM_AMOUNT) {
|
||||
if ($this->free_stat_points && $isMainWindow && $this->dexterity < self::STAT_MAXIMUM_AMOUNT) {
|
||||
//main.php?edit=1&ups=lovk
|
||||
return sprintf('%s <a href="#">[+]</a>', $this->dexterity);
|
||||
}
|
||||
@@ -159,7 +159,7 @@ class User
|
||||
|
||||
public function getIntuition($isMainWindow = 0)
|
||||
{
|
||||
if ($this->stat_points && $isMainWindow && $this->intuition < self::STAT_MAXIMUM_AMOUNT) {
|
||||
if ($this->free_stat_points && $isMainWindow && $this->intuition < self::STAT_MAXIMUM_AMOUNT) {
|
||||
//main.php?edit=1&ups=inta...
|
||||
return sprintf('%s <a href="#">[+]</a>', $this->intuition);
|
||||
}
|
||||
@@ -168,7 +168,7 @@ class User
|
||||
|
||||
public function getEndurance($isMainWindow = 0)
|
||||
{
|
||||
if ($this->stat_points && $isMainWindow && $this->endurance < self::STAT_MAXIMUM_AMOUNT) {
|
||||
if ($this->free_stat_points && $isMainWindow && $this->endurance < self::STAT_MAXIMUM_AMOUNT) {
|
||||
return sprintf('%s <a href="#">[+]</a>', $this->endurance);
|
||||
}
|
||||
return $this->endurance;
|
||||
@@ -176,7 +176,7 @@ class User
|
||||
|
||||
public function getIntelligence($isMainWindow = 0)
|
||||
{
|
||||
if ($this->stat_points && $isMainWindow && $this->intelligence < self::STAT_MAXIMUM_AMOUNT) {
|
||||
if ($this->free_stat_points && $isMainWindow && $this->intelligence < self::STAT_MAXIMUM_AMOUNT) {
|
||||
return sprintf('%s <a href="#">[+]</a>', $this->intelligence);
|
||||
}
|
||||
return $this->intelligence;
|
||||
@@ -184,7 +184,7 @@ class User
|
||||
|
||||
public function getWisdom($isMainWindow = 0)
|
||||
{
|
||||
if ($this->stat_points && $isMainWindow && $this->wisdom < self::STAT_MAXIMUM_AMOUNT) {
|
||||
if ($this->free_stat_points && $isMainWindow && $this->wisdom < self::STAT_MAXIMUM_AMOUNT) {
|
||||
return sprintf('%s <a href="#">[+]</a>', $this->wisdom);
|
||||
}
|
||||
return $this->wisdom;
|
||||
@@ -192,7 +192,7 @@ class User
|
||||
|
||||
public function setStrength()
|
||||
{
|
||||
if ($this->strength <= self::STAT_MAXIMUM_AMOUNT && $this->stat_points > 0) {
|
||||
if ($this->strength <= self::STAT_MAXIMUM_AMOUNT && $this->free_stat_points > 0) {
|
||||
db::c()->query('UPDATE users SET strength = strength + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i', $this->id);
|
||||
} else {
|
||||
throw new Exception(self::ERROR_STAT_IS_MAXIMUM);
|
||||
@@ -201,7 +201,7 @@ class User
|
||||
|
||||
public function setDexterity()
|
||||
{
|
||||
if ($this->dexterity <= self::STAT_MAXIMUM_AMOUNT && $this->stat_points > 0) {
|
||||
if ($this->dexterity <= self::STAT_MAXIMUM_AMOUNT && $this->free_stat_points > 0) {
|
||||
db::c()->query('UPDATE users SET dexterity = dexterity + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i', $this->id);
|
||||
} else {
|
||||
throw new Exception(self::ERROR_STAT_IS_MAXIMUM);
|
||||
@@ -210,7 +210,7 @@ class User
|
||||
|
||||
public function setIntuition()
|
||||
{
|
||||
if ($this->intuition <= self::STAT_MAXIMUM_AMOUNT && $this->stat_points > 0) {
|
||||
if ($this->intuition <= self::STAT_MAXIMUM_AMOUNT && $this->free_stat_points > 0) {
|
||||
db::c()->query('UPDATE users SET intuition = intuition + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i', $this->id);
|
||||
} else {
|
||||
throw new Exception(self::ERROR_STAT_IS_MAXIMUM);
|
||||
@@ -219,7 +219,7 @@ class User
|
||||
|
||||
public function setEndurance()
|
||||
{
|
||||
if ($this->endurance <= self::STAT_MAXIMUM_AMOUNT && $this->stat_points > 0) {
|
||||
if ($this->endurance <= self::STAT_MAXIMUM_AMOUNT && $this->free_stat_points > 0) {
|
||||
db::c()->query('UPDATE users SET endurance = endurance + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i', $this->id);
|
||||
} else {
|
||||
throw new Exception(self::ERROR_STAT_IS_MAXIMUM);
|
||||
@@ -228,7 +228,7 @@ class User
|
||||
|
||||
public function setIntelligence()
|
||||
{
|
||||
if ($this->intelligence <= self::STAT_MAXIMUM_AMOUNT && $this->stat_points > 0) {
|
||||
if ($this->intelligence <= self::STAT_MAXIMUM_AMOUNT && $this->free_stat_points > 0) {
|
||||
db::c()->query('UPDATE users SET intelligence = intelligence + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i', $this->id);
|
||||
} else {
|
||||
throw new Exception(self::ERROR_STAT_IS_MAXIMUM);
|
||||
@@ -237,7 +237,7 @@ class User
|
||||
|
||||
public function setWisdom()
|
||||
{
|
||||
if ($this->wisdom <= self::STAT_MAXIMUM_AMOUNT && $this->stat_points > 0) {
|
||||
if ($this->wisdom <= self::STAT_MAXIMUM_AMOUNT && $this->free_stat_points > 0) {
|
||||
db::c()->query('UPDATE users SET wisdom = wisdom + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i', $this->id);
|
||||
} else {
|
||||
throw new Exception(self::ERROR_STAT_IS_MAXIMUM);
|
||||
@@ -248,7 +248,7 @@ class User
|
||||
{
|
||||
$allowed = ['strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom'];
|
||||
if (in_array($stat_name, $allowed)) {
|
||||
if ($this->stat_points > 0 && $this->$stat_name <= self::STAT_MAXIMUM_AMOUNT) {
|
||||
if ($this->free_stat_points > 0 && $this->$stat_name <= self::STAT_MAXIMUM_AMOUNT) {
|
||||
$query = 'UPDATE users SET ?f = ?f + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i';
|
||||
db::c()->query($query, $stat_name, $stat_name, $this->id);
|
||||
} else {
|
||||
@@ -292,7 +292,7 @@ class User
|
||||
if ($this->watcherIsAdmin) {
|
||||
$this->Bank = new Bank($this->id);
|
||||
$infoString = '<br><span>ИД Игрока: %s<br> ИД Комнаты: %s<br> Деньги: %s<br> Деньги в банке: %s<br> Опыт: %s<br> Нераспределённые очки: %s<br> Текущая сессия: %s</span>';
|
||||
echo sprintf($infoString, $this->id, $this->room, $this->money, $this->Bank->money, $this->experience, $this->stat_points, $this->session_id);
|
||||
echo sprintf($infoString, $this->id, $this->room, $this->money, $this->Bank->money, $this->experience, $this->free_stat_points, $this->session_id);
|
||||
}
|
||||
$this->UserLogs = new UserLogModel($this->id);
|
||||
echo '<div class="secret-info-user-log"><b>Личное дело</b><br>';
|
||||
|
||||
Reference in New Issue
Block a user