dev #41

Merged
lopar merged 29 commits from dev into master 2021-05-25 15:28:14 +00:00
3 changed files with 11 additions and 67 deletions
Showing only changes of commit 4164046edb - Show all commits

View File

@ -42,50 +42,6 @@ class DressedItems
return $this->dressedItem;
}
private function getBonuses(): array
{
$query = <<<SQL
SELECT SUM(add_strength) as sum_strength,
SUM(add_dexterity) as sum_dexterity,
SUM(add_intuition) as sum_intuition,
SUM(add_endurance) as sum_endurance,
SUM(add_intelligence) as sum_intelligence,
SUM(add_wisdom) as sum_wisdom,
SUM(add_accuracy) as sum_accuracy,
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
FROM inventory WHERE owner_id = ? AND dressed_slot > 0
SQL;
return self::$db->fetch($query, $this->USERID);
}
public function getAccuracyBonus(): ?int
{
return self::getBonuses()['sum_accuracy'] ?? 0;
}
public function getEvasionBonus(): ?int
{
return self::getBonuses()['sum_evasion'] ?? 0;
}
public function getCriticalsBonus(): ?int
{
return self::getBonuses()['sum_criticals'] ?? 0;
}
public function getMinPhysDamage(): ?int
{
return self::getBonuses()['sum_min_phys_damage'];
}
public function getMaxPhysDamage(): ?int
{
return self::getBonuses()['sum_max_phys_damage'];
}
/**
* Снимает с предмета статус одетого на персонажа в определённом слоте персонажа.
* @param $slot_id - номер слота.

View File

@ -177,22 +177,6 @@ class UserStats extends User
return $this->maxMana;
}
/**
* @return int
*/
public function getMinDamage(): int
{
return $this->minDamage;
}
/**
* @return int
*/
public function getMaxDamage(): int
{
return $this->maxDamage;
}
/**
* @return int
*/
@ -226,7 +210,12 @@ class UserStats extends User
sum(greatest(intuition + (ifnull((select sum(add_intuition) from inventory where dressed_slot != 0 and 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)), 0)) as endurance,
sum(greatest(intelligence + (ifnull((select sum(add_intelligence) from inventory where dressed_slot != 0 and 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)), 0)) as wisdom
sum(greatest(wisdom + (ifnull((select sum(add_wisdom) from inventory where dressed_slot != 0 and 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);
}

View File

@ -82,7 +82,6 @@ if ($edit) {
// Подготавливаем отображение инфы и предметов.
$userInfo = new UserInfo($user->getId());
$userStats = new UserStats($user->getId());
$getItemsBonuses = new DressedItems($user->getId());
$data = \Battles\Database\DBPDO::INIT()->ofetchAll('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND on_sale = 0', $user->getId());
$iteminfo = [];
foreach ($data as $row) {
@ -400,11 +399,11 @@ Template::header('Игра');
<br>
Здоровье: <?= $userStats->getHealth() ?><br>
Пыль: <?= $userStats->getMana() ?><br>
Уворот: <?= $getItemsBonuses->getEvasionBonus() ?><br>
Точность: <?= $getItemsBonuses->getAccuracyBonus() ?><br>
Шанс крита: <?= $getItemsBonuses->getCriticalsBonus() ?><br>
Урон: <?= $userStats->getMinDamage() + $getItemsBonuses->getMinPhysDamage() ?>
- <?= $userStats->getMaxDamage() + $getItemsBonuses->getMaxPhysDamage() ?> <br>
Уворот: <?= $userStats->getFullStats()->evasion ?><br>
Точность: <?= $userStats->getFullStats()->accuracy ?><br>
Шанс крита: <?= $userStats->getFullStats()->criticals ?><br>
Урон: <?= $userStats->getFullStats()->min_physical_damage ?>
- <?= $userStats->getFullStats()->max_physical_damage ?> <br>
<br>
Защита от огня: ?? <br>
Защита от воды: ?? <br>