From cd80c56f934525a429579f53357df65cfc3af5f8 Mon Sep 17 00:00:00 2001 From: "Igor Barkov (iwork)" Date: Tue, 25 Jan 2022 18:16:09 +0200 Subject: [PATCH] =?UTF-8?q?=D0=A1loses=20#54;=20=D0=9C=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=B4=20[getMaxWeight()]=20=D0=B2=D0=BC=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=BE=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=B8=D0=B7=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4?= =?UTF-8?q?=D0=B0=20=D0=B8=20=D0=BC=D0=B0=D1=82=D0=B5=D0=BC=D0=B0=D1=82?= =?UTF-8?q?=D0=B8=D0=BA=D0=B8=20[getStrength()=20*=204];=20=D0=9E=D1=87?= =?UTF-8?q?=D0=B8=D1=81=D1=82=D0=BA=D0=B0=20=D0=BD=D0=B5=D0=B8=D1=81=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=B7=D1=83=D0=B5=D0=BC=D1=8B=D1=85=20=D0=BC?= =?UTF-8?q?=D0=B5=D1=82=D0=BE=D0=B4=D0=BE=D0=B2=20=D0=BA=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D1=81=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Battles/InventoryItem.php | 13 ++-- classes/Battles/UserInfo.php | 25 ++++--- classes/Battles/UserStats.php | 109 +++++++++++++----------------- hostel_room.php | 2 +- main.php | 27 ++++---- 5 files changed, 84 insertions(+), 92 deletions(-) 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()); //(масса: 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('Игра');
- Сила: getFreeStatPoints() ? $userStats->getStat('strength', 1) . '(' . strval($userStats->getFullStats()->strength) . ')' : $userStats->getFullStats()->strength) ?> + Сила: getFreeStatPoints() ? $userStats->getStat('strength', 1) . '(' . strval($stat->strength) . ')' : $stat->strength) ?>
- Ловкость: getFreeStatPoints() ? $userStats->getStat('dexterity', 1) . '(' . strval($userStats->getFullStats()->dexterity) . ')' : $userStats->getFullStats()->dexterity) ?> + Ловкость: getFreeStatPoints() ? $userStats->getStat('dexterity', 1) . '(' . strval($stat->dexterity) . ')' : $stat->dexterity) ?>
- Интуиция: getFreeStatPoints() ? $userStats->getStat('intuition', 1) . '(' . strval($userStats->getFullStats()->intuition) . ')' : $userStats->getFullStats()->intuition) ?> + Интуиция: getFreeStatPoints() ? $userStats->getStat('intuition', 1) . '(' . strval($stat->intuition) . ')' : $stat->intuition) ?>
- Выносливость: getFreeStatPoints() ? $userStats->getStat('endurance', 1) . '(' . strval($userStats->getFullStats()->endurance) . ')' : $userStats->getFullStats()->endurance) ?> + Выносливость: getFreeStatPoints() ? $userStats->getStat('endurance', 1) . '(' . strval($stat->endurance) . ')' : $stat->endurance) ?>
- Интеллект: getFreeStatPoints() ? $userStats->getStat('intelligence', 1) . '(' . strval($userStats->getFullStats()->intelligence) . ')' : $userStats->getFullStats()->intelligence) ?> + Интеллект: getFreeStatPoints() ? $userStats->getStat('intelligence', 1) . '(' . strval($stat->intelligence) . ')' : $stat->intelligence) ?>
- Мудрость: getFreeStatPoints() ? $userStats->getStat('wisdom', 1) . '(' . strval($userStats->getFullStats()->wisdom) . ')' : $userStats->getFullStats()->wisdom) ?> + Мудрость: getFreeStatPoints() ? $userStats->getStat('wisdom', 1) . '(' . strval($stat->wisdom) . ')' : $stat->wisdom) ?>
getFreeStatPoints()): ?> Возможных @@ -308,11 +309,11 @@ Template::header('Игра'); getMana() ?>
- Уворот: getFullStats()->evasion ?>
- Точность: getFullStats()->accuracy ?>
- Шанс крита: getFullStats()->criticals ?>
- Урон: getFullStats()->min_physical_damage ?> - - getFullStats()->max_physical_damage ?>
+ Уворот: evasion ?>
+ Точность: accuracy ?>
+ Шанс крита: criticals ?>
+ Урон: min_physical_damage ?> + - max_physical_damage ?>

Защита от огня: ??
Защита от воды: ??
@@ -346,7 +347,7 @@ Template::header('Игра');
Рюкзак - (масса: getStrength() * 4 ?>) + (масса: getMaxWeight() ?>)