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 Requirements
|
|
|
|
|
{
|
|
|
|
|
private static array $sex = [
|
|
|
|
|
0 => 'Мужской',
|
|
|
|
|
1 => 'Женский',
|
|
|
|
|
];
|
|
|
|
|
private static array $align = [
|
|
|
|
|
1 => 'Свет',
|
|
|
|
|
2 => 'Хаос',
|
|
|
|
|
3 => 'Тьма',
|
|
|
|
|
7 => 'Нейстралитет',
|
|
|
|
|
9 => 'Дитя подземелья',
|
|
|
|
|
];
|
|
|
|
|
private int $alignValue = 0;
|
|
|
|
|
|
|
|
|
|
private array $result = [];
|
2023-11-09 17:24:47 +00:00
|
|
|
|
private Stat $stat;
|
2023-07-28 21:18:04 +00:00
|
|
|
|
|
|
|
|
|
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 $requirementName => $value) {
|
2023-11-09 17:24:47 +00:00
|
|
|
|
if (!$this->stat->getRequirementNames()[$requirementName]) {
|
|
|
|
|
$this->result[$requirementName] = $value; //fixme на период отладки для отлова забытых
|
|
|
|
|
//continue;
|
2023-07-28 21:18:04 +00:00
|
|
|
|
}
|
|
|
|
|
if ($requirementName === 'sex') {
|
|
|
|
|
if (self::$sex[$value]) {
|
|
|
|
|
$value = self::$sex[$value];
|
|
|
|
|
} else {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($requirementName === 'align') {
|
|
|
|
|
if (self::$align[$value]) {
|
|
|
|
|
$this->alignValue = $value;
|
2023-11-09 17:24:47 +00:00
|
|
|
|
$this->result[$requirementName]['sysvalue'] = $value;
|
2023-07-28 21:18:04 +00:00
|
|
|
|
$value = self::$align[$value];
|
|
|
|
|
} else {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-11-09 17:24:47 +00:00
|
|
|
|
//$this->result[$this->stat->getRequirementNames()[$requirementName]] = $value;
|
|
|
|
|
|
2023-07-28 21:18:04 +00:00
|
|
|
|
$this->result[$requirementName] = [
|
2023-11-09 17:24:47 +00:00
|
|
|
|
'name' => $this->stat->getRequirementNames()[$requirementName],
|
2023-07-28 21:18:04 +00:00
|
|
|
|
'value' => $value,
|
|
|
|
|
];
|
|
|
|
|
}
|
2023-11-09 17:24:47 +00:00
|
|
|
|
|
2023-07-28 21:18:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function get(): array
|
|
|
|
|
{
|
|
|
|
|
return $this->result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Число для отрисовки иконки.
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
public function getAlign(): int
|
|
|
|
|
{
|
|
|
|
|
return $this->alignValue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|