From ef64f180a2ec91efa3dcaf2eebe6b3bce5f78994 Mon Sep 17 00:00:00 2001 From: hide_d Date: Fri, 4 Oct 2019 11:39:08 +0900 Subject: [PATCH] =?UTF-8?q?season=20=EB=B0=98=EC=98=81=20=EC=95=88?= =?UTF-8?q?=EB=90=9C=EA=B2=83=20=EB=A7=88=EC=A0=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/a_hallOfFame.php | 45 ++++++++++++++++++++++++++------------- hwe/func.php | 1 + hwe/js/hallOfFame.js | 9 +++++--- hwe/sammo/ResetHelper.php | 20 +++++++++++++++-- hwe/sql/schema.sql | 4 +++- 5 files changed, 58 insertions(+), 21 deletions(-) diff --git a/hwe/a_hallOfFame.php b/hwe/a_hallOfFame.php index b0f8cb23..42f7bc13 100644 --- a/hwe/a_hallOfFame.php +++ b/hwe/a_hallOfFame.php @@ -5,26 +5,34 @@ include "lib.php"; include "func.php"; $session = Session::getInstance()->setReadOnly(); +$seasonIdx = Util::getReq('seasonIdx', 'int', UniqueConst::$seasonIdx); $scenarioIdx = Util::getReq('scenarioIdx', 'int', null); $db = DB::db(); increaseRefresh("명예의전당", 1); -$scenarioList= []; -foreach($db->query('SELECT scenario_name as name, count(scenario) as cnt, scenario from ng_games group by scenario order by scenario asc') as $scenarioInfo){ - $scenarioList[$scenarioInfo['scenario']] = $scenarioInfo; -} - - +$scenarioList = (function(){ + $db = DB::db(); + $scenarioList= []; + foreach($db->query('SELECT season, scenario_name as name, count(scenario) as cnt, scenario from ng_games group by season, scenario order by season desc, scenario asc') as $scenarioInfo){ + $seasonIdx = $scenarioInfo['season']; + $scenarioIdx = $scenarioInfo['scenario']; + if(!key_exists($seasonIdx, $scenarioList)){ + $scenarioList[$seasonIdx] = []; + } + $scenarioList[$seasonIdx][$scenarioIdx] = $scenarioInfo; + } + return $scenarioList; +})(); if($scenarioIdx !== null || key_exists($scenarioIdx, $scenarioList)){ - $searchScenarioName = $scenarioList[$scenarioIdx]['name']; - $searchFilter = $db->sqleval('scenario = %i', $scenarioIdx); + $searchScenarioName = $scenarioList[$seasonIdx][$scenarioIdx]['name']; + $searchFilter = $db->sqleval('season = %i AND scenario = %i', $seasonIdx, $scenarioIdx); } else{ $searchScenarioName = '* 모두 *'; - $searchFilter = $db->sqleval(true); + $searchFilter = $db->sqleval('season = %i', $seasonIdx); } ?> @@ -53,12 +61,19 @@ else{ 명 예 의 전 당
시나리오 검색 : diff --git a/hwe/func.php b/hwe/func.php index 440a7a10..2d79dda0 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1473,6 +1473,7 @@ function CheckHall($no) { $db->insertIgnore('ng_hall', [ 'server_id'=>UniqueConst::$serverID, + 'season'=>UniqueConst::$seasonIdx, 'scenario'=>$scenarioIdx, 'general_no'=>$no, 'type'=>$idx, diff --git a/hwe/js/hallOfFame.js b/hwe/js/hallOfFame.js index ad475cfd..9a2c165e 100644 --- a/hwe/js/hallOfFame.js +++ b/hwe/js/hallOfFame.js @@ -1,7 +1,10 @@ jQuery(function($){ $('#by_scenario').change(function(){ - var scenarioIdx = $(this).val(); - $.redirect('a_hallOfFame.php', {scenarioIdx:scenarioIdx}, 'get'); + var $this = $(this); + var scenarioIdx = $this.val(); + var seasonIdx = $(this).find('option:selected').data('season'); + + + $.redirect('a_hallOfFame.php', {scenarioIdx:scenarioIdx, seasonIdx:seasonIdx}, 'get'); }) - //$.redirect("processing.php",{ commandtype: commandtype, turn: turn}, 'post'); }); \ No newline at end of file diff --git a/hwe/sammo/ResetHelper.php b/hwe/sammo/ResetHelper.php index 48db1ab9..c0d78b24 100644 --- a/hwe/sammo/ResetHelper.php +++ b/hwe/sammo/ResetHelper.php @@ -81,11 +81,22 @@ class ResetHelper{ mkdir($servRoot.'/logs/'.$serverID, 0755); mkdir($servRoot.'/data/'.$serverID, 0755); + $seasonIdx = 1; + if($db->queryFirstField('SHOW TABLES LIKE %s', 'storage') !== null){ + $gameStor = KVStorage::getStorage($db, 'game_env'); + $nextSeasonIdx = $gameStor->next_season_idx; + if($nextSeasonIdx !== null){ + $seasonIdx = $nextSeasonIdx; + } + $gameStor->resetCache(); + } + $result = Util::generateFileUsingSimpleTemplate( $servRoot.'/d_setting/UniqueConst.orig.php', $servRoot.'/d_setting/UniqueConst.php',[ 'serverID'=>$serverID, 'serverName'=>AppConf::getList()[$prefix]->getKorName(), + 'seasonIdx'=>$seasonIdx ], true ); @@ -112,12 +123,15 @@ class ResetHelper{ } } - (KVStorage::getStorage($db, 'game_env'))->resetValues(); (KVStorage::getStorage($db, 'nation_env'))->resetValues(); + $gameStor = KVStorage::getStorage($db, 'game_env'); + $gameStor->resetValues(); + $gameStor->next_season_idx = $seasonIdx; return [ 'result'=>true, - 'serverID'=>$serverID + 'serverID'=>$serverID, + 'seasonIdx'=>$seasonIdx ]; } @@ -154,6 +168,7 @@ class ResetHelper{ } $serverID = $clearResult['serverID']; + $seasonIdx = $clearResult['seasonIdx']; $scenarioObj = new Scenario($scenario, false); $scenarioObj->buildConf(); @@ -275,6 +290,7 @@ class ResetHelper{ 'date'=>$turntime, 'winner_nation'=>null, 'map'=>$scenarioObj->getMapTheme(), + 'season'=>$seasonIdx, 'scenario'=>$scenario, 'scenario_name'=>$scenarioObj->getTitle(), 'env'=>Json::encode($env) diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index 0fd91ccb..dd6dcd0a 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -332,6 +332,7 @@ ENGINE=InnoDB; CREATE TABLE IF NOT EXISTS `ng_hall` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `server_id` CHAR(20) NOT NULL, + `season` INT(11) NOT NULL, `scenario` INT(11) NOT NULL, `general_no` INT(11) NOT NULL, `type` INT(11) NOT NULL, @@ -342,7 +343,7 @@ CREATE TABLE IF NOT EXISTS `ng_hall` ( UNIQUE INDEX `server_general` (`server_id`, `type`, `general_no`), UNIQUE INDEX `owner` (`owner`, `server_id`, `type`), INDEX `server_show` (`server_id`, `type`, `value`), - INDEX `scenario` (`scenario`, `type`, `value`) + INDEX `scenario` (`season`, `scenario`, `type`, `value`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPRESSED; @@ -357,6 +358,7 @@ CREATE TABLE IF NOT EXISTS `ng_games` ( `date` DATETIME NOT NULL, `winner_nation` INT(11) NULL DEFAULT NULL, `map` VARCHAR(50) NULL DEFAULT NULL, + `season` INT(11) NOT NULL, `scenario` INT(11) NOT NULL, `scenario_name` TEXT NOT NULL, `env` TEXT NOT NULL COMMENT 'json',