From 81b7ebbab6b8c95037cb6937b229a68c3e72c54a Mon Sep 17 00:00:00 2001 From: Hide_D Date: Tue, 21 Aug 2018 02:01:56 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A0=84=ED=88=AC=20=EC=97=94=EC=A7=84=20?= =?UTF-8?q?=EB=B2=84=EA=B7=B8=203=EC=B0=A8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/process_war.php | 15 ++++++++++----- hwe/sammo/ActionLogger.php | 4 ++-- hwe/sammo/WarUnit.php | 12 ++++++++++++ hwe/sammo/WarUnitCity.php | 4 +++- hwe/sammo/WarUnitGeneral.php | 10 +++++----- 5 files changed, 32 insertions(+), 13 deletions(-) diff --git a/hwe/process_war.php b/hwe/process_war.php index fe171731..077d7f72 100644 --- a/hwe/process_war.php +++ b/hwe/process_war.php @@ -37,15 +37,20 @@ function processWar(array $rawAttacker, array $rawDefenderCity){ $city = new WarUnitCity($rawDefenderCity, $rawAttackerNation, $year, $month, $cityRate); - $defenderList = $db->query('SELECT no,name,turntime,personal,special2,crew,crewtype,atmos,train,intel,intel2,book,power,power2,weap,injury,leader,leader2,horse,item,explevel,level,rice,dex0,dex10,dex20,dex30,dex40,warnum,killnum,deathnum,killcrew,deathcrew,recwar FROM general WHERE city=%i AND nation=%i AND nation!=0 and crew > 0 and rice>(crew/100) and ((train>=60 and atmos>=60 and mode=1) or (train>=80 and atmos>=80 and mode=2))', $city->getVar('nation'), $city->getVar('city')); + $defenderList = $db->query('SELECT no,name,nation,turntime,personal,special2,crew,crewtype,atmos,train,intel,intel2,book,power,power2,weap,injury,leader,leader2,horse,item,explevel,level,rice,dex0,dex10,dex20,dex30,dex40,warnum,killnum,deathnum,killcrew,deathcrew,recwar FROM general WHERE nation=%i AND city=%i AND nation!=0 and crew > 0 and rice>(crew/100) and ((train>=60 and atmos>=60 and mode=1) or (train>=80 and atmos>=80 and mode=2))', $city->getVar('nation'), $city->getVar('city')); + + if(!$defenderList){ + $defenderList = []; + } usort($defenderList, function($lhs, $rhs){ return -(extractBattleOrder($lhs) <=> extractBattleOrder($rhs)); }); $iterDefender = new \ArrayIterator($defenderList); + $iterDefender->rewind(); - $getNextDefender = function(?WarUnit $prevDefender, bool $reqNext) use ($iterDefender, $db) { + $getNextDefender = function(?WarUnit $prevDefender, bool $reqNext) use ($iterDefender, $rawDefenderCity, $rawDefenderNation, $year, $month, $db) { if($prevDefender !== null){ $prevDefender->applyDB($db); } @@ -58,7 +63,7 @@ function processWar(array $rawAttacker, array $rawDefenderCity){ return null; } - $retVal = $iterDefender->current(); + $retVal = new WarUnitGeneral($iterDefender->current(), $rawDefenderCity, $rawDefenderNation, false, $year, $month); $iterDefender->next(); return $retVal; }; @@ -278,8 +283,8 @@ function processWar_NG( $defenderHP = $defender->getHP(); if($deadAttacker > $attackerHP || $deadDefender > $defenderHP){ - $deadAttackerRatio = $deadAttacker / $attackerHP; - $deadDefenderRatio = $deadDefender / $defenderHP; + $deadAttackerRatio = $deadAttacker / max(1, $attackerHP); + $deadDefenderRatio = $deadDefender / max(1, $defenderHP); if($deadDefenderRatio > $deadAttackerRatio){ //수비자가 더 병력 부족 diff --git a/hwe/sammo/ActionLogger.php b/hwe/sammo/ActionLogger.php index 2ce7f2aa..abc33dd5 100644 --- a/hwe/sammo/ActionLogger.php +++ b/hwe/sammo/ActionLogger.php @@ -257,14 +257,14 @@ class ActionLogger{ 'crewtype' => $me->getCrewTypeShortName(), 'name' => $me->getName(), 'remain_crew' => $me->getHP(), - 'killed_crew' => $me->getDead() + 'killed_crew' => -$me->getDeadCurrentBattle() ]; $render_oppose = [ 'crewtype' => $oppose->getCrewTypeShortName(), 'name' => $oppose->getName(), 'remain_crew' => $oppose->getHP(), - 'killed_crew' => $oppose->getDead() + 'killed_crew' => -$oppose->getDeadCurrentBattle() ]; if(!$me->isAttacker()){ diff --git a/hwe/sammo/WarUnit.php b/hwe/sammo/WarUnit.php index c95d3aee..5e9f78cf 100644 --- a/hwe/sammo/WarUnit.php +++ b/hwe/sammo/WarUnit.php @@ -8,7 +8,9 @@ class WarUnit{ protected $logger; protected $crewType; + protected $killedCurr = 0; protected $killed = 0; + protected $deadCurr = 0; protected $dead = 0; protected $isAttacker = false; @@ -145,6 +147,14 @@ class WarUnit{ return $this->dead; } + function getKilledCurrentBattle():int{ + return $this->killedCurr; + } + + function getDeadCurrentBattle():int{ + return $this->deadCurr; + } + function getSpecialDomestic():int{ return 0; } @@ -171,6 +181,8 @@ class WarUnit{ function setOppose(?WarUnit $oppose){ $this->oppose = $oppose; + $this->killedCurr = 0; + $this->deadCurr = 0; $this->activatedSkill = []; } diff --git a/hwe/sammo/WarUnitCity.php b/hwe/sammo/WarUnitCity.php index b64e3587..db0004eb 100644 --- a/hwe/sammo/WarUnitCity.php +++ b/hwe/sammo/WarUnitCity.php @@ -43,6 +43,7 @@ class WarUnitCity extends WarUnit{ function increaseKilled(int $damage):int{ $this->killed += $damage; + $this->killedCurr += $damage; return $this->killed; } @@ -61,6 +62,7 @@ class WarUnitCity extends WarUnit{ function decreaseHP(int $damage):int{ $damage = min($damage, $this->hp); $this->dead += $damage; + $this->deadCurr += $damage; $this->hp -= $damage; $this->increaseVarWithLimit('wall', -$damage/20, 0); @@ -89,7 +91,7 @@ class WarUnitCity extends WarUnit{ return; } $this->isFinished = true; - + $this->updateVar('def', Util::round($this->getHP() / 10)); $this->updateVar('wall', Util::round($this->getVar('wall'))); diff --git a/hwe/sammo/WarUnitGeneral.php b/hwe/sammo/WarUnitGeneral.php index 1f26d259..13a00d81 100644 --- a/hwe/sammo/WarUnitGeneral.php +++ b/hwe/sammo/WarUnitGeneral.php @@ -58,7 +58,7 @@ class WarUnitGeneral extends WarUnit{ } function setOppose(?WarUnit $oppose){ - $this->oppose = $oppose; + parent::setOppose($oppose); $this->increaseVar('warnum', 1); if($this->isAttacker){ @@ -67,8 +67,6 @@ class WarUnitGeneral extends WarUnit{ else if($oppose !== null){ $this->updateVar('recwar', $oppose->getVar('turntime')); } - - $this->activatedSkill = []; } function getSpecialWar():int{ @@ -361,7 +359,7 @@ class WarUnitGeneral extends WarUnit{ if ( $specialWar == 70 && $this->oppose instanceof WarUnitGeneral && - !$this->hasActivateSkill('저격') && + !$this->hasActivatedSkill('저격') && Util::randBool(1/3) ) { $this->activateSkill('저격'); @@ -386,7 +384,7 @@ class WarUnitGeneral extends WarUnit{ if( $item == 2 && $this->oppose instanceof WarUnitGeneral && - !$this->hasActivateSkill('저격') && + !$this->hasActivatedSkill('저격') && Util::randBool(1/5) ){ $itemActivated = true; @@ -455,6 +453,7 @@ class WarUnitGeneral extends WarUnit{ $damage = min($damage, $this->getVar('crew')); $this->dead += $damage; + $this->deadCurr += $damage; $this->increaseVar('crew', -$damage); $addDex = $damage; @@ -487,6 +486,7 @@ class WarUnitGeneral extends WarUnit{ $this->addDex($this->getCrewType(), $addDex); $this->killed += $damage; + $this->killedCurr += $damage; return $this->killed; }