diff --git a/hwe/func_process.php b/hwe/func_process.php index cf41db1e..0046e360 100644 --- a/hwe/func_process.php +++ b/hwe/func_process.php @@ -369,17 +369,26 @@ function process_3(&$general) { $exp = CharExperience($exp, $general['personal']); $ded = CharDedication($ded, $general['personal']); - // 부드러운 기술 제한 - if(TechLimit($admin['startyear'], $admin['year'], $nation['tech'])) { $score = intdiv($score, 4); } - //장수수 구함 - $query = "select no from general where nation='{$general['nation']}'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $gencount = MYDB_num_rows($result); - if($gencount < GameConst::$initialNationGenLimit) $gencount = GameConst::$initialNationGenLimit; + $gencount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i', $general['nation']); + $gencnt_eff = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc != 5', $general['nation']); + if ($gencnt_eff < GameConst::$initialNationGenLimit) { + $gencount = GameConst::$initialNationGenLimit; + $gencnt_eff = GameConst::$initialNationGenLimit; + } + + if($gencount != $gencnt_eff){ + $score *= $gencount / $gencnt_eff; + } + + // 부드러운 기술 제한 + if(TechLimit($admin['startyear'], $admin['year'], $nation['tech'])) { $score /= 4; } + // 내정 상승 - $query = "update nation set totaltech=totaltech+'$score',tech=totaltech/'$gencount' where nation='{$general['nation']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $db->update('nation', [ + 'totaltech'=>$db->sqleval('totaltech + %i', Util::round($score)), + 'tech'=>$db->sqleval('totaltech / %i', $gencount) + ], 'nation=%i', $general['nation']); // 자금 하락, 경험치 상승 // 공헌도, 명성 상승 = $score * 10 $general['gold'] -= $admin['develcost']; diff --git a/hwe/process_war.php b/hwe/process_war.php index c5951491..9ebb7705 100644 --- a/hwe/process_war.php +++ b/hwe/process_war.php @@ -111,6 +111,30 @@ function processWar(array $rawAttacker, array $rawDefenderCity){ $attackerIncTech = $attacker->getDead() * 0.01 * getNationTechMultiplier($rawAttackerNation['type']); $defenderIncTech = $attacker->getKilled() * 0.01 * getNationTechMultiplier($rawDefenderNation['type']); + $attackerGenCnt = $rawAttackerNation['gennum']; + $defenderGenCnt = $rawDefenderNation['gennum']; + $attackerGenCnt_eff = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc != 5', $rawAttackerNation['nation']); + $defenderGenCnt_eff = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc != 5', $rawDefenderNation['nation']); + + if($attackerGenCnt_eff < GameConst::$initialNationGenLimit){ + $attackerGenCnt = GameConst::$initialNationGenLimit; + $attackerGenCnt_eff = GameConst::$initialNationGenLimit; + } + + if($defenderGenCnt_eff < GameConst::$initialNationGenLimit){ + $defenderGenCnt = GameConst::$initialNationGenLimit; + $defenderGenCnt_eff = GameConst::$initialNationGenLimit; + } + + if($attackerGenCnt != $attackerGenCnt_eff){ + $attackerIncTech *= $attackerGenCnt / $attackerGenCnt_eff; + } + + if($defenderGenCnt != $defenderGenCnt_eff){ + $defenderIncTech *= $defenderGenCnt / $defenderGenCnt_eff; + } + + if(TechLimit($startYear, $year, $rawAttackerNation['tech'])){ $attackerIncTech /= 4; } @@ -124,8 +148,8 @@ function processWar(array $rawAttacker, array $rawDefenderCity){ $updateAttackerNation['totaltech'] = Util::round($attackerTotalTech); $updateDefenderNation['totaltech'] = Util::round($defenderTotalTech); - $updateAttackerNation['tech'] = Util::round($attackerTotalTech / max(GameConst::$initialNationGenLimit, $rawAttackerNation['gennum'])); - $updateDefenderNation['tech'] = Util::round($defenderTotalTech / max(GameConst::$initialNationGenLimit, $rawDefenderNation['gennum'])); + $updateAttackerNation['tech'] = Util::round($attackerTotalTech / $attackerGenCnt); + $updateDefenderNation['tech'] = Util::round($defenderTotalTech / $defenderGenCnt); $db->update('nation', $updateAttackerNation, 'nation=%i', $attackerNationID); $db->update('nation', $updateDefenderNation, 'nation=%i', $defenderNationID);