Отображаем параметры персонажей

This commit is contained in:
Igor Barkov (iwork) 2020-07-20 16:27:32 +03:00
parent 897cc530af
commit ab5d0459d9
3 changed files with 34 additions and 304 deletions

View File

@ -11,18 +11,11 @@ class DressedItems
protected $DBSUM;
protected $USERID;
private $dressedItem;
public $sumStrength = 0;
public $sumDexterity = 0;
public $sumIntuition = 0;
public $sumEndurance = 0;
public $sumIntelligence = 0;
public $sumWisdom = 0;
public $sumAccuracy = 0;
public $sumDodge = 0;
public $sumCriticals = 0;
/**
* DressedItems constructor.
*
* @param $user_id - ID игрока.
*/
public function __construct($user_id)
{
@ -49,8 +42,10 @@ SELECT SUM(add_strength) as sum_strength,
SUM(add_intelligence) as sum_intelligence,
SUM(add_wisdom) as sum_wisdom,
SUM(add_accuracy) as sum_accuracy,
SUM(add_dodge) as sum_dodge,
SUM(add_criticals) as sum_criticals
SUM(add_evasion) as sum_evasion,
SUM(add_criticals) as sum_criticals,
SUM(min_physical_damage) as sum_min_phys_damage,
SUM(max_physical_damage) as sum_max_phys_damage
FROM inventory WHERE owner_id = ?i AND dressed_slot > 0'
SQL;
$this->DBSUM = db::c()->query($query, $this->USERID)->fetch_assoc();
@ -106,9 +101,9 @@ SQL;
{
return $this->getBonuses()['sum_accuracy'];
}
public function getDodgeBonus()
public function getEvasionBonus()
{
return $this->getBonuses()['sum_dodge'];
return $this->getBonuses()['sum_evasion'];
}
public function getCriticalsBonus()
{

View File

@ -25,6 +25,9 @@ class User
public $room;
public $block;
public $shadow;
// Удар кулаком всегда 1-2.
public $minDamage = 1;
public $maxDamage = 2;
public const STAT_MAXIMUM_AMOUNT = 40;
// Пока несуществующие, для совместимости.

312
main.php
View File

@ -220,42 +220,12 @@ function sum_dmg($u)
}
}
function sum_bron($u)
{
try {
$sum = db::c()->query('SELECT SUM(`add_proc_bron`) AS `mf` FROM `inventory` WHERE `dressed` = 1 AND `add_proc_bron` > 0 AND `owner` = ?i', $u);
if ($sum->fetch_assoc() > 0) {
return $sum;
} else {
return 0;
}
} catch (\Krugozor\Database\Mysql\Exception $e) {
echo "<div style='background-color: #ffaaaa;'>Ошибка: " . $e->getMessage() . "<br> В файле: " . $e->getFile() . " (" . $e->getLine() . ")</div>";
}
}
function bron_ads($a1, $a2, $a3, $a4, $col)
{
return ['a1' => round(($a1 / 100) * $col), 'a2' => round(($a2 / 100) * $col), 'a3' => round(($a3 / 100) * $col), 'a4' => round(($a4 / 100) * $col)];
}
function max_mf()
{
$r = '';
$mfs = countmf();
if (($mfs['fkrit'] > $mfs['fakrit']) && ($mfs['fkrit'] > $mfs['fuvorot']) && ($mfs['fkrit'] > $mfs['fauvorot'])) {
$r = 'fkrit';
} elseif (($mfs['fakrit'] > $mfs['fkrit']) && ($mfs['fakrit'] > $mfs['fuvorot']) && ($mfs['fakrit'] > $mfs['fauvorot'])) {
$r = 'fakrit';
} elseif (($mfs['fuvorot'] > $mfs['fkrit']) && ($mfs['fuvorot'] > $mfs['fakrit']) && ($mfs['fuvorot'] > $mfs['fauvorot'])) {
$r = 'fuvorot';
} elseif (($mfs['fauvorot'] > $mfs['fkrit']) && ($mfs['fauvorot'] > $mfs['fakrit']) && ($mfs['fauvorot'] > $mfs['fuvorot'])) {
$r = 'fauvorot';
}
return $r;
}
function stack($it_id)
{
global $user;
@ -320,95 +290,6 @@ function del_efs($uid, $id, $type)
}
}
function countmf()
{ //TODO пересчитать модификаторы
//global $user;
// Защита от урона и сокрушение?
$zo = db::c()->query('SELECT 1 FROM `users_effects` WHERE `type` = 201 AND `owner_id` = ?i', $_SESSION['uid'])->getNumRows();
$sokr = db::c()->query('SELECT 1 FROM `users_effects` WHERE `type` = 202 AND `owner_id` = ?i', $_SESSION['uid'])->getNumRows();
$user = new User($_SESSION['uid']);
$userDressedItemsBonuses = new DressedItems($_SESSION['uid']);
function GetWeaponType($idwep)
{
if ($idwep == 0 || $idwep == null || $idwep == '') {
$type = "kulak";
}
$wep = db::c()->query('SELECT `otdel`, `minu` FROM `inventory` WHERE `id` = ?i', $idwep)->fetch_row();
if ($wep[0] == '1') {
$type = "noj";
} elseif ($wep[0] == '12') {
$type = "dubina";
} elseif ($wep[0] == '11') {
$type = "topor";
} elseif ($wep[0] == '13') {
$type = "mech";
} elseif ($wep[1] > 0) {
$type = "buket";
} else {
$type = "kulak";
}
return $type;
}
$bmfud = $bmfbron = 0;
if (!empty($sokr)) {
$bmfud += 5;
}
if (!empty($zo)) {
$bmfbron += 25;
}
$mf = [];
//$user_dress = db::c()->query('SELECT SUM(`minu`), SUM(`maxu`), SUM(`mfkrit`), SUM(`mfakrit`), SUM(`mfuvorot`), SUM(`mfauvorot`), SUM(`bron1`), SUM(`bron2`), SUM(`bron3`), SUM(`bron4`) FROM `inventory` WHERE `dressed` = 1 AND `owner` = ?i', $user['id'])->fetch_row();
//FIXME Брони стало 3, а не 4.
$user_dress[6] = $bmfbron + $user->headArmor;
$user_dress[7] = $bmfbron + $user->chestArmor;
$user_dress[8] = $bmfbron + $user->legArmor;
$user_dress[9] = $bmfbron + $user->legArmor;
$mykrit = $userDressedItemsBonuses->sumIntuition * 2.95; /* + SUM(mfkrit) */
$myakrit = $userDressedItemsBonuses->sumIntuition * 2.75; /* + SUM(mfakrit) */
$myuvorot = $userDressedItemsBonuses->sumDexterity * 5; /* + SUM(mfuvorot) */
$myauvorot = $userDressedItemsBonuses->sumDexterity * 5; /* + SUM(mfauvorot) */
$mf['me'] = ['udar' => (floor($user['sila'] / 3) + 1 + $user_dress[0]), 'maxudar' => (floor($user['sila'] / 3) + 4 + $user_dress[1])];
if ($mf['me']['udar'] < 0) {
$mf['me']['udar'] = 0;
}
$weap_b = 0;
switch (GetWeaponType($user['weap'])) {
case "noj":
$weap_b += $user['noj'];
break;
case "dubina":
$weap_b += $user['dubina'];
break;
case "topor":
$weap_b += $user['topor'];
break;
case "mech":
$weap_b += $user['mec'];
break;
default:
$weap_b = 0;
break;
}
$minu = $mf['me']['udar'] + $bmfud + $weap_b;
$maxu = $mf['me']['maxudar'] + $bmfud + $weap_b;
return ['minu' => $minu, 'maxu' => $maxu, 'fkrit' => round($mykrit, 0), 'fakrit' => round($myakrit, 0), 'fuvorot' => round($myuvorot, 0), 'fauvorot' => round($myauvorot, 0), 'bron1' => $user_dress[6], 'bron2' => $user_dress[7], 'bron3' => $user_dress[8], 'bron4' => $user_dress[9]];
}
// одеть предмет
function dressitem($id)
@ -985,181 +866,32 @@ if (input::get('edit')) {
<!--Параметры-->
<div>
<div class="container">
Сила: <?= $showUser->getStrength(1) ?> +<?= $getItemsBonuses->sumStrength ?><br>
Ловкость: <?= $showUser->getDexterity(1) ?> +<?= $getItemsBonuses->sumDexterity ?><br>
Интуиция: <?= $showUser->getIntuition(1) ?> +<?= $getItemsBonuses->sumIntuition ?><br>
Выносливость: <?= $showUser->getEndurance(1) ?> +<?= $getItemsBonuses->sumEndurance ?><br>
Интеллект: <?= $showUser->getIntelligence(1) ?> +<?= $getItemsBonuses->sumIntelligence ?><br>
Мудрость: <?= $showUser->getWisdom(1) ?> +<?= $getItemsBonuses->sumWisdom ?><br>
<small style="color: darkgreen;">Возможных увеличений: <?= $showUser->stat_points ?></small>
<br><br>
Здоровье: <?= $showUser->getHealth() ?><br>
Уворот: ?? + <?= $getItemsBonuses->sumDodge ?><br>
Точность: ?? + <?= $getItemsBonuses->sumAccuracy ?><br>
Шанс крита: ?? + <?= $getItemsBonuses->sumCriticals ?><br>
</div>
<?php
$mf = countmf();
$min_dmg = 0;
$max_dmg = 0;
$item_mf = db::c()->query('SELECT `id` FROM `inventory` WHERE `owner` = ?i AND `dressed` > 0 AND `add_proc_mf` > 0', $_SESSION['uid'])->fetch_assoc();
$item_damage = db::c()->query('SELECT `id` FROM `inventory` WHERE `owner` = ?i AND `dressed` > 0 AND `add_proc_uron` > 0', $_SESSION['uid'])->fetch_assoc();
$item_bron = db::c()->query('SELECT `id` FROM `inventory` WHERE `owner` = ?i AND `dressed` > 0 AND `add_proc_bron` > 0', $_SESSION['uid'])->fetch_assoc();
if (isset($item_mf['id'])) {
$max_mf = max_mf();
$add_mf = sum_mf($user['id']);
if ($max_mf == 'fkrit') {
$var_mf = round(($mf['fkrit'] / 100) * $add_mf);
$mf['fkrit'] += $var_mf;
} elseif ($max_mf == 'fakrit') {
$var_mf = round(($mf['fakrit'] / 100) * $add_mf);
$mf['fakrit'] += $var_mf;
} elseif ($max_mf == 'fuvorot') {
$var_mf = round(($mf['fuvorot'] / 100) * $add_mf);
$mf['fuvorot'] += $var_mf;
} elseif ($max_mf == 'fauvorot') {
$var_mf = round(($mf['fauvorot'] / 100) * $add_mf);
$mf['fauvorot'] += $var_mf;
}
}
if (isset($item_damage['id'])) {
$add_dmg = sum_dmg($user['id']);
$min_dmg = round(($mf['minu'] / 100) * $add_dmg);
$max_dmg = round(($mf['maxu'] / 100) * $add_dmg);
}
if (isset($item_bron['id'])) {
$add_bron = sum_bron($user['id']);
$var_brons = bron_ads($mf['bron1'], $mf['bron2'], $mf['bron3'], $mf['bron4'], $add_bron);
} else {
$var_brons = ['a1' => 0, 'a2' => 0, 'a3' => 0, 'a4' => 0];
}
?>
<SPAN title='Усредненный по всем типам повреждений для вашего урона, без учета брони и защиты противника.'>Урон: <b><?= $mf['minu'] + $min_dmg ?>
- <?= $mf['maxu'] + $max_dmg ?></b> <?php if (isset($item_damage['id'])) {
echo '<span style=\'color: Green;\'>(' . $add_dmg . '%)</span>';
} ?></span><br>
<SPAN title='Мф. крит. удара позволяет нанести критический удар, наносящий дополнительные повреждения даже сквозь блок.'>Шанс крита: <?= $mf['fkrit'] ?> <?php if (isset($item_mf['id']) && $max_mf == 'fkrit') {
echo '<span style=\'color: Green;\'>(' . $add_mf . '%)</span>';
} ?></span><br>
<SPAN title='Мф. против крит. удара снижает вероятность получения крит. удара'>Шанс антикрита: <?= $mf['fakrit'] ?> <?php if (isset($item_mf['id']) && $max_mf == 'fakrit') {
echo '<span style=\'color: Green;\'>(' . $add_mf . '%)</span>';
} ?></span><br>
<SPAN title='Мф. увертывания позволяет вам уклониться от атаки противника, полностью игнорируя ее.'>Шанс уворота: <?= $mf['fuvorot'] ?> <?php if (isset($item_mf['id']) && $max_mf == 'fuvorot') {
echo '<span style=\'color: Green;\'>(' . $add_mf . '%)</span>';
} ?></span><br>
<SPAN title='Мф. против увертывания снижает шансы противника уклониться от вашей атаки'>Шанс антиуворота: <?= $mf['fauvorot'] ?> <?php if (isset($item_mf['id']) && $max_mf == 'fauvorot') {
echo '<span style=\'color: Green;\'>(' . $add_mf . '%)</span>';
} ?></span><br>
<div class="container">
<b>Владение оружием:</b>
<br>Кинжалами: <?= $user['noj'] ?>
<?php if (!empty($user['stats'])): ?>
<img src=i/up.gif onclick="location.href='?edit=1&upm=noj'">
<?php endif; ?>
<br>Мечами: <?= $user['mec'] ?>
<?php if (!empty($user['stats'])): ?>
<img src=i/up.gif onclick="location.href='?edit=1&upm=mec'">
<?php endif; ?>
<br>Дубинами: <?= $user['dubina'] ?>
<?php if (!empty($user['stats'])): ?>
<img src=i/up.gif onclick="location.href='?edit=1&upm=dubina'">
<?php endif; ?>
<br>Топорами: <?= $user['topor'] ?>
<?php if (!empty($user['stats'])): ?>
<img src=i/up.gif onclick="location.href='?edit=1&upm=topor'">
<?php endif; ?>
<br><br>
<b>Владение магией:</b>
<br>Магия огня: <?= $user['mfire'] ?>
<?php if (!empty($user['stats'])): ?>
<img src=i/up.gif onclick="location.href='?edit=1&upm=mfire'">
<?php endif; ?>
<br>Магия воды: <?= $user['mwater'] ?>
<?php if (!empty($user['stats'])): ?>
<img src=i/up.gif onclick="location.href='?edit=1&upm=mwater'">
<?php endif; ?>
<br>Магия воздуха: <?= $user['mair'] ?>
<?php if (!empty($user['stats'])): ?>
<img src=i/up.gif onclick="location.href='?edit=1&upm=mair'">
<?php endif; ?>
<br>Магия земли: <?= $user['mearth'] ?>
<?php if (!empty($user['stats'])): ?>
<img src=i/up.gif onclick="location.href='?edit=1&upm=mearth'">
<?php endif; ?>
<br>Магия света: <?= $user['mlight'] ?>
<?php if (!empty($user['stats'])): ?>
<img src=i/up.gif onclick="location.href='?edit=1&upm=mlight'">
<?php endif; ?>
<br>Магия серости: <?= $user['mgray'] ?>
<?php if (!empty($user['stats'])): ?>
<img src=i/up.gif onclick="location.href='?edit=1&upm=mgray'">
<?php endif; ?>
<br>Магия тьмы: <?= $user['mdark'] ?>
<?php if (!empty($user['stats'])): ?>
<img src=i/up.gif onclick="location.href='?edit=1&upm=mdark'">
<?php endif; ?>
Сила: <?= $showUser->getStrength(1) ?> +<?= $getItemsBonuses->getStrengthBonus() ?><br>
Ловкость: <?= $showUser->getDexterity(1) ?> +<?= $getItemsBonuses->getDexterityBonus() ?><br>
Интуиция: <?= $showUser->getIntuition(1) ?> +<?= $getItemsBonuses->getIntuitionBonus() ?><br>
Выносливость: <?= $showUser->getEndurance(1) ?> +<?= $getItemsBonuses->getEnduranceBonus() ?><br>
Интеллект: <?= $showUser->getIntelligence(1) ?> +<?= $getItemsBonuses->getIntelliganceBonus() ?><br>
Мудрость: <?= $showUser->getWisdom(1) ?> +<?= $getItemsBonuses->getWisdomBonus() ?><br>
<small style="color: darkgreen;">Возможных увеличений: <?= $showUser->stat_points ?></small><br>
<br>
<small style="color: darkgreen;">Возможных увеличений: <?= $user['master'] ?></small>
<br><br>
Здоровье: <?= $showUser->getHealth() ?><br>
Уворот: ?? + <?= $getItemsBonuses->getEvasionBonus() ?><br>
Точность: ?? + <?= $getItemsBonuses->getAccuracyBonus() ?><br>
Шанс крита: ?? + <?= $getItemsBonuses->getCriticalsBonus() ?><br>
Урон: <?= $showUser->minDamage ?> - <?= $showUser->maxDamage ?> <br>
<br>
<div style="color: gold;">
Защита от огня: ?? <br>
Защита от воды: ?? <br>
Защита от вохдуха: ?? <br>
Защита от земли: ?? <br>
Защита от яда: ?? <br>
</div>
<div class="container">
Броня головы: <?= $mf['bron1'] + $var_brons['a1'] ?><?php if (isset($item_bron['id'])) {
echo '<span style=\'color: Green;\'>(' . $add_bron . '%)</span>';
} ?><BR>
Броня корпуса: <?= $mf['bron2'] + $var_brons['a2'] ?><?php if (isset($item_bron['id'])) {
echo '<span style=\'color: Green;\'>(' . $add_bron . '%)</span>';
} ?><BR>
Броня пояса: <?= $mf['bron3'] + $var_brons['a3'] ?><?php if (isset($item_bron['id'])) {
echo '<span style=\'color: Green;\'>(' . $add_bron . '%)</span>';
} ?><BR>
Броня ног: <?= $mf['bron4'] + $var_brons['a4'] ?><?php if (isset($item_bron['id'])) {
echo '<span style=\'color: Green;\'>(' . $add_bron . '%)</span>';
} ?><BR>
Броня головы: <?= $showUser->headArmor ?> <br>
Броня корпуса: <?= $showUser->chestArmor ?> <br>
Броня ног: <?= $showUser->legArmor ?> <br>
</div>
<?php
# Отображение (только отображение!) бонусов за количество статов.
$bonus['fkrit'] = $bonus['fakrit'] = $bonus['fuvorot'] = $bonus['fauvorot'] = $bonus['uminu'] = $bonus['umaxu'] = 0;
if (($user['sila']) >= 25) {
$bonus['fauvorot'] += round($user['sila'] / 3);
$bonus['fakrit'] += round($user['sila'] / 3);
}
// if (($user['sila']) >=100) {
// $bonus['uminu'] += round($user['sila'] / 25);
// $bonus['umaxu'] += round($bonus['uminu'] + $user['sila'] / 100);
// }
if (($user['lovk']) >= 25) {
$bonus['fuvorot'] += round($user['lovk'] / 2);
$bonus['fauvorot'] += round($user['lovk'] / 3);
}
if (($user['inta']) >= 25) {
$bonus['fkrit'] += round($user['inta'] / 2);
$bonus['fakrit'] += round($user['inta'] / 3);
}
if ($user['sila'] >= 25 || $user['lovk'] >= 25 || $user['inta'] >= 25 || $user['vinos'] >= 25) {
echo 'Бонусы за статы:<br>';
if (!empty($bonus['fkrit'])) {
echo "Шанс крита: +" . $bonus['fkrit'] . "<br>";
}
if (!empty($bonus['fakrit'])) {
echo "Шанс антикрита: +" . $bonus['fakrit'] . "<br />";
}
if (!empty($bonus['fuvorot'])) {
echo "Шанс уворота: +" . $bonus['fuvorot'] . "<br />";
}
if (!empty($bonus['fauvorot'])) {
echo "Шанс антиуворота: +" . $bonus['fauvorot'] . "<br />";
}
// if (!empty($bonus['uminu'])) echo "Бонус урона: +" . $bonus['uminu'] . "-" . $bonus['umaxu'];
}
?>
</div>
</TD>
<!--Меню-->