diff --git a/hwe/sammo/Scenario.php b/hwe/sammo/Scenario.php index 18872702..8f1e28fc 100644 --- a/hwe/sammo/Scenario.php +++ b/hwe/sammo/Scenario.php @@ -19,7 +19,7 @@ class Scenario{ private $title; private $history; - + /** @var \sammo\Scenario\Nation[] */ private $nations; /** @var \sammo\Scenario\Nation[] */ @@ -52,7 +52,7 @@ class Scenario{ } list( - $affinity, $name, $picturePath, $nationName, $locatedCity, + $affinity, $name, $picturePath, $nationName, $locatedCity, $leadership, $strength, $intel, $officerLevel, $birth, $death, $ego, $char, $text ) = $rawGeneral; @@ -70,9 +70,9 @@ class Scenario{ $this->tmpGeneralQueue[$name] = $rawGeneral; $obj = (new Scenario\GeneralBuilder( - $name, + $name, false, - $picturePath, + $picturePath, $nationID )); if(!$initFull){ @@ -110,22 +110,22 @@ class Scenario{ $this->nations = []; $this->nations[0] = $neutralNation; $this->nationsInv = [$neutralNation->getName() => $neutralNation]; - + foreach (Util::array_get($data['nation'],[]) as $idx=>$rawNation) { list($name, $color, $gold, $rice, $infoText, $tech, $type, $nationLevel, $cities) = $rawNation; $nationID = $idx+1; - + $nation = new Scenario\Nation( - $nationID, - $name, - $color, - $gold, - $rice, - $infoText, - $tech, - $type, - $nationLevel, + $nationID, + $name, + $color, + $gold, + $rice, + $infoText, + $tech, + $type, + $nationLevel, $cities ); $this->nations[$nationID] = $nation; @@ -134,7 +134,7 @@ class Scenario{ $this->diplomacy = Util::array_get($data['diplomacy'], []); - + $this->generals = array_map(function($rawGeneral){ return $this->generateGeneral($rawGeneral, false, 2); }, Util::array_get($data['general'], [])); @@ -166,22 +166,22 @@ class Scenario{ $this->nations = []; $this->nations[0] = $neutralNation; $this->nationsInv = [$neutralNation->getName() => $neutralNation]; - + foreach (Util::array_get($data['nation'],[]) as $idx=>$rawNation) { list($name, $color, $gold, $rice, $infoText, $tech, $type, $nationLevel, $cities) = $rawNation; $nationID = $idx+1; - + $nation = new Scenario\Nation( - $nationID, - $name, - $color, - $gold, - $rice, - $infoText, - $tech, - $type, - $nationLevel, + $nationID, + $name, + $color, + $gold, + $rice, + $infoText, + $tech, + $type, + $nationLevel, $cities ); $this->nations[$nationID] = $nation; @@ -190,7 +190,7 @@ class Scenario{ $this->diplomacy = Util::array_get($data['diplomacy'], []); - + $this->generals = array_map(function($rawGeneral){ return $this->generateGeneral($rawGeneral, true, 2); }, Util::array_get($data['general'], [])); @@ -211,12 +211,22 @@ class Scenario{ $this->events = array_map(function($rawEvent){ //event는 여기서 풀지 않는다. 평가만 한다. - $cond = $rawEvent[0]; - $action = array_slice($rawEvent, 1); - + $target = $rawEvent[0]; + if(is_string($target)){ + throw new \RuntimeException("{$target}이 문자열이 아님"); + } + $priority = $rawEvent[1]; + if(is_int($priority)){ + throw new \RuntimeException("{$priority}가 정수가 아님"); + } + $cond = $rawEvent[2]; + $action = array_slice($rawEvent, 3); + new \sammo\Event\EventHandler($cond, $action); - + return [ + 'target' => $target, + 'priority' => $priority, 'cond' => $cond, 'action' => $action ]; @@ -310,7 +320,7 @@ class Scenario{ $this->initLite(); return $this->nations; } - + public function getMapTheme(){ return $this->gameConf['mapName']; } @@ -377,7 +387,7 @@ class Scenario{ private function buildGenerals($env){ $this->initFull(); - + try{ $text = \file_get_contents(ServConfig::getSharedIconPath('../hook/list.json?1')); $storedIcons = Json::decode($text); @@ -398,7 +408,7 @@ class Scenario{ } $rawGeneral = $this->tmpGeneralQueue[$general->getGeneralRawName()]; - $birth = $general->getBirthYear(); + $birth = $general->getBirthYear(); if(!key_exists($birth, $remainGenerals)){ $remainGenerals[$birth] = []; } @@ -432,13 +442,13 @@ class Scenario{ } $rawGeneral = $this->tmpGeneralQueue[$general->getGeneralRawName()]; - $birth = $general->getBirthYear(); + $birth = $general->getBirthYear(); if(!key_exists($birth, $remainGenerals)){ $remainGenerals[$birth] = []; } $remainGenerals[$birth][] = array_merge(['RegNeutralNPC'], $rawGeneral); } - + return $remainGenerals; } @@ -508,7 +518,7 @@ class Scenario{ $nation->build($env); } - + refreshNationStaticInfo(); CityHelper::flushCache(); @@ -519,6 +529,8 @@ class Scenario{ $actions[] = ['DeleteEvent']; $this->events[] = [ + 'target'=>'Month', + 'priority'=>1000, 'cond'=>['Date', '>=', $targetYear, '1'], 'action'=>$actions ]; @@ -540,6 +552,8 @@ class Scenario{ $events = array_map(function($rawEvent){ return [ + 'target'=>$rawEvent['target'], + 'priority'=>$rawEvent['priority'], 'condition'=>Json::encode($rawEvent['cond']), 'action'=>Json::encode($rawEvent['action']) ]; @@ -549,7 +563,7 @@ class Scenario{ $db->insert('event', $events); } - + pushGlobalHistoryLog($this->history, $env['year'], $env['month']); @@ -568,7 +582,7 @@ class Scenario{ foreach(glob(self::SCENARIO_PATH.'/scenario_*.json') as $scenarioPath){ $scenarioName = pathinfo(basename($scenarioPath), PATHINFO_FILENAME); $scenarioIdx = Util::array_last(explode('_', $scenarioName)); - + if(!is_numeric($scenarioIdx)){ continue; } diff --git a/hwe/scenario/scenario_0.json b/hwe/scenario/scenario_0.json index b47e808a..b32f4dc2 100644 --- a/hwe/scenario/scenario_0.json +++ b/hwe/scenario/scenario_0.json @@ -8,11 +8,13 @@ }, "events":[ [ + "month", 1000, ["or", ["Date", "==", null, 12], ["Date", "==", null, 6]], ["CreateManyNPC", 10, 10], ["DeleteEvent"] ], [ + "month", 1000, ["Date", "==", 181, 1], ["RaiseNPCNation"], ["DeleteEvent"] diff --git a/hwe/scenario/scenario_1.json b/hwe/scenario/scenario_1.json index b609f4c6..b54183d7 100644 --- a/hwe/scenario/scenario_1.json +++ b/hwe/scenario/scenario_1.json @@ -11,11 +11,13 @@ }, "events":[ [ + "month", 1000, ["or", ["Date", "==", null, 12], ["Date", "==", null, 6]], ["CreateManyNPC", 10, 10], ["DeleteEvent"] ], [ + "month", 1000, ["Date", "==", 181, 1], ["RaiseNPCNation"], ["DeleteEvent"] diff --git a/hwe/scenario/scenario_1010.json b/hwe/scenario/scenario_1010.json index 1a39d070..7162d196 100644 --- a/hwe/scenario/scenario_1010.json +++ b/hwe/scenario/scenario_1010.json @@ -12,7 +12,7 @@ ]], ["황건적", "#FFD700", 10000, 10000, "황건적", 500, "태평도", 2, [ "업","계교","진류","관도","정도","평원","복양","패","허창","초" - ]] + ]] ], "diplomacy":[ ], @@ -703,7 +703,7 @@ ], "history":[ "●184년 1월:【역사모드1】황건적의 난", - "●184년 1월:【황건적】전국 각지에서 황건적이 들고 일어서고 있습니다." + "●184년 1월:【황건적】전국 각지에서 황건적이 들고 일어서고 있습니다." ], "initialEvents":[ [ diff --git a/hwe/scenario/scenario_1020.json b/hwe/scenario/scenario_1020.json index d6ce37d6..5cdab1e2 100644 --- a/hwe/scenario/scenario_1020.json +++ b/hwe/scenario/scenario_1020.json @@ -20,7 +20,7 @@ "진류" ]], ["유언", "#483D8B", 10000, 10000, "익주 주자사 유언", 1000, "유가", 3, [ - "성도", "면죽", "자동", "강주" + "성도", "면죽", "자동", "강주" ]], ["원술", "#FFC0CB", 10000, 10000, "4세 5공 명문 혈통 원소의 사촌 원술", 1000, "병가", 2, [ "완" @@ -67,7 +67,7 @@ ["공주", "#800080", 10000, 10000, "공주", 1000, "도가", 3, [ "초" ]] - + ], "diplomacy":[ [1, 2, 1, 36], diff --git a/hwe/scenario/scenario_1070.json b/hwe/scenario/scenario_1070.json index d4aff9e3..5b84996f 100644 --- a/hwe/scenario/scenario_1070.json +++ b/hwe/scenario/scenario_1070.json @@ -8,8 +8,8 @@ }, "nation":[ ["조조", "#000080", 10000, 10000, "하북을 제패하고 대군을 이끌고 남하하는 조조", 1000, "병가", 6, [ - "허창", "역경", "계교", "관도", "호관", "정도", "호로", "사곡", "함곡", "사수", "서주", "계", - "북평", "진양", "남피", "평원", "하내", "업", "북해", "복양", "장안", "홍농", "낙양", "진류", + "허창", "역경", "계교", "관도", "호관", "정도", "호로", "사곡", "함곡", "사수", "서주", "계", + "북평", "진양", "남피", "평원", "하내", "업", "북해", "복양", "장안", "홍농", "낙양", "진류", "패", "초", "하비", "완", "여남", "수춘", "신야", "양양", "강릉", "장판" ]], ["손권", "#FF0000", 10000, 10000, "조조의 남하에 유비와 불가침으로 맞서는 손권", 1000, "덕가", 4, [ diff --git a/hwe/scenario/scenario_2.json b/hwe/scenario/scenario_2.json index 12f63c82..0b577eb9 100644 --- a/hwe/scenario/scenario_2.json +++ b/hwe/scenario/scenario_2.json @@ -15,11 +15,13 @@ }, "events":[ [ + "month", 1000, ["or", ["Date", "==", null, 12], ["Date", "==", null, 6]], ["CreateManyNPC", 10, 10], ["DeleteEvent"] ], [ + "month", 1000, ["Date", "==", 181, 1], ["RaiseNPCNation"], ["DeleteEvent"] diff --git a/hwe/scenario/scenario_2300.json b/hwe/scenario/scenario_2300.json index 0aac9133..05f52f65 100644 --- a/hwe/scenario/scenario_2300.json +++ b/hwe/scenario/scenario_2300.json @@ -99,11 +99,13 @@ ], "events":[ [ + "month", 1000, ["or", ["Date", "==", null, 12], ["Date", "==", null, 6]], ["CreateManyNPC", 10, 10], ["DeleteEvent"] ], [ + "month", 1000, ["Date", "==", 181, 1], ["RaiseNPCNation"], ["DeleteEvent"] diff --git a/hwe/scenario/scenario_902.json b/hwe/scenario/scenario_902.json index 987283e5..0ca1b5e0 100644 --- a/hwe/scenario/scenario_902.json +++ b/hwe/scenario/scenario_902.json @@ -59,11 +59,13 @@ }, "events":[ [ + "month", 1000, ["Date", "==", null, 12], ["CreateManyNPC", 10, 10], ["DeleteEvent"] ], [ + "month", 1000, ["Date", "==", 182, 1], ["ChangeCity", "occupied", { "trade":100 @@ -71,6 +73,7 @@ ["DeleteEvent"] ], [ + "month", 1000, ["Date", "==", 182, 7], ["ChangeCity", "occupied", { "trade":100 diff --git a/hwe/scenario/scenario_903.json b/hwe/scenario/scenario_903.json index f99a15af..ab39c555 100644 --- a/hwe/scenario/scenario_903.json +++ b/hwe/scenario/scenario_903.json @@ -11,11 +11,13 @@ ], "events": [ [ + "month", 1000, ["Date", "==", null, 12], ["CreateManyNPC", 100, 0], ["DeleteEvent"] ], [ + "month", 1000, ["Date", "==", 181, 12], ["ChangeCity", "occupied", { "pop": "+60000",