2023-07-28 21:18:04 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Item\Data;
|
|
|
|
|
2023-11-09 17:24:47 +00:00
|
|
|
use Model\Constant\Stat;
|
|
|
|
|
2023-07-28 21:18:04 +00:00
|
|
|
class Bonuses
|
|
|
|
{
|
2023-11-09 17:24:47 +00:00
|
|
|
private Stat $stat;
|
2023-07-28 21:18:04 +00:00
|
|
|
private array $result = [];
|
|
|
|
|
|
|
|
public function __construct(array $data)
|
|
|
|
{
|
2023-11-09 17:24:47 +00:00
|
|
|
$this->stat = new Stat();
|
|
|
|
|
2023-07-28 21:18:04 +00:00
|
|
|
foreach ($data as $bonusName => $value) {
|
2023-11-09 17:24:47 +00:00
|
|
|
if (!$this->stat->getBonusNames()[$bonusName]) {
|
|
|
|
$this->result[$bonusName] = $value; //fixme на период отладки для отлова забытых
|
|
|
|
//continue;
|
2023-07-28 21:18:04 +00:00
|
|
|
}
|
2023-11-09 17:24:47 +00:00
|
|
|
$this->result[$this->stat->getBonusNames()[$bonusName]] = $value;
|
2023-07-28 21:18:04 +00:00
|
|
|
}
|
|
|
|
$this->armor($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function armor(array $data): void
|
|
|
|
{
|
|
|
|
$min = 0;
|
|
|
|
$max = 0;
|
|
|
|
$type = [
|
|
|
|
1 => 'головы',
|
|
|
|
2 => 'корпуса',
|
|
|
|
3 => 'пояса',
|
|
|
|
4 => 'ног',
|
|
|
|
];
|
|
|
|
foreach ($type as $k => $v) {
|
|
|
|
if (!empty($data['mib' . $k])) {
|
|
|
|
$min = $data['mib' . $k];
|
|
|
|
$max = $data['mib' . $k];
|
|
|
|
}
|
|
|
|
if (!empty($data['mab' . $k])) {
|
|
|
|
if (empty($data['mib' . $k])) {
|
|
|
|
$min = $data['mab' . $k];
|
|
|
|
}
|
|
|
|
$max = $data['mab' . $k];
|
|
|
|
}
|
|
|
|
if (empty($min) && empty($max)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$this->result['Броня ' . $v] = $min . ' - ' . $max;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function get(): array
|
|
|
|
{
|
|
|
|
return $this->result;
|
|
|
|
}
|
|
|
|
|
2023-11-02 13:57:39 +00:00
|
|
|
public function addZonb(): void
|
2023-07-28 21:18:04 +00:00
|
|
|
{
|
2023-11-09 17:24:47 +00:00
|
|
|
if (isset($this->result[$this->stat->getBonusNames()['zonb']])) {
|
|
|
|
$this->result[$this->stat->getBonusNames()['zonb']]++;
|
2023-07-28 21:18:04 +00:00
|
|
|
} else {
|
2023-11-09 17:24:47 +00:00
|
|
|
$this->result[$this->stat->getBonusNames()['zonb']] = 1;
|
2023-07-28 21:18:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|