game/_incl_data/class/Model/Constant/Stat.php

40 lines
886 B
PHP
Raw Normal View History

2023-11-09 17:24:47 +00:00
<?php
namespace Model\Constant;
use Enum\StatFilterCellName;
class Stat extends Constant
{
public function __construct()
{
self::$tableName = 'const_stats';
parent::__construct();
}
public function getBonusNames(): array
{
return $this->filterByCell(StatFilterCellName::Bonus);
}
private function filterByCell(StatFilterCellName $cellName): array
{
$result = [];
foreach ($this->rows as $row) {
if (!$row[$cellName->value]) {
continue;
}
if ($row['sys_name'] === 'level') {
$row['sys_name'] = 'lvl';
}
$result[$row['sys_name']] = $row['name'];
}
return $result;
}
public function getRequirementNames(): array
{
return $this->filterByCell(StatFilterCellName::Requirement);
}
}