From 7199a770c0f85d07c71bc71f435eafd48dc40824 Mon Sep 17 00:00:00 2001 From: hide_d Date: Thu, 7 May 2020 23:38:26 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func.php | 26 ++++++++-------- hwe/func_gamerule.php | 43 +++++++++++++------------- hwe/join_post.php | 2 +- hwe/sammo/Command/General/che_해산.php | 4 +-- 4 files changed, 38 insertions(+), 37 deletions(-) diff --git a/hwe/func.php b/hwe/func.php index 66d7c9af..d8149441 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1635,8 +1635,8 @@ function deleteNation(General $lord, bool $applyDB):array $db = DB::db(); $nationStor = KVStorage::getStorage($db, $nationID, 'nation_env'); - $oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $nationID); - $nationName = $oldNation['name']; + $nation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $nationID); + $nationName = $nation['name']; $logger = $lord->getLogger(); @@ -1644,7 +1644,7 @@ function deleteNation(General $lord, bool $applyDB):array $logger->pushGlobalHistoryLog("【멸망】{$nationName}{$josaUn} 멸망했습니다."); - $oldNationGeneralList = General::createGeneralObjListFromDB( + $nationGeneralList = General::createGeneralObjListFromDB( $db->queryFirstColumn( 'SELECT `no` FROM general WHERE nation=%i AND no != %i', $nationID, @@ -1652,21 +1652,21 @@ function deleteNation(General $lord, bool $applyDB):array ), ['npc', 'gold', 'rice', 'experience', 'explevel', 'dedication', 'dedlevel', 'aux'], 1 ); - $oldNationGeneralList[$lordID] = $lord; + $nationGeneralList[$lordID] = $lord; - $oldNation['generals'] = array_keys($oldNationGeneralList); - $oldNation['aux'] = Json::decode($oldNation['aux']); - $oldNation['msg'] = $nationStor->notice; - $oldNation['scout_msg'] = $nationStor->scout_msg; - $oldNation['aux'] += $nationStor->max_power; - $oldNation['history'] = getNationHistoryAll($nationID); + $nation['generals'] = array_keys($nationGeneralList); + $nation['aux'] = Json::decode($nation['aux']); + $nation['msg'] = $nationStor->notice; + $nation['scout_msg'] = $nationStor->scout_msg; + $nation['aux'] += $nationStor->max_power; + $nation['history'] = getNationHistoryAll($nationID); $josaYi = JosaUtil::pick($nationName, '이'); $destroyLog = "{$nationName}{$josaYi} 멸망했습니다."; $destroyHistoryLog = "{$nationName}{$josaYi} 멸망"; // 전 장수 재야로 - foreach($oldNationGeneralList as $general){ + foreach($nationGeneralList as $general){ $general->setVar('belong', 0); $general->setVar('troop', 0); $general->setVar('officer_level', 0); @@ -1694,7 +1694,7 @@ function deleteNation(General $lord, bool $applyDB):array $db->insert('ng_old_nations', [ 'server_id' => UniqueConst::$serverID, 'nation' => $nationID, - 'data' => Json::encode($oldNation) + 'data' => Json::encode($nation) ]); $db->delete('nation', 'nation=%i', $nationID); $db->delete('nation_turn', 'nation_id=%i', $nationID); @@ -1706,7 +1706,7 @@ function deleteNation(General $lord, bool $applyDB):array $nationStor = KVStorage::getStorage($db, $nationID, 'nation_env'); $nationStor->resetValues(); - return $oldNationGeneralList; + return $nationGeneralList; } function nextRuler(General $general) diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index 2c3ee312..9c320596 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -942,14 +942,13 @@ function checkEmperior() return; } - $remainNationCnt = $db->queryFirstField('SELECT count(*) FROM nation WHERE level > 0'); + $remainNations = $db->queryFirstColumn('SELECT nation FROM nation WHERE level > 0 LIMIT 2'); - if ($remainNationCnt > 1) { + if (!$remainNations || count($remainNations) != 1) { return; } - $nation = $db->queryFirstRow('SELECT * FROM nation WHERE level > 0 LIMIT 1'); - $nationID = $nation['nation']; + $nationID = $remainNations[0]; $nationStor = KVStorage::getStorage($db, $nationID, 'nation_env'); @@ -964,10 +963,13 @@ function checkEmperior() checkStatistic(); - $josaYi = JosaUtil::pick($nation['name'], '이'); + $nation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $nationID); + $nationName = $nation['name']; + + $josaYi = JosaUtil::pick($nationName, '이'); $nationLogger = new ActionLogger(0, $nationID, $admin['year'], $admin['month']); - $nationLogger->pushNationalHistoryLog("{$nation['name']}{$josaYi} 전토를 통일"); + $nationLogger->pushNationalHistoryLog("{$nationName}{$josaYi} 전토를 통일"); $gameStor->isunited = 2; $gameStor->conlimit = $gameStor->conlimit * 100; @@ -983,20 +985,19 @@ function checkEmperior() $chiefs = Util::convertArrayToDict( $db->query( 'SELECT no,name,picture,belong,officer_level FROM general WHERE nation=%i AND officer_level >= 5', - $nation['nation'] + $nationID ), 'officer_level' ); - $oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $nation['nation']); - $oldNationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nation['nation']); - $oldNation['generals'] = $oldNationGenerals; + $nationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nationID); + $nation['generals'] = $nationGenerals; $tigers = $db->query( 'SELECT value, name FROM rank_data LEFT JOIN general ON rank_data.general_id = general.no WHERE rank_data.nation_id = %i AND rank_data.type = "warnum" AND value > 0 ORDER BY value DESC LIMIT 5', - $nation['nation'] + $nationID ); // 오호장군 $tigerstr = join(', ', array_map(function ($arr) { @@ -1008,7 +1009,7 @@ function checkEmperior() 'SELECT value, name FROM rank_data LEFT JOIN general ON rank_data.general_id = general.no WHERE rank_data.nation_id = %i AND rank_data.type = "firenum" AND value > 0 ORDER BY value DESC LIMIT 7', - $nation['nation'] + $nationID ); // 건안칠자 $eaglestr = join(', ', array_map(function ($arr) { @@ -1019,7 +1020,7 @@ function checkEmperior() $rawGeneralList = $db->query('SELECT no, name, npc, owner FROM general WHERE nation=%i ORDER BY dedication DESC', $nationID); foreach ($rawGeneralList as $rawGeneral) { $generalLogger = new ActionLogger($rawGeneral['no'], $nationID, $admin['year'], $admin['month']); - $generalLogger->pushGeneralActionLog("{$nation['name']}{$josaYi} 전토를 통일하였습니다.", ActionLogger::YEAR_MONTH); + $generalLogger->pushGeneralActionLog("{$nationName}{$josaYi} 전토를 통일하였습니다.", ActionLogger::YEAR_MONTH); $generalLogger->flush(); } @@ -1034,13 +1035,13 @@ function checkEmperior() $statNation = $db->queryFirstRow('SELECT nation_count,nation_name,nation_hist from statistic where nation_count=%i LIMIT 1', $stat['nc']); $statGeneral = $db->queryFirstRow('SELECT gen_count,personal_hist,special_hist,aux from statistic order by no desc LIMIT 1'); - $oldNation = $nation; - $oldNation['generals'] = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nation['nation']); - $oldNation['aux'] = Json::decode($oldNation['aux']); - $oldNation['msg'] = $nationStor->notice; - $oldNation['scout_msg'] = $nationStor->scout_msg; - $oldNation['aux'] += $nationStor->max_power; - $oldNation['history'] = getNationHistoryAll($nation['nation']); + $nation = $nation; + $nation['generals'] = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nation['nation']); + $nation['aux'] = Json::decode($nation['aux']); + $nation['msg'] = $nationStor->notice; + $nation['scout_msg'] = $nationStor->scout_msg; + $nation['aux'] += $nationStor->max_power; + $nation['history'] = getNationHistoryAll($nation['nation']); storeOldGenerals(0, $admin['year'], $admin['month']); storeOldGenerals($nation['nation'], $admin['year'], $admin['month']); @@ -1048,7 +1049,7 @@ function checkEmperior() $db->insert('ng_old_nations', [ 'server_id' => UniqueConst::$serverID, 'nation' => $nation['nation'], - 'data' => Json::encode($oldNation) + 'data' => Json::encode($nation) ]); $noNationGeneral = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=0'); diff --git a/hwe/join_post.php b/hwe/join_post.php index e0456fd8..4bebac50 100644 --- a/hwe/join_post.php +++ b/hwe/join_post.php @@ -4,7 +4,7 @@ namespace sammo; include "lib.php"; include "func.php"; -$v = new Validator($_POST + $_GET); +$v = new Validator($_POST); $v ->rule('required', [ 'name', diff --git a/hwe/sammo/Command/General/che_해산.php b/hwe/sammo/Command/General/che_해산.php index d074b39c..dd2de1cc 100644 --- a/hwe/sammo/Command/General/che_해산.php +++ b/hwe/sammo/Command/General/che_해산.php @@ -94,8 +94,8 @@ class che_해산 extends Command\GeneralCommand{ $logger->pushGeneralHistoryLog("{$nationName}{$josaUl} 해산"); $general->setResultTurn(new LastTurn(static::getName(), $this->arg)); - $oldNationGenerals = deleteNation($general, false); - foreach($oldNationGenerals as $oldGeneral){ + $nationGenerals = deleteNation($general, false); + foreach($nationGenerals as $oldGeneral){ $oldGeneral->setVar('makelimit', 12); $oldGeneral->applyDB($db); }