diff --git a/hwe/sammo/ActionItem/che_계략_삼략.php b/hwe/sammo/ActionItem/che_계략_삼략.php index 8cfa8dc5..75618f52 100644 --- a/hwe/sammo/ActionItem/che_계략_삼략.php +++ b/hwe/sammo/ActionItem/che_계략_삼략.php @@ -1,5 +1,5 @@ object; - $isAttacker = $self->isAttacker(); - $oppose = $isAttacker?$defender:$attacker; - if($env === null){ $env = []; } @@ -36,16 +26,66 @@ abstract class BaseWarUnitTrigger extends ObjectTrigger{ $env['e_defender'] = []; } + if($env['stopNextAction']??false){ + return $env; + } + + /** @var WarUnitGeneral $attacker */ + /** @var WarUnit $defender */ + [$attacker, $defender] = $arg; + + /** @var WarUnit $self */ + $self = $this->object; + $isAttacker = $self->isAttacker(); + $oppose = $isAttacker?$defender:$attacker; + $selfEnv = $isAttacker?$env['e_attacker']:$env['e_defender']; $opposeEnv = $isAttacker?$env['e_defender']:$env['e_attacker']; - $this->actionWar($self, $oppose, $selfEnv, $opposeEnv); + $callNextAction = $this->actionWar($self, $oppose, $selfEnv, $opposeEnv); $env['e_attacker'] = $isAttacker?$selfEnv:$opposeEnv; $env['e_defender'] = $isAttacker?$opposeEnv:$selfEnv; + if($callNextAction){ + $env['stopNextAction'] = true; + } + return $env; } abstract protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):void; + + public function processConsumableItem():bool{ + if(!($this->raiseType & static::TYPE_ITEM)){ + return false; + } + + /** @var WarUnit $self */ + $self = $this->object; + + if($self->hasActivatedSkill('아이템사용')){ + return false; + } + + $self->activateSkill('아이템사용'); + $item = $self->getGeneral()->getItem(); + $itemName = $item->getName(); + $self->activateSkill($itemName); + + if (!($this->raiseType & static::TYPE_CONSUMABLE_ITEM)) { + return false; + } + + if($self->hasActivatedSkill('아이템소모')){ + return false; + } + + $self->activateSkill('아이템소모'); + $josaUl = JosaUtil::pick($itemName, '을'); + $self->getLogger()->pushGeneralActionLog("{$itemName}{$josaUl} 사용!", ActionLogger::PLAIN); + $self->general->deleteItem(); + + return true; + } } diff --git a/hwe/sammo/WarInitTrigger/che_저격시도.php b/hwe/sammo/WarInitTrigger/che_저격시도.php deleted file mode 100644 index c2638da4..00000000 --- a/hwe/sammo/WarInitTrigger/che_저격시도.php +++ /dev/null @@ -1,57 +0,0 @@ -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 diff --git a/hwe/sammo/WarUnitGeneral.php b/hwe/sammo/WarUnitGeneral.php index 011a9ea7..fca51213 100644 --- a/hwe/sammo/WarUnitGeneral.php +++ b/hwe/sammo/WarUnitGeneral.php @@ -90,6 +90,7 @@ class WarUnitGeneral extends WarUnit{ $general = $this->general; $criticalRatio = $this->getCrewType()->getCriticalRatio($general); + /** @var float $criticalRatio */ $criticalRatio = $general->onCalcStat($general, 'warCriticalRatio', $criticalRatio, ['isAttacker'=>$this->isAttacker]); return $criticalRatio; } @@ -100,6 +101,7 @@ class WarUnitGeneral extends WarUnit{ $avoidRatio = $this->getCrewType()->avoid / 100; $avoidRatio *= $this->getComputedTrain() / 100; + /** @var float $avoidRatio */ $avoidRatio = $general->onCalcStat($general, 'warAvoidRatio', $avoidRatio, ['isAttacker'=>$this->isAttacker]); if($this->getOppose()->getCrewType()->armType == GameUnitConst::T_FOOTMAN){ diff --git a/hwe/sammo/WarInitTrigger/che_저격발동.php b/hwe/sammo/WarUnitTrigger/che_저격발동.php similarity index 75% rename from hwe/sammo/WarInitTrigger/che_저격발동.php rename to hwe/sammo/WarUnitTrigger/che_저격발동.php index 1953de25..8695b6d5 100644 --- a/hwe/sammo/WarInitTrigger/che_저격발동.php +++ b/hwe/sammo/WarUnitTrigger/che_저격발동.php @@ -1,22 +1,23 @@ hasActivatedSkill('저격')){ - return; + return true; } - if($selfEnv['저격발동']){ - return; + if($selfEnv['저격발동']??false){ + return true; } $selfEnv['저격발동'] = true; @@ -28,5 +29,9 @@ class che_저격발동 extends BaseWarUnitTrigger{ $self->getLogger()->pushGeneralBattleDetailLog("상대에게 저격당했다!", ActionLogger::PLAIN); $general->increaseVarWithLimit('injury', Util::randRangeInt($opposeEnv['woundMin'], $opposeEnv['woundMax']), null, 80); + + $this->processConsumableItem(); + + return true; } } \ No newline at end of file diff --git a/hwe/sammo/WarUnitTrigger/che_저격시도.php b/hwe/sammo/WarUnitTrigger/che_저격시도.php new file mode 100644 index 00000000..a9474cbf --- /dev/null +++ b/hwe/sammo/WarUnitTrigger/che_저격시도.php @@ -0,0 +1,45 @@ +object = $unit; + $this->raiseType = $raiseType; + $this->ratio = $ratio; + $this->woundMin = $woundMin; + $this->woundMax = $woundMax; + } + + protected function actionWar(WarUnit $self, WarUnit $oppose, array &$selfEnv, array &$opposeEnv):bool{ + assert($self instanceof WarUnitGeneral, 'General만 발동 가능'); + if(!$oppose instanceof WarUnitGeneral){ + return true; + } + if($self->hasActivatedSkill('저격')){ + return true; + } + if($self->hasActivatedSkill('저격불가')){ + return true; + } + if(!Util::randBool($this->ratio)){ + return true; + } + + $this->activateSkill('저격'); + $selfEnv['woundMin'] = $this->woundMin; + $selfEnv['woundMax'] = $this->woundMax; + + return true; + } +} \ No newline at end of file diff --git a/hwe/sammo/WarUnitTrigger/che_전투치료발동.php b/hwe/sammo/WarUnitTrigger/che_전투치료발동.php new file mode 100644 index 00000000..afd77138 --- /dev/null +++ b/hwe/sammo/WarUnitTrigger/che_전투치료발동.php @@ -0,0 +1,33 @@ +hasActivatedSkill('치료')){ + return true; + } + + if($selfEnv['치료발동']??false){ + return true; + } + $selfEnv['치료발동'] = true; + + $oppose->getLogger()->pushGeneralBattleDetailLog("상대가 치료했다!", ActionLogger::PLAIN); + $self->getLogger()->pushGeneralBattleDetailLog("치료했다!", ActionLogger::PLAIN); + + $oppose->getGeneral()->multiplyWarPowerMultiply(1/1.5); + + $this->processConsumableItem(); + + return true; + } +} \ No newline at end of file diff --git a/hwe/sammo/WarUnitTrigger/che_전투치료시도.php b/hwe/sammo/WarUnitTrigger/che_전투치료시도.php new file mode 100644 index 00000000..81a83f70 --- /dev/null +++ b/hwe/sammo/WarUnitTrigger/che_전투치료시도.php @@ -0,0 +1,30 @@ +hasActivatedSkill('치료')){ + return true; + } + if($self->hasActivatedSkill('치료불가')){ + return true; + } + if(!Util::randBool(1/5)){ + return true; + } + + $this->activateSkill('치료'); + + + return true; + } +} \ No newline at end of file