Сloses #54; Метод [getMaxWeight()] вместо конструкции из метода и математики [getStrength() * 4]; Очистка неиспользуемых методов класса.

This commit is contained in:
Igor Barkov (iwork)
2022-01-25 18:16:09 +02:00
parent a1ea3a0a8c
commit cd80c56f93
5 changed files with 84 additions and 92 deletions
+7 -6
View File
@@ -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;
}
+14 -11
View File
@@ -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 = 'Уровень:<br>Сила:<br>Ловкость:<br>Интуиция:<br>Выносливость:<br>Интеллект:<br>Мудрость:<br>Местонахождение:';
$variables =
$this->level . '<br>' .
parent::getFullStats()->strength . '<br>' .
parent::getFullStats()->dexterity . '<br>' .
parent::getFullStats()->intuition . '<br>' .
parent::getFullStats()->endurance . '<br>' .
parent::getFullStats()->intelligence . '<br>' .
parent::getFullStats()->wisdom . '<br>' .
$stat->strength . '<br>' .
$stat->dexterity . '<br>' .
$stat->intuition . '<br>' .
$stat->endurance . '<br>' .
$stat->intelligence . '<br>' .
$stat->wisdom . '<br>' .
Rooms::$roomNames[$this->room];
if ($isMainWindow) {
$captions = 'Уровень:<br>Здоровье:<br>Сила:<br>Ловкость:<br>Интуиция:<br>Выносливость:<br>Интеллект:<br>Мудрость:<br>Опыт:<br>Очки характеристик:<br>Деньги:<br>Деньги в банке:';
+48 -61
View File
@@ -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