diff --git a/hwe/sammo/Command/BaseCommand.php b/hwe/sammo/Command/BaseCommand.php index ba49666e..8c62b0fd 100644 --- a/hwe/sammo/Command/BaseCommand.php +++ b/hwe/sammo/Command/BaseCommand.php @@ -5,6 +5,7 @@ use \sammo\{ Util, JosaUtil, DB, General, GameConst, ActionLogger, + Json, LastTurn, NotInheritedMethodException, RandUtil @@ -170,6 +171,10 @@ abstract class BaseCommand{ else{ $this->nation = $nation; } + + if(key_exists('aux', $this->nation) && is_string($this->nation['aux'])){ + $this->nation['aux'] = Json::decode($this->nation['aux']); + } } protected function setDestGeneral(General $destGeneralObj){ @@ -312,12 +317,12 @@ abstract class BaseCommand{ $this->generalObj->unpackAux(); $constraintInput = [ - 'general'=>$this->generalObj->getRaw(), + 'general'=>$this->generalObj, 'city'=>$this->city, 'nation'=>$this->nation, 'cmd_arg'=>$this->arg, - 'destGeneral'=>$this->destGeneralObj?$this->destGeneralObj->getRaw():null, + 'destGeneral'=>$this->destGeneralObj??null, 'destCity'=>$this->destCity, 'destNation'=>$this->destNation, ]; diff --git a/hwe/sammo/Constraint/Constraint.php b/hwe/sammo/Constraint/Constraint.php index 44fc448f..e4135db1 100644 --- a/hwe/sammo/Constraint/Constraint.php +++ b/hwe/sammo/Constraint/Constraint.php @@ -2,6 +2,8 @@ namespace sammo\Constraint; +use sammo\General; + abstract class Constraint { private function __construct() @@ -24,6 +26,8 @@ abstract class Constraint const REQ_VALUES = 0; + /** @var ?General */ + protected $generalObj = null; protected $general = null; protected $city = null; protected $nation = null; @@ -33,6 +37,8 @@ abstract class Constraint protected $cmd_arg = null; + /** @var ?General */ + protected $destGeneralObj = null; protected $destGeneral = null; protected $destCity = null; protected $destNation = null; @@ -48,9 +54,10 @@ abstract class Constraint return static::REQ_VALUES; } - public function setGeneral(array $general) + public function setGeneral(General $general) { - $this->general = $general; + $this->generalObj = $general; + $this->general = $general->getRaw(); $this->tested = false; $this->reason = null; } @@ -85,9 +92,10 @@ abstract class Constraint $this->reason = null; } - public function setDestGeneral(array $general) + public function setDestGeneral(General $general) { - $this->destGeneral = $general; + $this->destGeneralObj = $general; + $this->destGeneral = $general->getRaw(); $this->tested = false; $this->reason = null; }