diff --git a/twe/j_install.php b/twe/j_install.php index 3749d8eb..3e4bc3eb 100644 --- a/twe/j_install.php +++ b/twe/j_install.php @@ -60,6 +60,7 @@ $mysqli_obj = $db->get(); $scenarioObj = new Scenario($scenario); +$startyear = $scenarioObj->getYear(); if($mysqli_obj->multi_query(file_get_contents(__dir__.'/sql/reset.sql'))){ while (@$mysqli_obj->next_result()) {;} @@ -74,21 +75,11 @@ $db->insert('plock', [ 'plock'=>1 ]); -foreach(RootDB::db()->query('SELECT `no`, `name`, `picture`, `imgsvr` FROM member WHERE grade >= 5') as $admin){ - $db->insert('general', [ - 'owner'=>$admin['no'], - 'name'=>$admin['name'], - 'picture'=>$admin['picture'], - 'imgsvr'=>$admin['imgsvr'], - 'turntime'=>$turntime, - 'killturn'=>null - ]); -} - CityConst::build(); + $turntime = date('Y-m-d H:i:s'); $time = substr($turntime, 11, 2); if($sync == 0) { @@ -111,6 +102,8 @@ $killturn = 4800 / $turnterm; if($npcmode == 1) { $killturn = floor($killturn / 3); } $env = [ + 'scenario'=>$scenario, + 'startyear'=>$startyear, 'year'=> $year, 'month'=> $month, 'msg'=>'공지사항',//TODO:공지사항 @@ -125,17 +118,26 @@ $env = [ 'turnterm'=>$turnterm, 'killturn'=>$killturn, 'genius'=>5, - 'startyear'=>$startyear, - 'scenario'=>$scenario, 'show_img_level'=>$show_img_level, 'npcmode'=>$npcmode, - 'extend'=>$extend, + 'extended_general'=>$extend, 'fiction'=>$fiction ]; +foreach(RootDB::db()->query('SELECT `no`, `name`, `picture`, `imgsvr` FROM member WHERE grade >= 5') as $admin){ + $db->insert('general', [ + 'owner'=>$admin['no'], + 'name'=>$admin['name'], + 'picture'=>$admin['picture'], + 'imgsvr'=>$admin['imgsvr'], + 'turntime'=>$turntime, + 'killturn'=>null + ]); +} + $db->insert('game', $env); -$scenario->build($env); +$scenarioObj->build($env); $db->update('plock', [ 'plock'=>0 diff --git a/twe/js/install.js b/twe/js/install.js index 33b7a6c8..b13a34d2 100644 --- a/twe/js/install.js +++ b/twe/js/install.js @@ -159,13 +159,13 @@ function formSetup(){ deferred.reject('fail'); } else{ - alert('DB.php가 생성되었습니다.'); + alert('게임이 리셋되었습니다.'); deferred.resolve(); } return deferred.promise(); }).then(function(){ - location.href = 'install.php'; + //location.href = 'install.php'; }); }); diff --git a/twe/sammo/CityConst.php b/twe/sammo/CityConst.php index 8451240f..b1df2a9c 100644 --- a/twe/sammo/CityConst.php +++ b/twe/sammo/CityConst.php @@ -161,7 +161,7 @@ class CityConst{ ]; private static function _generate(){ - if(static::$constID || static::$constName || static::$constCity || static::$constRegion){ + if(static::$constID || static::$constName || static::$constRegion){ return; } @@ -336,7 +336,7 @@ class CityConst{ 'wall2'=>$city->wall, 'region'=>$city->region ]); - }, static::$constID); + }, array_values(static::$constID)); DB::db()->insert('city', $queries); } diff --git a/twe/sammo/CityInitialDetail.php b/twe/sammo/CityInitialDetail.php index fd9df423..131cd87d 100644 --- a/twe/sammo/CityInitialDetail.php +++ b/twe/sammo/CityInitialDetail.php @@ -25,7 +25,7 @@ class CityInitialDetail{ int $defence, int $wall, int $region, - int $path + array $path ){ $this->id = $id; $this->name = $name; diff --git a/twe/sammo/Scenario.php b/twe/sammo/Scenario.php index 06e0f501..1e61039e 100644 --- a/twe/sammo/Scenario.php +++ b/twe/sammo/Scenario.php @@ -59,7 +59,7 @@ class Scenario{ ); } - $this->displomacy = Util::array_get($data['diplomacy'], []); + $this->diplomacy = Util::array_get($data['diplomacy'], []); $this->generals = array_map(function($rawGeneral){ @@ -132,14 +132,21 @@ class Scenario{ }, Util::array_get($data['generalEx'], [])); $this->initialEvents = array_map(function($rawEvent){ - return new \sammo\Event\EventHandler($rawEvent[0], array_slice($rawEvent, 1)); + $cond = $rawEvent[0]; + $action = array_slice($rawEvent, 1); + return new \sammo\Event\EventHandler($cond, $action); }, Util::array_get($data['initialEvents'], [])); $this->events = array_map(function($rawEvent){ - //event는 여기서 풀지 않는다. + //event는 여기서 풀지 않는다. 평가만 한다. + $cond = $rawEvent[0]; + $action = array_slice($rawEvent, 1); + + new \sammo\Event\EventHandler($cond, $action); + return [ - 'cond' => $rawEvent[0], - 'action' => array_slice($rawEvent, 1) + 'cond' => $cond, + 'action' => $action ]; }, Util::array_get($data['events'], [])); @@ -282,19 +289,19 @@ class Scenario{ $remainGenerals[$birth][] = array_merge(['RegNPC'], $rawGeneral); } - if($env['useExtentedGeneral']){ + if($env['extended_general']){ foreach($this->generalsEx as $general){ if($general->build($env)){ continue; } - } - $rawGeneral = $this->tmpGeneralQueue[$general->$name]; - $birth = $general->birth; - if(!key_exists($birth, $remainGenerals)){ - $remainGenerals[$birth] = []; + $rawGeneral = $this->tmpGeneralQueue[$general->$name]; + $birth = $general->birth; + if(!key_exists($birth, $remainGenerals)){ + $remainGenerals[$birth] = []; + } + $remainGenerals[$birth][] = array_merge(['RegNPC'], $rawGeneral); } - $remainGenerals[$birth][] = array_merge(['RegNPC'], $rawGeneral); } return $remainGenerals; } @@ -313,7 +320,7 @@ class Scenario{ } } - public function buildGame($env=[]){ + public function build($env=[]){ //NOTE: 초기화가 되어있다고 가정함. /* @@ -361,7 +368,11 @@ class Scenario{ ]; }, $this->events); - $db->insert('event', $this->events); + if(count($events) > 0){ + $db->insert('event', $events); + } + + pushHistory($this->history); diff --git a/twe/sammo/Scenario/Nation.php b/twe/sammo/Scenario/Nation.php index a2919e21..7cc8c0cf 100644 --- a/twe/sammo/Scenario/Nation.php +++ b/twe/sammo/Scenario/Nation.php @@ -108,7 +108,7 @@ class Nation{ public function postBuild($env=[]){ $npc_cnt = count($this->generals); - if($env['useExtentedGeneral']){ + if($env['extended_general']){ $npc_cnt += count($this->generalsEx); } diff --git a/twe/scenario/scenario_0.json b/twe/scenario/scenario_0.json index 9cb6dfbd..2691b49d 100644 --- a/twe/scenario/scenario_0.json +++ b/twe/scenario/scenario_0.json @@ -1,5 +1,6 @@ { "title":"【공백지】 공백지", + "startYear":180, "history":[ ] } \ No newline at end of file diff --git a/twe/sql/schema.sql b/twe/sql/schema.sql index 96db9b45..b7ed67e3 100644 --- a/twe/sql/schema.sql +++ b/twe/sql/schema.sql @@ -383,8 +383,8 @@ create table game ( starttime datetime, isUnited int(1) default 0, scenario int(2) default 0, - img int(1) default 0, - extend int(1) default 0, + show_img_level int(2) default 0, + extended_general int(1) default 0, fiction int(1) default 0, npcmode int(1) default 0, tnmt_auto int(2) default 0, tnmt_time datetime default '2100-01-01 00:00:00',