Подсчёт бонусных очков
This commit is contained in:
parent
6e73380b82
commit
0cc3454086
@ -9,23 +9,36 @@ class DressedItems
|
|||||||
{
|
{
|
||||||
protected $DB;
|
protected $DB;
|
||||||
protected $DBSUM;
|
protected $DBSUM;
|
||||||
|
protected $USERID;
|
||||||
private $dressedItem;
|
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.
|
* DressedItems constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct() {}
|
public function __construct($user_id)
|
||||||
|
{
|
||||||
|
$this->USERID = $user_id;
|
||||||
|
}
|
||||||
|
|
||||||
private function getDressedItems($user_id)
|
private function getDressedItems()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->DB = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $user_id);
|
$this->DB = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $this->USERID);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo '<div class="debug">Не прогрузилась таблица inventory (*) для класса DressedItems.</div>';
|
echo '<div class="debug">Не прогрузилась таблица inventory (*) для класса DressedItems.</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getBonusesFromDressedItems($user_id)
|
protected function getBonusesFromDressedItems()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$query = <<<SQL
|
$query = <<<SQL
|
||||||
@ -40,16 +53,16 @@ SELECT SUM(add_strength) as sum_strength,
|
|||||||
SUM(add_criticals) as sum_criticals
|
SUM(add_criticals) as sum_criticals
|
||||||
FROM inventory WHERE owner_id = ?i AND dressed_slot > 0'
|
FROM inventory WHERE owner_id = ?i AND dressed_slot > 0'
|
||||||
SQL;
|
SQL;
|
||||||
$this->DBSUM = db::c()->query($query, $user_id)->fetch_assoc();
|
$this->DBSUM = db::c()->query($query, $this->USERID)->fetch_assoc();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo '<div class="debug">Не прогрузилась таблица inventory (SUM) для класса DressedItems.</div>';
|
echo '<div class="debug">Не прогрузилась таблица inventory (SUM) для класса DressedItems:' . $e . '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getItemsInSlots($user_id)
|
public function getItemsInSlots()
|
||||||
{
|
{
|
||||||
if (!$this->DB) {
|
if (!$this->DB) {
|
||||||
$this->getDressedItems($user_id);
|
$this->getDressedItems();
|
||||||
}
|
}
|
||||||
while ($row = $this->DB->fetch_assoc()) {
|
while ($row = $this->DB->fetch_assoc()) {
|
||||||
$dressed_item[$row['dressed_slot']] = $row;
|
$dressed_item[$row['dressed_slot']] = $row;
|
||||||
@ -57,12 +70,50 @@ SQL;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBonusesAmount($user_id)
|
protected function getBonuses()
|
||||||
{
|
{
|
||||||
if (!$this->DBSUM) {
|
if (!$this->DBSUM) {
|
||||||
$this->getBonusesFromDressedItems($user_id);
|
$this->getBonusesFromDressedItems();
|
||||||
}
|
}
|
||||||
return $this->DBSUM;
|
return $this->DBSUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getStrengthBonus()
|
||||||
|
{
|
||||||
|
return $this->getBonuses()['sum_strength'];
|
||||||
|
}
|
||||||
|
public function getDexterityBonus()
|
||||||
|
{
|
||||||
|
return $this->getBonuses()['sum_dexterity'];
|
||||||
|
}
|
||||||
|
public function getIntuitionBonus()
|
||||||
|
{
|
||||||
|
return $this->getBonuses()['sum_intuition'];
|
||||||
|
}
|
||||||
|
public function getEnduranceBonus()
|
||||||
|
{
|
||||||
|
return $this->getBonuses()['sum_endurance'];
|
||||||
|
}
|
||||||
|
public function getIntelliganceBonus()
|
||||||
|
{
|
||||||
|
return $this->getBonuses()['sum_intelligence'];
|
||||||
|
}
|
||||||
|
public function getWisdomBonus()
|
||||||
|
{
|
||||||
|
return $this->getBonuses()['sum_wisdom'];
|
||||||
|
}
|
||||||
|
public function getAccuracyBonus()
|
||||||
|
{
|
||||||
|
return $this->getBonuses()['sum_accuracy'];
|
||||||
|
}
|
||||||
|
public function getDodgeBonus()
|
||||||
|
{
|
||||||
|
return $this->getBonuses()['sum_dodge'];
|
||||||
|
}
|
||||||
|
public function getCriticalsBonus()
|
||||||
|
{
|
||||||
|
return $this->getBonuses()['sum_criticals'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -68,8 +68,8 @@ class User
|
|||||||
private function UserInfoDoll($isBattle = 0, $isMain = 0)
|
private function UserInfoDoll($isBattle = 0, $isMain = 0)
|
||||||
{
|
{
|
||||||
//https://jsfiddle.net/ngx0yvhc
|
//https://jsfiddle.net/ngx0yvhc
|
||||||
$di = new DressedItems();
|
$di = new DressedItems($this->id);
|
||||||
$dressedItems = $di->getItemsInSlots($this->id);
|
$dressedItems = $di->getItemsInSlots();
|
||||||
|
|
||||||
for ($i = 1; $i <= 12; $i++) {
|
for ($i = 1; $i <= 12; $i++) {
|
||||||
echo sprintf('<div class="slot-%s">', $i);
|
echo sprintf('<div class="slot-%s">', $i);
|
||||||
|
44
main.php
44
main.php
@ -329,8 +329,8 @@ function countmf()
|
|||||||
$sokr = db::c()->query('SELECT 1 FROM `users_effects` WHERE `type` = 202 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']);
|
$user = new User($_SESSION['uid']);
|
||||||
$userDressedItems = new DressedItems();
|
$userDressedItemsBonuses = new DressedItems();
|
||||||
$allBonuses = $userDressedItems->getBonusesAmount($_SESSION['uid']) ?? [];
|
|
||||||
|
|
||||||
function GetWeaponType($idwep)
|
function GetWeaponType($idwep)
|
||||||
{
|
{
|
||||||
@ -367,22 +367,17 @@ function countmf()
|
|||||||
$mf = [];
|
$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();
|
//$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;
|
||||||
|
|
||||||
$user_dress[6] = $bmfbron;
|
$mykrit = $allBonuses['sum_intuition'] * 2.95; /* + SUM(mfkrit) */
|
||||||
$user_dress[7] = $bmfbron;
|
$myakrit = $allBonuses['sum_intuition'] * 2.75; /* + SUM(mfakrit) */
|
||||||
$user_dress[8] = $bmfbron;
|
$myuvorot = $allBonuses['sum_dexterity'] * 5; /* + SUM(mfuvorot) */
|
||||||
$user_dress[9] = $bmfbron;
|
$myauvorot = $allBonuses['sum_dexterity'] * 5; /* + SUM(mfauvorot) */
|
||||||
|
|
||||||
$user_dress[6] += $user['ubron1'];
|
|
||||||
$user_dress[7] += $user['ubron2'];
|
|
||||||
$user_dress[8] += $user['ubron3'];
|
|
||||||
$user_dress[9] += $user['ubron4'];
|
|
||||||
|
|
||||||
$mykrit = $user_dress[2] + ($user['inta'] * 2.95);
|
|
||||||
$myakrit = $user_dress[3] + ($user['inta'] * 2.75);
|
|
||||||
|
|
||||||
$myuvorot = $user_dress[4] + ($user['lovk'] * 5);
|
|
||||||
$myauvorot = $user_dress[5] + ($user['lovk'] * 4);
|
|
||||||
|
|
||||||
$mf['me'] = ['udar' => (floor($user['sila'] / 3) + 1 + $user_dress[0]), 'maxudar' => (floor($user['sila'] / 3) + 4 + $user_dress[1])];
|
$mf['me'] = ['udar' => (floor($user['sila'] / 3) + 1 + $user_dress[0]), 'maxudar' => (floor($user['sila'] / 3) + 4 + $user_dress[1])];
|
||||||
|
|
||||||
@ -946,6 +941,7 @@ if (input::get('edit')) {
|
|||||||
<?php
|
<?php
|
||||||
$showUser = new User($_SESSION['uid']);
|
$showUser = new User($_SESSION['uid']);
|
||||||
$showUser->showUserDoll(0, 1);
|
$showUser->showUserDoll(0, 1);
|
||||||
|
$showItemsBonuses = new DressedItems();
|
||||||
?> <!-- Первый столбец -->
|
?> <!-- Первый столбец -->
|
||||||
<div align="center">
|
<div align="center">
|
||||||
<a href='main.php?edit=1&undress=all'>Снять все</a><BR>
|
<a href='main.php?edit=1&undress=all'>Снять все</a><BR>
|
||||||
@ -989,14 +985,18 @@ if (input::get('edit')) {
|
|||||||
<!--Параметры-->
|
<!--Параметры-->
|
||||||
<div>
|
<div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
Сила: <?= $showUser->getStrength(1) ?><br>
|
Сила: <?= $showUser->getStrength(1) + $showItemsBonuses->sumStrength ?><br>
|
||||||
Ловкость: <?= $showUser->getDexterity(1) ?><br>
|
Ловкость: <?= $showUser->getDexterity(1) + $showItemsBonuses->sumDexterity ?><br>
|
||||||
Интуиция: <?= $showUser->getIntuition(1) ?><br>
|
Интуиция: <?= $showUser->getIntuition(1) + $showItemsBonuses->sumIntuition ?><br>
|
||||||
Выносливость: <?= $showUser->getEndurance(1) ?><br>
|
Выносливость: <?= $showUser->getEndurance(1) + $showItemsBonuses->sumEndurance ?><br>
|
||||||
Интеллект: <?= $showUser->getIntelligence(1) ?><br>
|
Интеллект: <?= $showUser->getIntelligence(1) + $showItemsBonuses->sumIntelligence ?><br>
|
||||||
Мудрость: <?= $showUser->getWisdom(1) ?><br>
|
Мудрость: <?= $showUser->getWisdom(1) + $showItemsBonuses->sumWisdom ?><br>
|
||||||
<small style="color: darkgreen;">Возможных увеличений: <?= $showUser->stat_points ?></small>
|
<small style="color: darkgreen;">Возможных увеличений: <?= $showUser->stat_points ?></small>
|
||||||
<br><br>
|
<br><br>
|
||||||
|
Здоровье: <?= $showUser->getHealth() ?><br>
|
||||||
|
Уворот: ?? + <? $showItemsBonuses->sumDodge ?><br>
|
||||||
|
Точность: ?? + <? $showItemsBonuses->sumAccuracy ?><br>
|
||||||
|
Шанс крита: ?? + <? $showItemsBonuses->sumCriticals ?><br>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
$mf = countmf();
|
$mf = countmf();
|
||||||
|
Loading…
Reference in New Issue
Block a user