From 00a6e9798ff1c28e809a69d045de18e529b0e5f8 Mon Sep 17 00:00:00 2001 From: hide_d Date: Mon, 29 Apr 2019 02:04:45 +0900 Subject: [PATCH] =?UTF-8?q?=EC=88=98=EA=B7=B9=EC=9D=84=20=ED=86=B5?= =?UTF-8?q?=ED=95=9C=20=EC=A0=80=EA=B2=A9=20=EC=98=88=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/process_war.php | 8 ++++ hwe/sammo/ActionItem/che_저격_수극.php | 24 ++++++++++ hwe/sammo/BaseWarUnitTrigger.php | 44 ++++++++++++++++- hwe/sammo/GameUnitInitTriggerBase.php | 18 +------ hwe/sammo/GameUnitPhaseTriggerBase.php | 19 ++------ hwe/sammo/TriggerCaller.php | 4 +- hwe/sammo/WarInitTrigger/che_저격발동.php | 32 +++++++++++++ hwe/sammo/WarInitTrigger/che_저격시도.php | 57 +++++++++++++++++++++++ 8 files changed, 172 insertions(+), 34 deletions(-) create mode 100644 hwe/sammo/ActionItem/che_저격_수극.php create mode 100644 hwe/sammo/WarInitTrigger/che_저격발동.php create mode 100644 hwe/sammo/WarInitTrigger/che_저격시도.php diff --git a/hwe/process_war.php b/hwe/process_war.php index 1203061a..9c2ca91b 100644 --- a/hwe/process_war.php +++ b/hwe/process_war.php @@ -294,6 +294,13 @@ function processWar_NG( $attacker->setOppose($defender); $defender->setOppose($attacker); + $initCaller = $attacker->getGeneral()->getBattleInitSkillTriggerList($attacker); + $initCaller->merge($defender->getGeneral()->getBattleInitSkillTriggerList($defender)); + + $initCaller->fire([], [$attacker, $defender]); + //스킬류, 아이템, 스킬 및 아이템 적용 순이어야 할 것 + + /* foreach(Util::zip( $attacker->checkBattleBeginSkill(), $defender->checkBattleBeginSkill() @@ -306,6 +313,7 @@ function processWar_NG( $attacker->applyBattleBeginSkillAndItem(); $defender->applyBattleBeginSkillAndItem(); + */ } $attacker->beginPhase(); diff --git a/hwe/sammo/ActionItem/che_저격_수극.php b/hwe/sammo/ActionItem/che_저격_수극.php new file mode 100644 index 00000000..3600b5c8 --- /dev/null +++ b/hwe/sammo/ActionItem/che_저격_수극.php @@ -0,0 +1,24 @@ +object = $unit; + $this->raiseType = $raiseType; } + + public function action(?array $env=null, $arg=null):?array{ + /** @var WarUnitGeneral $attacker */ + /** @var WarUnit $defender */ + [$attacker, $defender] = $arg; + + + /** @var WarUnit $self */ + $self = $this->object; + $isAttacker = $self->isAttacker(); + $oppose = $isAttacker?$defender:$attacker; + + if($env === null){ + $env = []; + } + if(!key_exists('e_attacker', $env)){ + $env['e_attacker'] = []; + } + if(!key_exists('e_defender', $env)){ + $env['e_defender'] = []; + } + + $selfEnv = $isAttacker?$env['e_attacker']:$env['e_defender']; + $opposeEnv = $isAttacker?$env['e_defender']:$env['e_attacker']; + + $this->actionWar($self, $oppose, $selfEnv, $opposeEnv); + + $env['e_attacker'] = $isAttacker?$selfEnv:$opposeEnv; + $env['e_defender'] = $isAttacker?$opposeEnv:$selfEnv; + + return $env; + } + + abstract protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):void; } diff --git a/hwe/sammo/GameUnitInitTriggerBase.php b/hwe/sammo/GameUnitInitTriggerBase.php index 7d9ab034..af4525fa 100644 --- a/hwe/sammo/GameUnitInitTriggerBase.php +++ b/hwe/sammo/GameUnitInitTriggerBase.php @@ -1,24 +1,10 @@ object = $unit; - $this->unitType = $unit->getCrewType(); - } - - public function action(?array $env=null, $arg=null):?array{ - /** @var WarUnitGeneral $attacker */ - /** @var WarUnit $defender */ - [$attacker, $defender] = $arg; - - $attackerCrewType = $attacker->getCrewType(); - $defenderCrewType = $defender->getCrewType(); - + protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):void{ //TODO: 충차는 성벽 상대로 부상입지 않음 - - return $env; } } \ No newline at end of file diff --git a/hwe/sammo/GameUnitPhaseTriggerBase.php b/hwe/sammo/GameUnitPhaseTriggerBase.php index 2cc8acd4..8c07203f 100644 --- a/hwe/sammo/GameUnitPhaseTriggerBase.php +++ b/hwe/sammo/GameUnitPhaseTriggerBase.php @@ -1,23 +1,10 @@ object = $unit; - $this->unitType = $unit->getCrewType(); - } - - public function action(?array $env=null, $arg=null):?array{ - /** @var WarUnitGeneral $attacker */ - /** @var WarUnit $defender */ - [$attacker, $defender] = $arg; - - $attackerCrewType = $attacker->getCrewType(); - $defenderCrewType = $defender->getCrewType(); - - //TODO: 목우 - return $env; + protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):void{ + //TODO: 목우 목우 } } \ No newline at end of file diff --git a/hwe/sammo/TriggerCaller.php b/hwe/sammo/TriggerCaller.php index d6890237..50928027 100644 --- a/hwe/sammo/TriggerCaller.php +++ b/hwe/sammo/TriggerCaller.php @@ -81,6 +81,8 @@ abstract class TriggerCaller{ return; } + //NOTE: array_merge로 계속 가야하는가? merge가 많으면 SPL의 LinkedList가 낫지 않나? + $newTriggerList = []; $iterLhs = new \ArrayIterator($this->triggerListByPriority); $iterRhs = new \ArrayIterator($other->triggerListByPriority); @@ -96,7 +98,7 @@ abstract class TriggerCaller{ $iterRhs->next(); continue; } - $newTriggerList[$iterLhs->key()] = $iterLhs->current() + $iterRhs->current(); + $newTriggerList[$iterLhs->key()] = array_merge($iterLhs->current(), $iterRhs->current()); $iterLhs->next(); $iterRhs->next(); } diff --git a/hwe/sammo/WarInitTrigger/che_저격발동.php b/hwe/sammo/WarInitTrigger/che_저격발동.php new file mode 100644 index 00000000..1953de25 --- /dev/null +++ b/hwe/sammo/WarInitTrigger/che_저격발동.php @@ -0,0 +1,32 @@ +hasActivatedSkill('저격')){ + return; + } + + if($selfEnv['저격발동']){ + return; + } + $selfEnv['저격발동'] = true; + + $general = $self->general; + + $oppose->getLogger()->pushGeneralActionLog("상대를 저격했다!", ActionLogger::PLAIN); + $oppose->getLogger()->pushGeneralBattleDetailLog("상대를 저격했다!", ActionLogger::PLAIN); + $self->getLogger()->pushGeneralActionLog("상대에게 저격당했다!", ActionLogger::PLAIN); + $self->getLogger()->pushGeneralBattleDetailLog("상대에게 저격당했다!", ActionLogger::PLAIN); + + $general->increaseVarWithLimit('injury', Util::randRangeInt($opposeEnv['woundMin'], $opposeEnv['woundMax']), null, 80); + } +} \ No newline at end of file diff --git a/hwe/sammo/WarInitTrigger/che_저격시도.php b/hwe/sammo/WarInitTrigger/che_저격시도.php new file mode 100644 index 00000000..c2638da4 --- /dev/null +++ b/hwe/sammo/WarInitTrigger/che_저격시도.php @@ -0,0 +1,57 @@ +object = $unit; + $this->raiseType = $raiseType; + } + + protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):void{ + assert($self instanceof WarUnitGeneral, 'General만 발동 가능'); + if(!$oppose instanceof WarUnitGeneral){ + return; + } + if($self->hasActivatedSkill('저격')){ + return; + } + if($self->hasActivatedSkill('저격불가')){ + return; + } + if(!Util::randBool(1/5)){ + return; + } + + $this->activateSkill('저격'); + $selfEnv['woundMin'] = $this->woundMin; + $selfEnv['woundMax'] = $this->woundMax; + + if(!($this->raiseType & static::TYPE_ITEM)){ + return; + } + + $self->activateSkill('아이템사용'); + $item = $self->getGeneral()->getItem(); + $itemName = $item->getName(); + $self->activateSkill($itemName); + + if (!($this->raiseType & static::TYPE_CONSUMABLE_ITEM)) { + return; + } + + $self->activateSkill('아이템소모'); + $josaUl = JosaUtil::pick($itemName, '을'); + $self->getLogger()->pushGeneralActionLog("{$itemName}{$josaUl} 사용!", ActionLogger::PLAIN); + $self->general->deleteItem(); + } +} \ No newline at end of file