diff --git a/hwe/_admin5_submit.php b/hwe/_admin5_submit.php index 4a3c60c9..8a4a56ba 100644 --- a/hwe/_admin5_submit.php +++ b/hwe/_admin5_submit.php @@ -23,6 +23,7 @@ $connect=$db->get(); switch($btn) { case "국가변경": + $oldNation = $db->queryFirstField('SELECT nation FROM general WHERE owner=%i', $userID); if($nation == 0) { $db->update('general', [ 'nation'=>0, @@ -33,6 +34,14 @@ switch($btn) { 'nation'=>$nation, 'level'=>1, ], 'owner=%i', $userID); + $db->update('nation', [ + 'gennum'=>$db->sqleval('gennum + 1') + ], 'nation=%i', $oldNation); + } + if($oldNation != 0){ + $db->update('nation', [ + 'gennum'=>$db->sqleval('gennum - 1') + ], 'nation=%i', $oldNation); } break; } diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index 247ee04a..157c5596 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -501,7 +501,7 @@ function postUpdateMonthly() { // 명성,공헌 $nations = $db->query('SELECT A.nation, - A.gennum, A.gennum2, A.aux, + A.gennum, A.aux, round(( round(((A.gold+A.rice)+(select sum(gold+rice) from general where nation=A.nation))/100) +A.tech @@ -536,7 +536,6 @@ function postUpdateMonthly() { $db->update('nation', [ 'power'=>$nation['power'], - 'gennum2'=>$nation['gennum'], 'aux'=>Json::encode($aux) ], 'nation=%i', $nation['nation']); } diff --git a/hwe/func_process_chief.php b/hwe/func_process_chief.php index 4a0acc74..1a278cf0 100644 --- a/hwe/func_process_chief.php +++ b/hwe/func_process_chief.php @@ -1976,10 +1976,8 @@ function process_76(&$general) { pushGeneralHistory($general, "●{$admin['year']}년 {$admin['month']}월:의병모집을 발동"); pushNationHistory($nation, "●{$admin['year']}년 {$admin['month']}월:{$general['name']}{$josaYi} 의병모집을 발동"); - $query = "select avg(gennum) as gennum from nation"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $avgNation = MYDB_fetch_array($result); - $gencount = 5 + Util::round($avgNation['gennum'] / 10); + $avgGenNum = $db->queryFirstField('SELECT avg(gennum) FROM nation'); + $addGenCount = 5 + Util::round($avgGenNum / 10); $query = "select avg(age) as age, max(leader+power+intel) as lpi, avg(dedication) as ded,avg(experience) as exp, avg(dex0) as dex0, avg(dex10) as dex10, avg(dex20) as dex20, avg(dex30) as dex30, avg(dex40) as dex40 from general where nation='{$general['nation']}'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); @@ -1988,7 +1986,7 @@ function process_76(&$general) { //의병추가 $npc = 4; $npcid = $admin['npccount']; - for($i=0; $i < $gencount; $i++) { + for($i=0; $i < $addGenCount; $i++) { // 무장 40%, 지장 40%, 무지장 20% $type = rand() % 10; switch($type) { @@ -2089,13 +2087,6 @@ function process_76(&$general) { //npccount $gameStor->npccount=$npcid; - //국가 기술력 그대로 - $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); - $gennum = $gencount; - if($gencount < GameConst::$initialNationGenLimit) $gencount = GameConst::$initialNationGenLimit; - // 국가보정 if($nation['type'] == 11) { $term3 = Util::round($term3 / 2); } if($nation['type'] == 12) { $term3 = $term3 * 2; } @@ -2103,7 +2094,7 @@ function process_76(&$general) { //전략기한 $db->update('nation', [ 'sabotagelimit'=>$term3, - 'gennum'=>$gennum + 'gennum'=>$db->sqleval('gennum + %i', $addGenCount), ], 'nation=%i', $general['nation']); //경험치, 공헌치 diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index 475d9285..102d6fe6 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -176,7 +176,6 @@ CREATE TABLE `nation` ( `capital` INT(1) NULL DEFAULT '0', `capset` INT(1) NULL DEFAULT '0', `gennum` INT(3) NULL DEFAULT '1', - `gennum2` INT(3) NULL DEFAULT '1', `gold` INT(8) NULL DEFAULT '0', `rice` INT(8) NULL DEFAULT '0', `bill` INT(3) NULL DEFAULT '0',