From 0ad8db5a63ace8c5554caaf01a6a5637dd314d26 Mon Sep 17 00:00:00 2001 From: hide_d Date: Tue, 27 Mar 2018 02:44:28 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A6=AC=EC=85=8B=20=EC=8B=9C=20=EC=8B=9C?= =?UTF-8?q?=EB=82=98=EB=A6=AC=EC=98=A4=20=EC=A0=95=EB=B3=B4=EB=A5=BC=20?= =?UTF-8?q?=EA=B0=84=EB=8B=A8=ED=9E=88=20=EB=B3=B4=EC=97=AC=EC=A3=BC?= =?UTF-8?q?=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- twe/install.php | 12 ++--- twe/j_load_scenarios.php | 14 +++-- twe/js/install.js | 77 ++++++++++++++++++++++++++- twe/sammo/Scenario.php | 99 +++++++++++++++++++++++++++++++++-- twe/scenario/scenario_0.json | 5 ++ twe/scenario/scenario_24.json | 2 +- 6 files changed, 191 insertions(+), 18 deletions(-) create mode 100644 twe/scenario/scenario_0.json diff --git a/twe/install.php b/twe/install.php index 7de3e56a..b9c41885 100644 --- a/twe/install.php +++ b/twe/install.php @@ -94,13 +94,7 @@ if(Session::getUserGrade(true) < 5){
-
@@ -183,9 +177,9 @@ if(Session::getUserGrade(true) < 5){ 설정값 - 일자180년 1월 + 시작 연도180년 NPC 수 - 국가 수 + 국가 diff --git a/twe/j_load_scenarios.php b/twe/j_load_scenarios.php index 836da0bd..1b937515 100644 --- a/twe/j_load_scenarios.php +++ b/twe/j_load_scenarios.php @@ -2,8 +2,8 @@ namespace sammo; require "lib.php"; - -if(Session::getUserGrade() < 5){ +$session = Session::Instance()->setReadOnly(); +if($session->userGrade < 5){ Json::die([ 'result'=>false, 'reason'=>'관리자가 아닙니다.' @@ -21,7 +21,13 @@ if ($scenarioIdx !== null) { ]); } + +$scenarios = []; +foreach(Scenario::getAllScenarios() as $scenario){ + $scenarios[$scenario->getScenarioIdx()] = $scenario->getScenarioBrief(); +} + Json::die([ - 'result'=>false, - 'reason'=>'NYI' + 'result'=>true, + 'scenario'=>$scenarios ]); \ No newline at end of file diff --git a/twe/js/install.js b/twe/js/install.js index fa092207..c192bb14 100644 --- a/twe/js/install.js +++ b/twe/js/install.js @@ -19,16 +19,91 @@ function loadScenarioPreview(scenarioIdx){ } */ + + function loadScenarios(){ $.ajax({ method:'post', url:'j_load_scenarios.php', dataType:'json' }).then(function(result){ + if(!result.result){ + var deferred = $.Deferred(); + deferred.reject('fail'); + return deferred.promise(); + } + + var list = {}; + + + $.each(result.scenario, function(idx, value){ + var title = value.title || "-"; + var titles = title.split(/【|[0-9]*】/); + var category = titles.length>2?titles[1]:'-'; + + value.title = title; + value.category = category; + value.idx = idx; + value.year = value.year || 180; + + if(!(category in list)){ + list[category] = {}; + } + + list[category][idx] = value; + }); + + var $select = $('#scenario_sel'); + $.each(list, function(category, items){ + var $optgroup = $('').attr('label', category); + + $.each(items, function(idx, scenario){ + var $option = $('