diff --git a/hwe/func_converter.php b/hwe/func_converter.php index 9c018368..275c0dd4 100644 --- a/hwe/func_converter.php +++ b/hwe/func_converter.php @@ -223,7 +223,7 @@ function getNationTypeClass(?string $type){ $type = GameConst::$neutralNationType; } - static $basePath = __NAMESPACE__.'\\TriggerNationType\\'; + static $basePath = __NAMESPACE__.'\\ActionNationType\\'; $classPath = ($basePath.$type); if(class_exists($classPath)){ @@ -243,7 +243,7 @@ function getPersonalityClass(?string $type){ $type = GameConst::$neutralPersonality; } - static $basePath = __NAMESPACE__.'\\TriggerPersonality\\'; + static $basePath = __NAMESPACE__.'\\ActionPersonality\\'; $classPath = ($basePath.$type); if(class_exists($classPath)){ @@ -263,7 +263,7 @@ function getGeneralSpecialDomesticClass(?string $type){ $type = GameConst::$defaultSpecialDomestic; } - static $basePath = __NAMESPACE__.'\\TriggerSpecialDomestic\\'; + static $basePath = __NAMESPACE__.'\\ActionSpecialDomestic\\'; $classPath = ($basePath.$type); if(class_exists($classPath)){ @@ -283,7 +283,7 @@ function getGeneralSpecialWarClass(?string $type){ $type = GameConst::$defaultSpecialWar; } - static $basePath = __NAMESPACE__.'\\TriggerSpecialWar\\'; + static $basePath = __NAMESPACE__.'\\ActionSpecialWar\\'; $classPath = ($basePath.$type); if(class_exists($classPath)){ diff --git a/hwe/sammo/TriggerNationType/che_덕가.php b/hwe/sammo/ActionNationType/che_덕가.php similarity index 88% rename from hwe/sammo/TriggerNationType/che_덕가.php rename to hwe/sammo/ActionNationType/che_덕가.php index dc041b84..3d01e661 100644 --- a/hwe/sammo/TriggerNationType/che_덕가.php +++ b/hwe/sammo/ActionNationType/che_덕가.php @@ -1,10 +1,10 @@ logger; } - public function getNationTypeObj():iActionTrigger{ + public function getNationTypeObj():iAction{ return $this->nationType; } - public function getGeneralLevelObj():iActionTrigger{ + public function getGeneralLevelObj():iAction{ return $this->levelObj; } @@ -276,7 +276,7 @@ class General implements iActionTrigger{ return $result; } - public function onPreTurnExecute(General $general):array{ + public function getPreTurnExecuteTriggerList(General $general):array{ $chain = []; foreach(array_merge([ $this->nationType, @@ -288,7 +288,7 @@ class General implements iActionTrigger{ if(!$iObj){ continue; } - $chain[] = $iObj->onPreTurnExecute($general); + $chain[] = $iObj->getPreTurnExecuteTriggerList($general); } return array_merge([], ...$chain); } diff --git a/hwe/sammo/GeneralTriggerCaller.php b/hwe/sammo/GeneralTriggerCaller.php new file mode 100644 index 00000000..63f8a1b2 --- /dev/null +++ b/hwe/sammo/GeneralTriggerCaller.php @@ -0,0 +1,10 @@ +merge($triggerList); + } + + function merge(array $triggerList){ + foreach($triggerList as $trigger){ + if(!checkValidTrigger($trigger)){ + throw new \InvalidArgumentException('Invalid Trigger Type'); + } + /** @var iObjectTrigger $trigger */ + $priority = $trigger->getPriority(); + $uniqueID = $trigger->getUniqueID(); + if(!key_exists($priority, $this->triggerListByPriority)){ + $this->triggerListByPriority[$priority] = []; + } + + $subTriggerList = &$this->triggerListByPriority[$priority]; + + if(key_exists($uniqueID, $subTriggerList)){ + continue; + } + $subTriggerList[$uniqueID] = $trigger; + } + $this->sorted = false; + } + + function fire(?array $env = null, $arg = null):?array{ + if(!$this->sorted){ + krsort($this->triggerListByPriority); + $this->sorted = true; + } + + foreach($this->triggerListByPriority as $subTriggerList){ + /** @var iObjectTrigger[] $subTriggerList */ + foreach($subTriggerList as $trigger){ + $env = $trigger->action($env, $arg); + } + } + return $env; + } + +} \ No newline at end of file diff --git a/hwe/sammo/TriggerGeneralLevel.php b/hwe/sammo/TriggerGeneralLevel.php index af036440..92d0b00b 100644 --- a/hwe/sammo/TriggerGeneralLevel.php +++ b/hwe/sammo/TriggerGeneralLevel.php @@ -1,8 +1,8 @@ getGeneral(); - $general->onPreTurnExecute($general); + $general->getPreTurnExecuteTriggerList($general); if($general->getVar('injury') && !$general->hasActivatedSkill('pre.부상경감')){ $general->increaseVarWithLimit('injury', -10, 0); diff --git a/hwe/sammo/WarUnitTriggerCaller.php b/hwe/sammo/WarUnitTriggerCaller.php new file mode 100644 index 00000000..198405c2 --- /dev/null +++ b/hwe/sammo/WarUnitTriggerCaller.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/hwe/sammo/iObjectTrigger.php b/hwe/sammo/iObjectTrigger.php new file mode 100644 index 00000000..08265a43 --- /dev/null +++ b/hwe/sammo/iObjectTrigger.php @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/hwe/sammo/iWarUnitTrigger.php b/hwe/sammo/iWarUnitTrigger.php new file mode 100644 index 00000000..c7d071a3 --- /dev/null +++ b/hwe/sammo/iWarUnitTrigger.php @@ -0,0 +1,7 @@ + \ No newline at end of file