dev-bug54 #55

Merged
lopar merged 2 commits from dev-bug54 into master 2022-01-25 16:41:35 +00:00
5 changed files with 84 additions and 92 deletions
Showing only changes of commit cd80c56f93 - Show all commits

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;
}

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>Деньги в банке:';

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 = "
$stats = self::$db->ofetch("
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);
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

View File

@ -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,
];
}

View File

@ -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('Игра');
<!--Параметры-->
<div>
<div class="container">
Сила: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('strength', 1) . '(' . strval($userStats->getFullStats()->strength) . ')' : $userStats->getFullStats()->strength) ?>
Сила: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('strength', 1) . '(' . strval($stat->strength) . ')' : $stat->strength) ?>
<br>
Ловкость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('dexterity', 1) . '(' . strval($userStats->getFullStats()->dexterity) . ')' : $userStats->getFullStats()->dexterity) ?>
Ловкость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('dexterity', 1) . '(' . strval($stat->dexterity) . ')' : $stat->dexterity) ?>
<br>
Интуиция: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('intuition', 1) . '(' . strval($userStats->getFullStats()->intuition) . ')' : $userStats->getFullStats()->intuition) ?>
Интуиция: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('intuition', 1) . '(' . strval($stat->intuition) . ')' : $stat->intuition) ?>
<br>
Выносливость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('endurance', 1) . '(' . strval($userStats->getFullStats()->endurance) . ')' : $userStats->getFullStats()->endurance) ?>
Выносливость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('endurance', 1) . '(' . strval($stat->endurance) . ')' : $stat->endurance) ?>
<br>
Интеллект: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('intelligence', 1) . '(' . strval($userStats->getFullStats()->intelligence) . ')' : $userStats->getFullStats()->intelligence) ?>
Интеллект: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('intelligence', 1) . '(' . strval($stat->intelligence) . ')' : $stat->intelligence) ?>
<br>
Мудрость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('wisdom', 1) . '(' . strval($userStats->getFullStats()->wisdom) . ')' : $userStats->getFullStats()->wisdom) ?>
Мудрость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('wisdom', 1) . '(' . strval($stat->wisdom) . ')' : $stat->wisdom) ?>
<br>
<?php if ($userStats->getFreeStatPoints()): ?>
<small style="color: darkgreen;">Возможных
@ -308,11 +309,11 @@ Template::header('Игра');
<progress max="<?= $userStats->getMaxMana() ?>"
value="<?= $userStats->getMana() ?>"><?= $userStats->getMana() ?></progress>
<br>
Уворот: <?= $userStats->getFullStats()->evasion ?><br>
Точность: <?= $userStats->getFullStats()->accuracy ?><br>
Шанс крита: <?= $userStats->getFullStats()->criticals ?><br>
Урон: <?= $userStats->getFullStats()->min_physical_damage ?>
- <?= $userStats->getFullStats()->max_physical_damage ?> <br>
Уворот: <?= $stat->evasion ?><br>
Точность: <?= $stat->accuracy ?><br>
Шанс крита: <?= $stat->criticals ?><br>
Урон: <?= $stat->min_physical_damage ?>
- <?= $stat->max_physical_damage ?> <br>
<br>
Защита от огня: ?? <br>
Защита от воды: ?? <br>
@ -346,7 +347,7 @@ Template::header('Игра');
<div> <!--рюкзак-->
<table style="border: 0; padding: 2px; border-spacing: 1px; width: 100%; background-color: #a5a5a5">
<caption>Рюкзак
(масса: <?= '?? /' . (int)$userStats->getStrength() * 4 ?>)
(масса: <?= '?? /' . $userStats->getMaxWeight() ?>)
</caption>
<?php
foreach ($iteminfo as $ii) {