feat(wip): GameUnitConstrint
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace sammo;
|
||||
|
||||
use sammo\GameUnitConstraint\GameUnitConstraint;
|
||||
use sammo\GameUnitConstraint\BaseGameUnitConstraint;
|
||||
|
||||
class GameUnitDetail implements iAction
|
||||
{
|
||||
@@ -18,19 +18,16 @@ class GameUnitDetail implements iAction
|
||||
public $magicCoef;
|
||||
public $cost;
|
||||
public $rice;
|
||||
public $reqTech;
|
||||
public $reqCities;
|
||||
public $reqRegions;
|
||||
public $reqYear;
|
||||
public $attackCoef;
|
||||
public $defenceCoef;
|
||||
public $info;
|
||||
public $initSkillTrigger;
|
||||
public $phaseSkillTrigger;
|
||||
/** @var iAction[]|null iActionList */
|
||||
public $iActionList;
|
||||
public array $reqConstraints;
|
||||
|
||||
protected ?string $info;
|
||||
|
||||
public function __construct(
|
||||
int $id,
|
||||
int $armType,
|
||||
@@ -45,7 +42,6 @@ class GameUnitDetail implements iAction
|
||||
array $reqConstraints,
|
||||
array $attackCoef,
|
||||
array $defenceCoef,
|
||||
array $info,
|
||||
?array $initSkillTrigger,
|
||||
?array $phaseSkillTrigger,
|
||||
?array $iActionList,
|
||||
@@ -63,7 +59,6 @@ class GameUnitDetail implements iAction
|
||||
$this->reqConstraints = $reqConstraints;
|
||||
$this->attackCoef = $attackCoef;
|
||||
$this->defenceCoef = $defenceCoef;
|
||||
$this->info = $info;
|
||||
$this->initSkillTrigger = $initSkillTrigger;
|
||||
$this->phaseSkillTrigger = $phaseSkillTrigger;
|
||||
$this->iActionList = [];
|
||||
@@ -78,7 +73,16 @@ class GameUnitDetail implements iAction
|
||||
|
||||
public function getInfo(): string
|
||||
{
|
||||
return join("\n<br>", $this->info);
|
||||
if($this->info !== null){
|
||||
return $this->info;
|
||||
}
|
||||
|
||||
$info = [];
|
||||
foreach ($this->reqConstraints as $constraint) {
|
||||
$info[] = $constraint->getInfo();
|
||||
}
|
||||
$this->info = join("\n<br>", $info);
|
||||
return $this->info;
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
@@ -195,8 +199,10 @@ class GameUnitDetail implements iAction
|
||||
//음수 없음
|
||||
$relativeYear = max(0, $relativeYear);
|
||||
|
||||
if ($relativeYear < $this->reqYear) {
|
||||
return false;
|
||||
foreach($this->reqConstraints as $constraint){
|
||||
if(!$constraint->test($ownCities, $ownRegions, $relativeYear, $tech)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($tech < $this->reqTech) {
|
||||
|
||||
Reference in New Issue
Block a user