73 lines
1.9 KiB
PHP
73 lines
1.9 KiB
PHP
<?php
|
||
|
||
namespace Item\Data;
|
||
|
||
use Model\Constant\Stat;
|
||
|
||
class Requirements
|
||
{
|
||
private static array $sex = [
|
||
0 => 'Мужской',
|
||
1 => 'Женский',
|
||
];
|
||
private static array $align = [
|
||
1 => 'Свет',
|
||
2 => 'Хаос',
|
||
3 => 'Тьма',
|
||
7 => 'Нейстралитет',
|
||
9 => 'Дитя подземелья',
|
||
];
|
||
private int $alignValue = 0;
|
||
|
||
private array $result = [];
|
||
|
||
public function __construct(array $data)
|
||
{
|
||
$statnames = new Stat();
|
||
$statnames->getRequirement();
|
||
foreach ($data as $requirementName => $value) {
|
||
if (!$statnames->requirementNames[$requirementName]) {
|
||
$this->result[$requirementName] = $value; //fixme на период отладки для отлова забытых
|
||
//continue;
|
||
}
|
||
if ($requirementName === 'sex') {
|
||
if (self::$sex[$value]) {
|
||
$value = self::$sex[$value];
|
||
} else {
|
||
continue;
|
||
}
|
||
}
|
||
if ($requirementName === 'align') {
|
||
if (self::$align[$value]) {
|
||
$this->alignValue = $value;
|
||
$this->result[$requirementName]['sysvalue'] = $value;
|
||
$value = self::$align[$value];
|
||
} else {
|
||
continue;
|
||
}
|
||
}
|
||
//$this->result[$this->stat->getRequirementNames()[$requirementName]] = $value;
|
||
|
||
$this->result[$requirementName] = [
|
||
'name' => $statnames->requirementNames[$requirementName],
|
||
'value' => $value,
|
||
];
|
||
}
|
||
|
||
}
|
||
|
||
public function get(): array
|
||
{
|
||
return $this->result;
|
||
}
|
||
|
||
/** Число для отрисовки иконки.
|
||
* @return int
|
||
*/
|
||
public function getAlign(): int
|
||
{
|
||
return $this->alignValue;
|
||
}
|
||
}
|
||
|