game/_incl_data/class/Item/Data/Bonuses.php

68 lines
1.7 KiB
PHP
Raw Normal View History

<?php
namespace Item\Data;
2023-11-09 17:24:47 +00:00
use Model\Constant\Stat;
class Bonuses
{
2023-11-09 17:24:47 +00:00
private Stat $stat;
private array $result = [];
public function __construct(array $data)
{
2023-11-09 17:24:47 +00:00
$this->stat = new Stat();
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-11-09 17:24:47 +00:00
$this->result[$this->stat->getBonusNames()[$bonusName]] = $value;
}
$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-11-09 17:24:47 +00:00
if (isset($this->result[$this->stat->getBonusNames()['zonb']])) {
$this->result[$this->stat->getBonusNames()['zonb']]++;
} else {
2023-11-09 17:24:47 +00:00
$this->result[$this->stat->getBonusNames()['zonb']] = 1;
}
}
}