fix: ReqCities, ReqRegion 버그

This commit is contained in:
2025-01-21 17:13:37 +00:00
parent 9f81c760d0
commit 84fee0f1f2
7 changed files with 52 additions and 42 deletions
+12 -7
View File
@@ -26,7 +26,7 @@ class GameUnitDetail implements iAction
public $iActionList;
public array $reqConstraints;
protected ?string $info;
protected ?array $info = null;
public function __construct(
int $id,
@@ -42,6 +42,7 @@ class GameUnitDetail implements iAction
array $reqConstraints,
array $attackCoef,
array $defenceCoef,
public readonly array $baseInfo,
?array $initSkillTrigger,
?array $phaseSkillTrigger,
?array $iActionList,
@@ -75,20 +76,24 @@ class GameUnitDetail implements iAction
}
}
public function getInfo(): string
{
public function getInfoArr(): array {
if($this->info !== null){
return $this->info;
}
$info = [];
$info = $this->baseInfo;
foreach ($this->reqConstraints as $constraint) {
$info[] = $constraint->getInfo();
}
$this->info = join("\n<br>", $info);
$this->info = $info;
return $this->info;
}
public function getInfo(): string
{
return join("\n<br>", $this->getInfoArr());
}
public function getShortName(): string
{
return StringUtil::subStringForWidth($this->name, 0, 4);
@@ -198,13 +203,13 @@ class GameUnitDetail implements iAction
return $defaultWar;
}
public function isValid($ownCities, $ownRegions, $relativeYear, $tech)
public function isValid(General $general, $ownCities, $ownRegions, $relativeYear, $tech, $nationAux = [])
{
//음수 없음
$relativeYear = max(0, $relativeYear);
foreach($this->reqConstraints as $constraint){
if(!$constraint->test($ownCities, $ownRegions, $relativeYear, $tech)){
if(!$constraint->test($general, $ownCities, $ownRegions, $relativeYear, $tech, $nationAux)){
return false;
}
}