From 6e25a6e262820964ff6509c46724574eae701c9d Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sun, 12 Mar 2023 02:48:59 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B0=9C=EB=B3=84=20=EC=8B=9C=EB=82=98?= =?UTF-8?q?=EB=A6=AC=EC=98=A4=EC=97=90=EC=84=9C=20=EA=B8=B0=EB=B3=B8=20?= =?UTF-8?q?=EC=9D=B4=EB=B2=A4=ED=8A=B8=EB=A5=BC=20=EB=AC=B4=EC=8B=9C?= =?UTF-8?q?=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Scenario.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/hwe/sammo/Scenario.php b/hwe/sammo/Scenario.php index 9123b6a6..364e3ee2 100644 --- a/hwe/sammo/Scenario.php +++ b/hwe/sammo/Scenario.php @@ -41,6 +41,8 @@ class Scenario{ private $initialEvents; private $events; + private $ignoreDefaultEvents; + private $initBasic = false; private $initOK = false; @@ -208,11 +210,22 @@ class Scenario{ return $this->generateGeneral($rawGeneral, true, 6); }, Util::array_get($data['general_neutral'], [])); + + if($this->ignoreDefaultEvents){ + $rawInitialEvents = Util::array_get($data['initialEvents'], []); + $rawEvents = Util::array_get($data['events'], []); + } + else{ + $rawInitialEvents = array_merge(GameConst::$defaultInitialEvents, Util::array_get($data['initialEvents'], [])); + $rawEvents = array_merge(GameConst::$defaultEvents, Util::array_get($data['events'], [])); + } + $this->initialEvents = array_map(function($rawEvent){ $cond = $rawEvent[0]; $action = array_slice($rawEvent, 1); return new \sammo\Event\EventHandler($cond, $action); - }, array_merge(GameConst::$defaultInitialEvents, Util::array_get($data['initialEvents'], []))); + }, $rawInitialEvents); + $this->events = array_map(function($rawEvent){ //event는 여기서 풀지 않는다. 평가만 한다. @@ -235,7 +248,7 @@ class Scenario{ 'cond' => $cond, 'action' => $action ]; - }, array_merge(GameConst::$defaultEvents, Util::array_get($data['events'], []))); + }, $rawEvents); } public function getGameConf(){ @@ -277,13 +290,14 @@ class Scenario{ $data = Json::decode(file_get_contents($scenarioPath)); $this->data = $data; + $this->ignoreDefaultEvents = $data['ignoreDefaultEvents'] ?? false; $this->getGameConf(); - $this->year = Util::array_get($data['startYear']); - $this->title = Util::array_get($data['title'] , ''); + $this->year = $data['startYear'] ?? null; + $this->title = $data['title'] ?? ''; - $this->history = Util::array_get($data['history'], []); + $this->history = $data['history'] ?? []; if(!$lazyInit){ $this->initFull();