WIP: removing User::class public array $items for Stat()::class.

This commit is contained in:
2024-01-08 03:33:20 +02:00
parent 4a7535d67d
commit 9652ee5c8e
22 changed files with 811 additions and 971 deletions

View File

@@ -6,6 +6,7 @@ use Core\Db;
use Helper\Conversion;
use JetBrains\PhpStorm\NoReturn;
use Model\ActionModel;
use Model\Constant\Stat;
use User\Effects;
use User\InfoBox;
use User\ItemsModel;
@@ -562,6 +563,7 @@ class User
private InfoBox $infoBox;
private Reputation $reputation;
private Stats $userStats;
private Stat $statnames;
private function __construct(int $uid = 0)
{
@@ -586,6 +588,8 @@ class User
$this->stats = $this->userStats->getStats($this->info);
$this->infoTasks();
$this->statnames->getBonus();
$this->statnames->getRequirement();
if (Core\Config::get('securetime') > 0) {
if (!defined('IP')) {
@@ -910,7 +914,7 @@ class User
) . '" AND `sex` = "' . $this->info['sex'] . '" AND (`login` = "" OR `login` = "' . $this->info['login'] . '") LIMIT 1'
)
);
$t = $this->items['tr'];
$x = 0;
$po = Conversion::dataStringToArray($o['tr']);
if ($o['itm'] > 0) {
@@ -938,8 +942,8 @@ class User
$j++;
}
}
while ($x < count($t)) {
$n = $t[$x];
while ($x < count($this->statnames->sysRequirementNames)) {
$n = $this->statnames->sysRequirementNames[$x];
if (isset($po['tr_' . $n]) && $po['tr_' . $n] > $this->stats[$n]) {
$tr = false;
}
@@ -969,7 +973,7 @@ class User
'SELECT `id`,`sex`,`tr`,`img`,`login`,`level`,`admin`,`align`,`clan`,`itm` FROM `obraz` WHERE `id` = "' . ((int)$_GET['obr_sel']) . '" AND `sex` = "' . $this->info['sex'] . '" AND (`login` = "" OR `login` = "' . $this->info['login'] . '") LIMIT 1'
)
);
$t = $this->items['tr'];
$x = 0;
$po = Conversion::dataStringToArray($o['tr']);
if ($o['itm'] > 0) {
@@ -1005,8 +1009,8 @@ class User
$this->error = 'Необходимы предметы: ' . $tritm;
}
}
while ($x < count($t)) {
$n = $t[$x];
while ($x < count($this->statnames->sysRequirementNames)) {
$n = $this->statnames->sysRequirementNames[$x];
if (isset($po['tr_' . $n]) && $po['tr_' . $n] > $this->stats[$n]) {
$tr = false;
$this->error = 'Недостаточно характеристик или параметров персонажа';
@@ -2555,9 +2559,9 @@ class User
);
$j = 0;
$data_r = Conversion::dataStringToArray($ritm['data']);
while ($j < count($this->items['add'])) {
if (isset($data_r['add_' . $this->items['add'][$j]])) {
$data['add_' . $this->items['add'][$j]] -= $data_r['add_' . $this->items['add'][$j]];
while ($j < count($this->statnames->sysBonusNames)) {
if (isset($data_r['add_' . $this->statnames->sysBonusNames[$j]])) {
$data['add_' . $this->statnames->sysBonusNames[$j]] -= $data_r['add_' . $this->statnames->sysBonusNames[$j]];
}
$j++;
}
@@ -2569,9 +2573,9 @@ class User
//Добавляем характеристики руны
$add = Conversion::dataStringToArray($rune['data']);
$i = 0;
while ($i < count($this->items['add'])) {
if (isset($add['add_' . $this->items['add'][$i]])) {
$data['add_' . $this->items['add'][$i]] += $add['add_' . $this->items['add'][$i]];
while ($i < count($this->statnames->sysBonusNames)) {
if (isset($add['add_' . $this->statnames->sysBonusNames[$i]])) {
$data['add_' . $this->statnames->sysBonusNames[$i]] += $add['add_' . $this->statnames->sysBonusNames[$i]];
}
$i++;
}
@@ -2796,9 +2800,9 @@ class User
);
$j = 0;
$data_r = Conversion::dataStringToArray($ritm['data']);
while ($j < count($this->items['add'])) {
if (isset($data_r['add_' . $this->items['add'][$j]])) {
$pvr['rune'][$this->items['add'][$j]] = $data_r['add_' . $this->items['add'][$j]];
while ($j < count($this->statnames->sysBonusNames)) {
if (isset($data_r['add_' . $this->statnames->sysBonusNames[$j]])) {
$pvr['rune'][$this->statnames->sysBonusNames[$j]] = $data_r['add_' . $this->statnames->sysBonusNames[$j]];
}
$j++;
}
@@ -2808,39 +2812,24 @@ class User
$data['add_hpAll'] -= $data['spell_st_val_hp'];
}
//$i = 0;
//while( $i < count($data)) {
if (!isset($data['spell_st_name'])) {
$delk = count($this->items['add']);
$this->items['add'][] = 'mib1';
$this->items['add'][] = 'mib2';
$this->items['add'][] = 'mib3';
$this->items['add'][] = 'mib4';
$this->items['add'][] = 'mab1';
$this->items['add'][] = 'mab2';
$this->items['add'][] = 'mab3';
$this->items['add'][] = 'mab4';
$j = 0;
while ($j < count($this->items['add'])) {
if (isset($data['add_' . $this->items['add'][$j]])) {
if ($data_l['add_' . $this->items['add'][$j]] != $data['add_' . $this->items['add'][$j]] - $pvr['rune'][$this->items['add'][$j]] - $pvr['podgon'][$this->items['add'][$j]]) {
//echo ''.$this->items['add'][$j].' -> '.$data_l['add_'.$this->items['add'][$j]].' / '.$data['add_'.$this->items['add'][$j]].'<br>';
if (!isset($data_l['add_' . $this->items['add'][$j]])) {
unset($data['add_' . $this->items['add'][$j]]);
} else {
$data['add_' . $this->items['add'][$j]] = $data_l['add_' . $this->items['add'][$j]];
}
while ($j < count($this->statnames->sysBonusNames)) {
if (
isset($data['add_' . $this->statnames->sysBonusNames[$j]]) &&
$data_l['add_' . $this->statnames->sysBonusNames[$j]] != $data['add_' . $this->statnames->sysBonusNames[$j]] - $pvr['rune'][$this->statnames->sysBonusNames[$j]] - $pvr['podgon'][$this->statnames->sysBonusNames[$j]]
) {
if (!isset($data_l['add_' . $this->statnames->sysBonusNames[$j]])) {
unset($data['add_' . $this->statnames->sysBonusNames[$j]]);
} else {
$data['add_' . $this->statnames->sysBonusNames[$j]] = $data_l['add_' . $this->statnames->sysBonusNames[$j]];
}
}
$j++;
}
$i = 0;
while ($i < 8) {
unset($this->items['add'][$delk + $i]);
$i++;
}
}
}
//Новая чарка
$i = 0;
$utp = explode(',', $add['onItemType']);
@@ -2858,9 +2847,9 @@ class User
$tw = '';
}
$j = 0;
while ($j < count($this->items['add'])) {
if (isset($add[$tw . 'add' . $utp[$i] . '_' . $this->items['add'][$j]])) {
$rnda[count($rnda)] = $this->items['add'][$j];
while ($j < count($this->statnames->sysBonusNames)) {
if (isset($add[$tw . 'add' . $utp[$i] . '_' . $this->statnames->sysBonusNames[$j]])) {
$rnda[] = $this->statnames->sysBonusNames[$j];
}
$j++;
}
@@ -3068,13 +3057,12 @@ class User
$data['upatack_id'] = $rune['item_id'];
$data['upatack_name'] = $rune['name'];
$data['upatack_lvl'] = $add['upatack'];
$data['upatack_lvl'] = $add['upatack'];
//Добавляем характеристики руны
$i = 0;
while ($i < count($this->items['add'])) {
if (isset($add['add_' . $this->items['add'][$i]])) {
$data['add_' . $this->items['add'][$i]] += $add['add_' . $this->items['add'][$i]];
while ($i < count($this->statnames->sysBonusNames)) {
if (isset($add['add_' . $this->statnames->sysBonusNames[$i]])) {
$data['add_' . $this->statnames->sysBonusNames[$i]] += $add['add_' . $this->statnames->sysBonusNames[$i]];
}
$i++;
}
@@ -3653,72 +3641,66 @@ class User
$notr++;
}
$tr = '';
$t = $this->items['tr'];
$x = 0;
while ($x < count($t)) {
$n = $t[$x];
if (isset($po['tr_' . $n]) && $po['tr_' . $n] != 0) {
while ($x < count($this->statnames->sysRequirementNames)) {
$n = $this->statnames->sysRequirementNames[$x];
if (!empty($po['tr_' . $n])) {
if ($n == 'sex') {
if ($this->info['sex'] != $po['tr_' . $n]) {
$tr .= '<font color="red">';
$tr .= '<span style="color: red;">';
$notr++;
}
} elseif ($po['tr_' . $n] > $this->stats[$n]) {
if ($n == 'align_bs' && $this->info['inTurnir'] > 0) {
if ($po['tr_align_bs'] == '1') {
$pal = !($this->info['align_real'] <= 1 || $this->info['align_real'] >= 2);
} elseif ($po['tr_align_bs'] == '3') {
$tar = !($this->info['align_real'] <= 3 || $this->info['align_real'] >= 4);
}
}
if ($n == 'rep') {
$temp = explode('::', $po['tr_' . $n]);
if ($this->rep['rep' . $temp[1]] < $temp[0]) {
$tr .= '<font color="red">';
$tr .= '<span style="color: red;">';
$notr++;
}
unset($temp);
} elseif ($n == 'align_bs' && $this->info['inTurnir'] > 0 && ($pal = false || $tar = false)) {
$tr .= '<font color="red">';
} elseif ($n == 'align_bs' && $this->info['inTurnir'] > 0) {
$tr .= '<span style="color: red;">';
$notr++;
} elseif ($n != 'align' && $n != 'align_bs' || floor(
$this->info['align']
) != $po['tr_' . $n]) {
$tr .= '<font color="red">';
$tr .= '<span style="color: red;">';
$notr++;
}
}
$tr .= '<br />• ';
if ($n == 'rep') {
$temp = explode('::', $po['tr_' . $n]);
$tr .= $this->is[$n] . ' ' . ucfirst(
$tr .= $this->statnames->requirementNames[$n] . ' ' . ucfirst(
str_replace('city', ' city', $temp[1])
) . ': ' . $temp[0];
unset($temp);
} elseif ($n != 'align' && $n != 'align_bs') {
if ($n == 'sex') {
if ($po['tr_' . $n] == 1) {
$tr .= $this->is[$n] . ': Женский';
$tr .= $this->statnames->requirementNames[$n] . ': Женский';
} else {
$tr .= $this->is[$n] . ': Мужской';
$tr .= $this->statnames->requirementNames[$n] . ': Мужской';
}
} else {
$tr .= $this->is[$n] . ': ' . $po['tr_' . $n];
$tr .= $this->statnames->requirementNames[$n] . ': ' . $po['tr_' . $n];
}
} else {
$tr .= $this->is[$n] . ': ' . $this->align_nm[$po['tr_' . $n]];
$tr .= $this->statnames->requirementNames[$n] . ': ' . $this->align_nm[$po['tr_' . $n]];
}
if ($n == 'sex') {
if ($this->info['sex'] != $po['tr_' . $n]) {
$tr .= '</font>';
$tr .= '</span>';
}
} elseif ($po['tr_' . $n] > $this->stats[$n]) {
if ($n == 'align_bs' && $this->info['inTurnir'] > 0 && ($pal = false || $tar = false)) {
$tr .= '</font>';
if ($n == 'align_bs' && $this->info['inTurnir'] > 0) {
$tr .= '</span>';
} elseif ($n != 'align' && $n != 'align_bs' || floor(
$this->info['align']
) != $po['tr_' . $n]) {
$tr .= '</font>';
$tr .= '</span>';
}
}
}
@@ -3729,7 +3711,7 @@ class User
}
//<strong>Действует на:</strong>
$tr = '';
$t = $this->items['add'];
if (isset($po['mf_stats']) && $po['mf_stats'] > 0) {
$tr .= '<br>Свободные характеристики: ' . $po['mf_stats'];
}
@@ -3741,19 +3723,19 @@ class User
}
$x = 0;
while ($x < count($t)) {
$n = $t[$x];
if (isset($po['add_' . $n], $this->is[$n])) {
while ($x < count($this->statnames->sysBonusNames)) {
$n = $this->statnames->sysBonusNames[$x];
if (isset($po['add_' . $n])) {
$z = '+';
if ($po['add_' . $n] < 0) {
$z = '';
}
$tr .= '<br>• ' . $this->is[$n] . ': ' . $z . '' . $po['add_' . $n];
$tr .= '<br>• ' . $this->statnames->bonusNames[$n] . ': ' . $z . $po['add_' . $n];
if (isset($po['mf_stats']) && $po['mf_stats'] > 0 && ($n == 's1' || $n == 's2' || $n == 's3' || $n == 's5')) {
$tr .= ' <a href="main.php?inv=1&otdel=' . $_GET['otdel'] . '&rstv=' . $pl['id'] . '&mf=' . $n . '"><img src="' . Config::img() . '/i/up.gif" width="11" height="11"></a>';
$tr .= ' <a href="/main.php?inv=1&otdel=' . $_GET['otdel'] . '&rstv=' . $pl['id'] . '&mf=' . $n . '"><img src="' . Config::img() . '/i/up.gif" alt=""></a>';
}
if (isset($po['mf_mod']) && $po['mf_mod'] > 0 && ($n == 'm1' || $n == 'm2' || $n == 'm4' || $n == 'm5')) {
$tr .= ' <a href="main.php?inv=1&otdel=' . $_GET['otdel'] . '&rstv=' . $pl['id'] . '&mf=' . $n . '"><img src="' . Config::img() . '/i/up.gif" width="11" height="11"></a>';
$tr .= ' <a href="/main.php?inv=1&otdel=' . $_GET['otdel'] . '&rstv=' . $pl['id'] . '&mf=' . $n . '"><img src="' . Config::img() . '/i/up.gif" alt=""></a>';
}
}
$x++;
@@ -3763,17 +3745,10 @@ class User
$bn = [1 => 'головы', 2 => 'корпуса', 3 => 'пояса', 4 => 'ног'];
while ($i <= 4) {
if (isset($po['add_mab' . $i])) {
if ($po['add_mab' . $i] == $po['add_mib' . $i] && $pl['geniration'] == 1) {
$z = '+';
if ($po['add_mab' . $i] < 0) {
$z = '';
}
$tr .= '<br>• Броня ' . $bn[$i] . ': ' . $z . '' . $po['add_mab' . $i];
} else {
$tr .= '<br>• Броня ' . $bn[$i] . ': ' . $po['add_mib' . $i] . '-' . $po['add_mab' . $i];
}
$tr .= '<br>• Броня ' . $bn[$i] . ': ' . $po['add_mib' . $i] . '-' . $po['add_mab' . $i];
if (isset($po['mf_mib']) && $po['mf_mib'] > 0) {
$tr .= ' <a href="main.php?inv=1&otdel=' . $_GET['otdel'] . '&rstv=' . $pl['id'] . '&mf=mib' . $i . '"><img src="' . Config::img(
$tr .= ' <a href="/main.php?inv=1&otdel=' . $_GET['otdel'] . '&rstv=' . $pl['id'] . '&mf=mib' . $i . '"><img src="' . Config::img(
) . '/i/up.gif" width="11" height="11"></a>';
}
}
@@ -3785,22 +3760,11 @@ class User
}
//<strong>Свойства предмета:</strong>
$tr = '';
$t = $this->items['sv'];
if (isset($po['sv_yron_min'], $po['sv_yron_max'])) {
$tr .= '<br>• Урон: ' . $po['sv_yron_min'] . ' - ' . $po['sv_yron_max'];
}
$x = 0;
while ($x < count($t)) {
$n = $t[$x];
if (isset($po['sv_' . $n])) {
$z = '+';
if ($po['sv_' . $n] < 0) {
$z = '';
}
$tr .= '<br>• ' . $this->is[$n] . ': ' . $z . '' . $po['sv_' . $n];
}
$x++;
}
if ($pl['2too'] == 1) {
$tr .= '<br>• Второе оружие';
}
@@ -3810,20 +3774,16 @@ class User
if (isset($po['zonb'])) {
$tr .= '<br>• Зоны блокирования: ';
if ($po['zonb'] > 0) {
$x = 1;
while ($x <= $po['zonb']) {
$tr .= '+';
$x++;
}
$tr .= str_repeat('+', $po['zonb']);
} else {
$tr .= '—';
}
}
if ($tr != '') {
$is2 .= '<br><strong>Свойства предмета:</strong>' . $tr;
}
if ($notr == 0) {
$d[0] = 1;
if ($pl['magic_inci'] != '' || $pl['magic_inc'] != '') {
@@ -4019,16 +3979,18 @@ class User
$i1c = 0;
$i2c = 0;
$i1e = Conversion::dataStringToArray($plc['data']);
while ($i1c < count($this->items['add'])) {
if (isset($i1e[$this->items['add'][$i1c]])) {
$i3c = $i1e[$this->items['add'][$i1c]];
while ($i1c < count($this->statnames->sysBonusNames)) {
if (isset($i1e[$this->statnames->sysBonusNames[$i1c]])) {
$i3c = $i1e[$this->statnames->sysBonusNames[$i1c]];
if ($i3c > 0) {
$i3c = '+' . $i3c;
}
if ($i2c > 0) {
$com1['text'] .= '&nbsp; &nbsp; ' . $this->is[$this->items['add'][$i1c]] . ': ' . $i3c;
$com1['text'] .= '&nbsp; &nbsp; ' . $this->statnames->bonusNames[$this->statnames->sysBonusNames[$i1c]] . ': ' . $i3c;
} else {
$com1['text'] .= $this->is[$this->items['add'][$i1c]] . ': ' . $i3c;
$com1['text'] .= $this->statnames->bonusNames[$this->statnames->sysBonusNames[$i1c]] . ': ' . $i3c;
}
$com1['text'] .= '<br>';
$i2c++;
@@ -4055,16 +4017,16 @@ class User
$i1c = 0;
$i2c = 0;
$i1e = Conversion::dataStringToArray($plc['data']);
while ($i1c < count($this->items['add'])) {
if (isset($i1e[$this->items['add'][$i1c]])) {
$i3c = $i1e[$this->items['add'][$i1c]];
while ($i1c < count($this->statnames->sysBonusNames)) {
if (isset($i1e[$this->statnames->sysBonusNames[$i1c]])) {
$i3c = $i1e[$this->statnames->sysBonusNames[$i1c]];
if ($i3c > 0) {
$i3c = '+' . $i3c;
}
if ($i2c > 0) {
$com1['text'] .= '&nbsp; &nbsp; ' . $this->is[$this->items['add'][$i1c]] . ': ' . $i3c;
$com1['text'] .= '&nbsp; &nbsp; ' . $this->statnames->bonusNames[$this->statnames->sysBonusNames[$i1c]] . ': ' . $i3c;
} else {
$com1['text'] .= $this->is[$this->items['add'][$i1c]] . ': ' . $i3c;
$com1['text'] .= $this->statnames->bonusNames[$this->statnames->sysBonusNames[$i1c]] . ': ' . $i3c;
}
$com1['text'] .= '<br>';
$i2c++;
@@ -4089,9 +4051,9 @@ class User
$ixi = 0;
while ($sm_pl = mysql_fetch_array($sm_sp)) {
if ($sm_pl['type'] == 0) {
$smt .= '<font class="date">' . date(
$smt .= '<span class="date">' . date(
'd.m.Y H:i', $sm_pl['time']
) . '</font> <strong>' . $sm_pl['login'] . '</strong>. ' . $sm_pl['text'] . '<br>';
) . '</span> <strong>' . $sm_pl['login'] . '</strong>. ' . $sm_pl['text'] . '<br>';
} else {
$smt .= $sm_pl['text'] . '<br>';
}
@@ -4154,8 +4116,8 @@ class User
)
);
if (isset($plpo['id'])) {
$is2 .= ' <font color=grey>(Дар игрока <strong>' . $plpo['login'] . '</strong><a href="info/' . $plpo['id'] . '" target="_blank"><img src="' . Config::img(
) . '/i/inf_' . $plpo['cityreg'] . '.gif" width="9"></a>)</font>';
$is2 .= ' <span style="color: grey;">(Дар игрока <strong>' . $plpo['login'] . '</strong><a href="info/' . $plpo['id'] . '" target="_blank"><img src="' . Config::img(
) . '/i/inf_' . $plpo['cityreg'] . '.gif" width="9"></a>)</span>';
if ($plpo['login'] == $this->info['login']) {
if (isset($_GET['backmyitm'])) {
$pl['inOdet'] = 0;
@@ -5106,8 +5068,6 @@ class User
[$u['id']]
);
$t = $this->items['tr'];
$x = 0;
$notr = 0;
@@ -5140,8 +5100,8 @@ class User
}
$j++;
}
while ($x < count($t)) {
$n = $t[$x];
while ($x < count($this->statnames->sysRequirementNames)) {
$n = $this->statnames->sysRequirementNames[$x];
if (isset($po['tr_' . $n]) && $n == 'sex') {
if ($po['tr_' . $n] != $this->info['sex']) {
$notr++;
@@ -5889,7 +5849,7 @@ LIMIT 1'
private function trItem($po): int
{
$notr = 0;
foreach ($this->items['tr'] as $trn) {
foreach ($this->statnames->sysRequirementNames as $trn) {
if (!isset($po["tr_$trn"])) {
continue;
}