From 89ecbe34ed994452dd5d371eb425bc12b4e58c46 Mon Sep 17 00:00:00 2001 From: hide_d Date: Mon, 1 Oct 2018 02:02:30 +0900 Subject: [PATCH] =?UTF-8?q?Trigger,=20Action=20=EC=97=AD=ED=95=A0=20?= =?UTF-8?q?=EC=9E=AC=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func_converter.php | 8 +-- .../che_덕가.php | 8 +-- .../che_도가.php | 8 +-- .../che_도적.php | 8 +-- .../che_명가.php | 8 +-- .../che_묵가.php | 8 +-- .../che_법가.php | 8 +-- .../che_병가.php | 8 +-- .../che_불가.php | 8 +-- .../che_오두미도.php | 8 +-- .../che_유가.php | 8 +-- .../che_음양가.php | 8 +-- .../che_종횡가.php | 8 +-- hwe/sammo/ActionNationType/che_중립.php | 15 +++++ .../che_태평도.php | 8 +-- hwe/sammo/ActionPersonality/None.php | 11 ++++ .../che_대의.php | 8 +-- .../che_안전.php | 8 +-- .../che_왕좌.php | 8 +-- .../che_유지.php | 8 +-- .../che_은둔.php | 8 +-- .../che_의협.php | 8 +-- .../che_재간.php | 8 +-- .../che_정복.php | 8 +-- .../che_출세.php | 8 +-- .../che_패권.php | 8 +-- .../che_할거.php | 8 +-- .../None.php | 8 +-- .../che_경작.php | 8 +-- .../che_귀모.php | 8 +-- .../che_발명.php | 8 +-- .../che_상재.php | 8 +-- .../che_수비.php | 8 +-- .../che_인덕.php | 8 +-- .../che_축성.php | 8 +-- .../che_통찰.php | 8 +-- .../None.php | 8 +-- .../che_격노.php | 8 +-- .../che_견고.php | 8 +-- .../che_공성.php | 8 +-- .../che_궁병.php | 8 +-- .../che_귀병.php | 8 +-- .../che_기병.php | 8 +-- .../che_돌격.php | 8 +-- .../che_무쌍.php | 8 +-- .../che_반계.php | 8 +-- .../che_보병.php | 8 +-- .../che_신산.php | 8 +-- .../che_신중.php | 8 +-- .../che_위압.php | 8 +-- .../che_의술.php | 10 ++-- .../che_저격.php | 8 +-- .../che_집중.php | 8 +-- .../che_징병.php | 8 +-- .../che_척사.php | 8 +-- .../che_필살.php | 8 +-- .../che_환술.php | 8 +-- hwe/sammo/DefaultActionTrigger.php | 4 +- hwe/sammo/General.php | 16 +++--- hwe/sammo/GeneralTriggerCaller.php | 10 ++++ hwe/sammo/TriggerCaller.php | 55 +++++++++++++++++++ hwe/sammo/TriggerGeneralLevel.php | 4 +- hwe/sammo/TriggerNationType/che_중립.php | 15 ----- hwe/sammo/TriggerPersonality/None.php | 11 ---- hwe/sammo/TurnExecutionHelper.php | 2 +- hwe/sammo/WarUnitTriggerCaller.php | 10 ++++ hwe/sammo/{iActionTrigger.php => iAction.php} | 16 +++++- hwe/sammo/iGeneralTrigger.php | 7 +++ hwe/sammo/iObjectTrigger.php | 9 +++ hwe/sammo/iWarUnitTrigger.php | 7 +++ 70 files changed, 372 insertions(+), 262 deletions(-) rename hwe/sammo/{TriggerNationType => ActionNationType}/che_덕가.php (88%) rename hwe/sammo/{TriggerNationType => ActionNationType}/che_도가.php (84%) rename hwe/sammo/{TriggerNationType => ActionNationType}/che_도적.php (86%) rename hwe/sammo/{TriggerNationType => ActionNationType}/che_명가.php (86%) rename hwe/sammo/{TriggerNationType => ActionNationType}/che_묵가.php (81%) rename hwe/sammo/{TriggerNationType => ActionNationType}/che_법가.php (86%) rename hwe/sammo/{TriggerNationType => ActionNationType}/che_병가.php (87%) rename hwe/sammo/{TriggerNationType => ActionNationType}/che_불가.php (85%) rename hwe/sammo/{TriggerNationType => ActionNationType}/che_오두미도.php (88%) rename hwe/sammo/{TriggerNationType => ActionNationType}/che_유가.php (85%) rename hwe/sammo/{TriggerNationType => ActionNationType}/che_음양가.php (87%) rename hwe/sammo/{TriggerNationType => ActionNationType}/che_종횡가.php (87%) create mode 100644 hwe/sammo/ActionNationType/che_중립.php rename hwe/sammo/{TriggerNationType => ActionNationType}/che_태평도.php (87%) create mode 100644 hwe/sammo/ActionPersonality/None.php rename hwe/sammo/{TriggerPersonality => ActionPersonality}/che_대의.php (73%) rename hwe/sammo/{TriggerPersonality => ActionPersonality}/che_안전.php (80%) rename hwe/sammo/{TriggerPersonality => ActionPersonality}/che_왕좌.php (73%) rename hwe/sammo/{TriggerPersonality => ActionPersonality}/che_유지.php (80%) rename hwe/sammo/{TriggerPersonality => ActionPersonality}/che_은둔.php (85%) rename hwe/sammo/{TriggerPersonality => ActionPersonality}/che_의협.php (80%) rename hwe/sammo/{TriggerPersonality => ActionPersonality}/che_재간.php (80%) rename hwe/sammo/{TriggerPersonality => ActionPersonality}/che_정복.php (73%) rename hwe/sammo/{TriggerPersonality => ActionPersonality}/che_출세.php (80%) rename hwe/sammo/{TriggerPersonality => ActionPersonality}/che_패권.php (80%) rename hwe/sammo/{TriggerPersonality => ActionPersonality}/che_할거.php (73%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialDomestic}/None.php (67%) rename hwe/sammo/{TriggerSpecialDomestic => ActionSpecialDomestic}/che_경작.php (82%) rename hwe/sammo/{TriggerSpecialDomestic => ActionSpecialDomestic}/che_귀모.php (81%) rename hwe/sammo/{TriggerSpecialDomestic => ActionSpecialDomestic}/che_발명.php (82%) rename hwe/sammo/{TriggerSpecialDomestic => ActionSpecialDomestic}/che_상재.php (82%) rename hwe/sammo/{TriggerSpecialDomestic => ActionSpecialDomestic}/che_수비.php (82%) rename hwe/sammo/{TriggerSpecialDomestic => ActionSpecialDomestic}/che_인덕.php (83%) rename hwe/sammo/{TriggerSpecialDomestic => ActionSpecialDomestic}/che_축성.php (82%) rename hwe/sammo/{TriggerSpecialDomestic => ActionSpecialDomestic}/che_통찰.php (82%) rename hwe/sammo/{TriggerSpecialDomestic => ActionSpecialWar}/None.php (66%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_격노.php (77%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_견고.php (73%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_공성.php (81%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_궁병.php (78%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_귀병.php (75%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_기병.php (79%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_돌격.php (74%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_무쌍.php (72%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_반계.php (73%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_보병.php (80%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_신산.php (81%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_신중.php (69%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_위압.php (74%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_의술.php (73%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_저격.php (74%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_집중.php (69%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_징병.php (75%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_척사.php (75%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_필살.php (73%) rename hwe/sammo/{TriggerSpecialWar => ActionSpecialWar}/che_환술.php (71%) create mode 100644 hwe/sammo/GeneralTriggerCaller.php create mode 100644 hwe/sammo/TriggerCaller.php delete mode 100644 hwe/sammo/TriggerNationType/che_중립.php delete mode 100644 hwe/sammo/TriggerPersonality/None.php create mode 100644 hwe/sammo/WarUnitTriggerCaller.php rename hwe/sammo/{iActionTrigger.php => iAction.php} (72%) create mode 100644 hwe/sammo/iGeneralTrigger.php create mode 100644 hwe/sammo/iObjectTrigger.php create mode 100644 hwe/sammo/iWarUnitTrigger.php 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