game/_incl_data/class/Model/Constant/Stat.php
2023-11-09 19:24:47 +02:00

40 lines
886 B
PHP

<?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);
}
}