feat: 특정 등급 이상 도시 보유 조건 추가
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace sammo\GameUnitConstraint;
|
||||||
|
|
||||||
|
use sammo\General;
|
||||||
|
|
||||||
|
use function sammo\getCityLevelList;
|
||||||
|
|
||||||
|
class ReqHighLevelCities extends BaseGameUnitConstraint
|
||||||
|
{
|
||||||
|
|
||||||
|
public readonly array $reqCities;
|
||||||
|
public function __construct(
|
||||||
|
public readonly int $reqCityLevel,
|
||||||
|
public readonly int $reqCityCount
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function test(General $general, array $ownCities, array $ownRegions, int $relativeYear, int $tech, array $nationAux): bool
|
||||||
|
{
|
||||||
|
$cnt = 0;
|
||||||
|
foreach ($ownCities as $cityItem) {
|
||||||
|
if ($cityItem['level'] >= $this->reqCityLevel) {
|
||||||
|
$cnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($cnt >= $this->reqCityCount) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getInfo(): string
|
||||||
|
{
|
||||||
|
$cityLevelText = getCityLevelList()[$this->reqCityLevel];
|
||||||
|
return "{$cityLevelText}성 {$this->reqCityCount}개 이상 소유시 가능";
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user