diff --git a/classes/Battles/InventoryItem.php b/classes/Battles/InventoryItem.php
index ccf715b..f7f6df0 100644
--- a/classes/Battles/InventoryItem.php
+++ b/classes/Battles/InventoryItem.php
@@ -55,13 +55,14 @@ IMG;
private function dressStatsChecks(): ?string
{
$checkStats = new UserStats($this->owner_id);
+ $stat = $checkStats->getFullStats();
return
- $this->need_strength > $checkStats->getFullStats()->strength
- || $this->need_dexterity > $checkStats->getFullStats()->dexterity
- || $this->need_intuition > $checkStats->getFullStats()->intuition
- || $this->need_endurance > $checkStats->getFullStats()->endurance
- || $this->need_intelligence > $checkStats->getFullStats()->intelligence
- || $this->need_wisdom > $checkStats->getFullStats()->wisdom
+ $this->need_strength > $stat->strength
+ || $this->need_dexterity > $stat->dexterity
+ || $this->need_intuition > $stat->intuition
+ || $this->need_endurance > $stat->endurance
+ || $this->need_intelligence > $stat->intelligence
+ || $this->need_wisdom > $stat->wisdom
? true : null;
}
diff --git a/classes/Battles/UserInfo.php b/classes/Battles/UserInfo.php
index 8b0f243..1c68bd4 100644
--- a/classes/Battles/UserInfo.php
+++ b/classes/Battles/UserInfo.php
@@ -60,6 +60,7 @@ class UserInfo extends UserStats
private function ttz()
{
+ $stat = $this->getFullStats();
$arr = [
'Уровень' => $this->level,
'Сила' => $this->printStat('strength'),
@@ -68,10 +69,10 @@ class UserInfo extends UserStats
'Выносливость' => $this->printStat('endurance'),
'Интеллект' => $this->printStat('intelligence'),
'Мудрость' => $this->printStat('wisdom'),
- 'Уворот' => $this->getFullStats()->evasion,
- 'Точность' => $this->getFullStats()->accuracy,
- 'Шанс крита' => $this->getFullStats()->criticals,
- 'Урон' => $this->getFullStats()->min_physical_damage . ' - ' . $this->getFullStats()->max_physical_damage,
+ 'Уворот' => $stat->evasion,
+ 'Точность' => $stat->accuracy,
+ 'Шанс крита' => $stat->criticals,
+ 'Урон' => $stat->min_physical_damage . ' - ' . $stat->max_physical_damage,
'Локация' => Rooms::$roomNames[$this->room],
];
@@ -93,21 +94,23 @@ class UserInfo extends UserStats
private function printStat($statName): string
{
- return $this->getFreeStatPoints() ? $this->getStat($statName, 1) . '(' . $this->getFullStats()->$statName . ')' : $this->getFullStats()->$statName;
+ $stat = $this->getFullStats();
+ return $this->getFreeStatPoints() ? $this->getStat($statName, 1) . '(' . $stat->$statName . ')' : $stat->$statName;
}
//TODO вызывать из main.php
private function UserInfoStats($isMainWindow = 0)
{
+ $stat = $this->getFullStats();
$captions = 'Уровень:
Сила:
Ловкость:
Интуиция:
Выносливость:
Интеллект:
Мудрость:
Местонахождение:';
$variables =
$this->level . '
' .
- parent::getFullStats()->strength . '
' .
- parent::getFullStats()->dexterity . '
' .
- parent::getFullStats()->intuition . '
' .
- parent::getFullStats()->endurance . '
' .
- parent::getFullStats()->intelligence . '
' .
- parent::getFullStats()->wisdom . '
' .
+ $stat->strength . '
' .
+ $stat->dexterity . '
' .
+ $stat->intuition . '
' .
+ $stat->endurance . '
' .
+ $stat->intelligence . '
' .
+ $stat->wisdom . '
' .
Rooms::$roomNames[$this->room];
if ($isMainWindow) {
$captions = 'Уровень:
Здоровье:
Сила:
Ловкость:
Интуиция:
Выносливость:
Интеллект:
Мудрость:
Опыт:
Очки характеристик:
Деньги:
Деньги в банке:';
diff --git a/classes/Battles/UserStats.php b/classes/Battles/UserStats.php
index 3025a20..d6a66e3 100644
--- a/classes/Battles/UserStats.php
+++ b/classes/Battles/UserStats.php
@@ -90,52 +90,9 @@ class UserStats extends User
}
}
- /**
- * @return mixed
- */
- public function getStrength()
+ public function getMaxWeight(): int
{
- return $this->strength;
- }
-
- /**
- * @return mixed
- */
- public function getDexterity()
- {
- return $this->dexterity;
- }
-
- /**
- * @return mixed
- */
- public function getIntuition()
- {
- return $this->intuition;
- }
-
- /**
- * @return mixed
- */
- public function getEndurance()
- {
- return $this->endurance;
- }
-
- /**
- * @return mixed
- */
- public function getIntelligence()
- {
- return $this->intelligence;
- }
-
- /**
- * @return mixed
- */
- public function getWisdom()
- {
- return $this->wisdom;
+ return $this->strength * 4;
}
/**
@@ -202,23 +159,53 @@ class UserStats extends User
return $this->legArmor;
}
- public function getFullStats()
+ public function getFullStats(): object
{
- $query = "
- select
- sum(greatest(strength + (ifnull((select sum(add_strength) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)) + (ifnull((select sum(mod_strength) from users_effects where owner_id = $this->id), 0)), 0)) as strength,
- sum(greatest(dexterity + (ifnull((select sum(add_dexterity) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)) + (ifnull((select sum(mod_dexterity) from users_effects where owner_id = $this->id), 0)), 0)) as dexterity,
- sum(greatest(intuition + (ifnull((select sum(add_intuition) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)) + (ifnull((select sum(mod_intuition) from users_effects where owner_id = $this->id), 0)), 0)) as intuition,
- sum(greatest(endurance + (ifnull((select sum(add_endurance) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)) + (ifnull((select sum(mod_endurance) from users_effects where owner_id = $this->id), 0)), 0)) as endurance,
- sum(greatest(intelligence + (ifnull((select sum(add_intelligence) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)) + (ifnull((select sum(mod_intelligence) from users_effects where owner_id = $this->id), 0)), 0)) as intelligence,
- sum(greatest(wisdom + (ifnull((select sum(add_wisdom) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)) + (ifnull((select sum(mod_wisdom) from users_effects where owner_id = $this->id), 0)), 0)) as wisdom,
- ifnull((select sum(add_accuracy) from inventory where dressed_slot != 0 and owner_id = $this->id), 0) as accuracy,
- ifnull((select sum(add_evasion) from inventory where dressed_slot != 0 and owner_id = $this->id), 0) as evasion,
- ifnull((select sum(add_criticals) from inventory where dressed_slot != 0 and owner_id = $this->id), 0) as criticals,
- sum(greatest($this->minDamage + (ifnull((select sum(add_min_physical_damage) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as min_physical_damage,
- sum(greatest($this->maxDamage + (ifnull((select sum(add_max_physical_damage) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as max_physical_damage
- from users where id = $this->id";
- return self::$db->ofetch($query);
+ $stats = self::$db->ofetch("
+ select
+ strength,
+ dexterity,
+ intuition,
+ endurance,
+ intelligence,
+ wisdom
+ from users where id = $this->id");
+ $itemBonuses = self::$db->ofetch("
+ select
+ sum(add_strength) as item_strength,
+ sum(add_dexterity) as item_dexterity,
+ sum(add_intuition) as item_intuition,
+ sum(add_endurance) as item_endurance,
+ sum(add_intelligence) as item_intelligence,
+ sum(add_wisdom) as item_wisdom,
+ sum(add_accuracy) as item_accuracy,
+ sum(add_evasion) as item_evasion,
+ sum(add_criticals) as item_criticals,
+ sum(add_min_physical_damage) as item_min_physical_damage,
+ sum(add_max_physical_damage) as item_max_physical_damage
+ from inventory where dressed_slot != 0 and owner_id = $this->id");
+ $effectBonuses = self::$db->ofetch("
+ select
+ sum(mod_strength) as effect_strength,
+ sum(mod_dexterity) as effect_dexterity,
+ sum(mod_intuition) as effect_intuition,
+ sum(mod_endurance) as effect_endurance,
+ sum(mod_intelligence) as effect_intelligence,
+ sum(mod_wisdom) as effect_wisdom
+ from users_effects where owner_id = $this->id");
+ $obj = (object)[];
+ $obj->strength = max(0,$stats->strength + $itemBonuses->item_strength + $effectBonuses->effect_strength);
+ $obj->dexterity = max(0,$stats->dexterity + $itemBonuses->item_dexterity + $effectBonuses->effect_dexterity);
+ $obj->intuition = max(0,$stats->intuition + $itemBonuses->item_intuition + $effectBonuses->effect_intuition);
+ $obj->endurance = max(0,$stats->endurance + $itemBonuses->item_endurance + $effectBonuses->effect_endurance);
+ $obj->intelligence = max(0,$stats->intelligence + $itemBonuses->item_intelligence + $effectBonuses->effect_intelligence);
+ $obj->wisdom = max(0,$stats->wisdom + $itemBonuses->item_wisdom + $effectBonuses->effect_wisdom);
+ $obj->accuracy = max(0, $itemBonuses->item_accuracy);
+ $obj->evasion = max(0, $itemBonuses->item_evasion);
+ $obj->criticals = max(0, $itemBonuses->item_criticals);
+ $obj->min_physical_damage = max($this->minDamage, $this->minDamage + $itemBonuses->item_min_physical_damage);
+ $obj->max_physical_damage = max($this->maxDamage, $this->maxDamage + $itemBonuses->item_max_physical_damage);
+ return $obj;
}
public function levelUp(): string
diff --git a/hostel_room.php b/hostel_room.php
index 3877394..52eef1e 100644
--- a/hostel_room.php
+++ b/hostel_room.php
@@ -21,7 +21,7 @@ function get_meshok(): object
$stat = new UserInfo(User::$current->getId());
return (object)[
'currentweight' => $allweight->items_weight_sum,
- 'maxweight' => $stat->getStat('strength') * 4 + $allweight->items_weight_sum,
+ 'maxweight' => $stat->getMaxWeight() + $allweight->items_weight_sum,
];
}
diff --git a/main.php b/main.php
index c0c8156..dbeb47d 100644
--- a/main.php
+++ b/main.php
@@ -73,6 +73,7 @@ if ($req->edit) {
// Подготавливаем отображение инфы и предметов.
$userInfo = new UserInfo(User::$current->getId());
$userStats = new UserStats(User::$current->getId());
+$stat = $userStats->getFullStats();
$data = DBPDO::$db->ofetchAll('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND on_sale = 0', User::$current->getId());
$iteminfo = [];
foreach ($data as $row) {
@@ -132,7 +133,7 @@ if ($req->goto) {
$eff = db::c()->query('SELECT 1 FROM `users_effects` WHERE `owner_id` = ?i AND (`type` = 14 OR `type` = 13)', User::$current->getId());
//(масса: = $getItemsBonuses->getItemsWeight() . '/' . User::$current->strength * 4
- if ($d['sum_weight'] > $userStats->getStrength() * 4) {
+ if ($d['sum_weight'] > $userStats->getMaxWeight()) {
err('У вас переполнен рюкзак, вы не можете передвигаться...');
$imove = false;
}
@@ -282,17 +283,17 @@ Template::header('Игра');