From d8cc820572a6889dfa6a57ab7afb381bac5555d7 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Tue, 21 Aug 2018 01:22:18 +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=202=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/func_command.php | 2 +- hwe/process_war.php | 20 +++++++------------- hwe/sammo/ActionLogger.php | 4 ++-- hwe/sammo/WarUnit.php | 9 +++++---- hwe/sammo/WarUnitCity.php | 7 ++++++- hwe/sammo/WarUnitGeneral.php | 9 +++++++-- 6 files changed, 28 insertions(+), 23 deletions(-) diff --git a/hwe/func_command.php b/hwe/func_command.php index b176c2f1..cc581f99 100644 --- a/hwe/func_command.php +++ b/hwe/func_command.php @@ -533,7 +533,7 @@ function processCommand($no) { } //장수정보 재로드 - $query = "select npc,no,name,picture,imgsvr,nation,nations,city,troop,injury,affinity,leader,leader2,power,power2,intel,intel2,experience,dedication,level,gold,rice,crew,crewtype,train,atmos,weap,book,horse,item,turntime,makenation,makelimit,killturn,block,dedlevel,explevel,age,belong,personal,special,special2,term,turn0,dex0,dex10,dex20,dex30,dex40 from general where no='$no'"; + $query = "select npc,no,name,picture,imgsvr,nation,nations,city,troop,injury,affinity,leader,leader2,power,power2,intel,intel2,experience,dedication,level,gold,rice,crew,crewtype,train,atmos,weap,book,horse,item,turntime,makenation,makelimit,killturn,block,dedlevel,explevel,age,belong,personal,special,special2,term,turn0,dex0,dex10,dex20,dex30,dex40,warnum,killnum,deathnum,killcrew,deathcrew,recwar from general where no='$no'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $general = MYDB_fetch_array($result); } diff --git a/hwe/process_war.php b/hwe/process_war.php index 04ae3ad2..fe171731 100644 --- a/hwe/process_war.php +++ b/hwe/process_war.php @@ -186,11 +186,7 @@ function processWar_NG( $logger->pushGlobalActionLog("{$attacker->getNationVar('name')}{$attacker->getName()}{$josaYi} {$city->getName()}{$josaRo} 진격합니다."); $logger->pushGeneralActionLog("{$city->getName()}{$josaRo} 진격합니다. <1>$date"); - $battleBegin = false; - for($currPhase = 0; $currPhase < $attacker->getMaxPhase(); $currPhase+=1){ - $battleBegin = true; - if($defender === null){ $defender = $city; @@ -346,7 +342,6 @@ function processWar_NG( } if(!$defender->continueWar($noRice)){ - $battleBegin = false; $attacker->logBattleResult(); $defender->logBattleResult(); @@ -376,22 +371,23 @@ function processWar_NG( $defender->getLogger()->pushGeneralActionLog("전멸했습니다.", ActionLogger::PLAIN); } + if($currPhase + 1 == $attacker->getMaxPhase()){ + break; + } + $defender->finishBattle(); $defender = ($getNextDefender)($defender, true); if($defender !== null && !($defender instanceof WarUnitGeneral)){ throw new \RuntimeException('다음 수비자를 받아오는데 실패'); - } + } + } } $attacker->finishBattle(); - - if(!$battleBegin){ - // 마지막 페이즈까지 갔지만, '갱신된 수비자'와 전투하지 않았다. - return false; - } + $defender->finishBattle(); if($currPhase == $attacker->getMaxPhase()){ //마지막 페이즈의 전투 마무리 @@ -402,8 +398,6 @@ function processWar_NG( $defender->logBattleResult(); } - $defender->finishBattle(); - if($defender instanceof WarUnitCity){ $newConflict = $defender->addConflict(); if($newConflict){ diff --git a/hwe/sammo/ActionLogger.php b/hwe/sammo/ActionLogger.php index 98fed4fa..2ce7f2aa 100644 --- a/hwe/sammo/ActionLogger.php +++ b/hwe/sammo/ActionLogger.php @@ -69,12 +69,12 @@ class ActionLogger{ } if($this->generalBattleResultLog){ - pushGenLog(['no'=>$this->generalId], $this->generalBattleResultLog); + pushBatRes(['no'=>$this->generalId], $this->generalBattleResultLog); $this->generalBattleResultLog = []; } if($this->generalBattleDetailLog){ - pushGenLog(['no'=>$this->generalId], $this->generalBattleDetailLog); + pushBatLog(['no'=>$this->generalId], $this->generalBattleDetailLog); $this->generalBattleDetailLog = []; } diff --git a/hwe/sammo/WarUnit.php b/hwe/sammo/WarUnit.php index 7a14291c..c95d3aee 100644 --- a/hwe/sammo/WarUnit.php +++ b/hwe/sammo/WarUnit.php @@ -26,6 +26,7 @@ class WarUnit{ protected $warPowerMultiply = 1.0; protected $activatedSkill = []; + protected $isFinished = false; private function __construct(){ } @@ -72,10 +73,10 @@ class WarUnit{ function increaseVarWithLimit(string $key, $value, $min = null, $max = null){ $targetValue = $this->raw[$key] + $value; if($min !== null && $targetValue < $min){ - $value = $min; + $targetValue = $min; } if($max !== null && $targetValue > $max){ - $value = $max; + $targetValue = $max; } $this->updateVar($key, $targetValue); } @@ -92,10 +93,10 @@ class WarUnit{ function multiplyVarWithLimit(string $key, $value, $min = null, $max = null){ $targetValue = $this->raw[$key] * $value; if($min !== null && $targetValue < $min){ - $value = $min; + $targetValue = $min; } if($max !== null && $targetValue > $max){ - $value = $max; + $targetValue = $max; } $this->updateVar($key, $targetValue); } diff --git a/hwe/sammo/WarUnitCity.php b/hwe/sammo/WarUnitCity.php index da04b1a0..b64e3587 100644 --- a/hwe/sammo/WarUnitCity.php +++ b/hwe/sammo/WarUnitCity.php @@ -85,7 +85,12 @@ class WarUnitCity extends WarUnit{ } function finishBattle(){ - $this->updateVar('def', Util::round($this->hp / 10)); + if($this->isFinished){ + return; + } + $this->isFinished = true; + + $this->updateVar('def', Util::round($this->getHP() / 10)); $this->updateVar('wall', Util::round($this->getVar('wall'))); //NOTE: 전투로 인한 사망자는 여기서 처리하지 않음 diff --git a/hwe/sammo/WarUnitGeneral.php b/hwe/sammo/WarUnitGeneral.php index 7d08d30a..1f26d259 100644 --- a/hwe/sammo/WarUnitGeneral.php +++ b/hwe/sammo/WarUnitGeneral.php @@ -556,7 +556,7 @@ class WarUnitGeneral extends WarUnit{ //계략 if($crewType->magicCoef){ - $magicRatio = getGeneralIntel($general, true, true, true, false) / 100; + $magicRatio = getGeneralIntel($this->raw, true, true, true, false) / 100; $magicRatio *= $crewType->magicCoef; if($specialWar == 41){ @@ -931,7 +931,12 @@ class WarUnitGeneral extends WarUnit{ return $result; } - function finishBattle(){ + function finishBattle(){ + if($this->isFinished){ + return; + } + $this->isFinished = true; + $this->increaseVar('killcrew', $this->killed); $this->increaseVar('deathcrew', $this->dead);