From e6791ee8ec06812bc116365b7656264ceec9eb58 Mon Sep 17 00:00:00 2001 From: hide_d Date: Wed, 22 Aug 2018 14:49:15 +0900 Subject: [PATCH] =?UTF-8?q?=ED=83=88=EC=B7=A8=20=EC=84=B1=EA=B3=B5?= =?UTF-8?q?=EC=8B=9C=20=EC=9D=BC=EB=B6=80=EB=8A=94=20=EC=9E=A5=EC=88=98?= =?UTF-8?q?=EA=B0=80=20=EC=86=8C=EC=9C=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func_process_sabotage.php | 64 +++++++++++++++++------------------ 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/hwe/func_process_sabotage.php b/hwe/func_process_sabotage.php index cf4bb722..d686e107 100644 --- a/hwe/func_process_sabotage.php +++ b/hwe/func_process_sabotage.php @@ -64,6 +64,32 @@ function calcSabotageAttackScore(string $statType, array $general, array $nation ]; } +function calcSabotageDefendScore(string $statType, array $generalList, array $city, array $nation):array{ + $maxGenScore = 0; + + foreach ($generalList as $general) { + setLeadershipBonus($general, $nation['level']); + + if ($statType === 'leader') { + $maxGenScore = max($maxGenScore, getGeneralLeadership($general, true, true, true)); + } elseif ($statType === 'power') { + $maxGenScore = max($maxGenScore, getGeneralPower($general, true, true, true)); + } elseif ($statType === 'intel') { + $maxGenScore = max($maxGenScore, getGeneralIntel($general, true, true, true)); + } else { + throw new MustNotBeReachedException(); + } + } + + $supplyScore = $city['supply'] ? 0.1 : 0; + + return [ + ($maxGenScore / GameConst::$sabotageProbCoefByStat), + $cityScore, + $supplyScore + ]; +} + function checkSabotageFailCondition($general, $srcCity, $destCity, $reqGold, $reqRice, $dipState):?string{ $srcNationID = $general['nation']; $destNationID = $destCity['nation']; @@ -98,36 +124,6 @@ function checkSabotageFailCondition($general, $srcCity, $destCity, $reqGold, $re return null; } -function calcSabotageDefendScore(string $statType, array $generalList, array $city, array $nation):array{ - $maxGenScore = 0; - - foreach($generalList as $general){ - setLeadershipBonus($general, $nation['level']); - - if($statType === 'leader'){ - $maxGenScore = max($maxGenScore, getGeneralLeadership($general, true, true, true)); - } - else if($statType === 'power'){ - $maxGenScore = max($maxGenScore, getGeneralPower($general, true, true, true)); - } - else if($statType === 'intel'){ - $maxGenScore = max($maxGenScore, getGeneralIntel($general, true, true, true)); - } - else{ - throw new MustNotBeReachedException(); - } - } - - $cityScore = $city['secu'] / $city['secu2'] / 5; - $supplyScore = $city['supply'] ? 0.1 : 0; - - return [ - ($maxGenScore / GameConst::$sabotageProbCoefByStat), - $city['secu'] / $city['secu2'] / 5, - $supplyScore - ]; -} - function process_32(&$general) { $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); @@ -394,12 +390,14 @@ function process_33(&$general) { ], 'city=%i', $destCityID); } - // 본국으로 회수, 재야이면 본인이 소유 + // 본국으로 일부 회수, 재야이면 본인이 전량 소유 if($general['nation'] != 0) { $db->update('nation', [ - 'gold' => $db->sqleval('gold + %i', $gold), - 'rice' => $db->sqleval('rice + %i', $rice) + 'gold' => $db->sqleval('gold + %i', Util::round($gold * 0.7)), + 'rice' => $db->sqleval('rice + %i', Util::round($rice * 0.7)) ], 'nation=%i', $srcNationID); + $general['gold'] += $gold - Util::round($gold * 0.7); + $general['rice'] += $rice - Util::round($rice * 0.7); } else { $general['gold'] += $gold; $general['rice'] += $rice;