diff --git a/twe/sammo/Event/Action.php b/twe/sammo/Event/Action.php index 70a60a42..e1f20ad9 100644 --- a/twe/sammo/Event/Action.php +++ b/twe/sammo/Event/Action.php @@ -2,7 +2,7 @@ namespace sammo\Event; abstract class Action{ - public abstract function __construct($args=null); + //public abstract function __construct(...$args); public abstract function run($env=null); public static function build($actionArgs){ @@ -10,7 +10,7 @@ abstract class Action{ throw new \InvalidArgumentException('action을 입력해야 합니다.'); } - $className = ___NAMESPACE__.'\\Action\\'.$actionArgs[0]; + $className = __NAMESPACE__.'\\Action\\'.$actionArgs[0]; if(!class_exists($className)){ throw new \InvalidArgumentException('존재하지 않는 Action입니다 :'.$actionArgs[0]); } diff --git a/twe/sammo/Event/Action/ChangeCity.php b/twe/sammo/Event/Action/ChangeCity.php index 5e0230f6..1ff2f5dd 100644 --- a/twe/sammo/Event/Action/ChangeCity.php +++ b/twe/sammo/Event/Action/ChangeCity.php @@ -4,7 +4,7 @@ use sammo\Util; use sammo\DB; //기존 시나리오에서 개시 1월에 내정을 깎는 것을 모사. -class ChangeCity extends sammo\Event\Action{ +class ChangeCity extends \sammo\Event\Action{ const AVAILABLE_KEY = [ 'pop'=>true, 'agri'=>true, @@ -20,7 +20,7 @@ class ChangeCity extends sammo\Event\Action{ private $queries; private $targetType = 'all'; private $targetArgs = []; - public function __construct(array $target = null, array $actions){ + public function __construct($target = null, array $actions){ //values 포맷은 key, value로 @@ -54,7 +54,7 @@ class ChangeCity extends sammo\Event\Action{ continue; } - $queries[$key] = $this->genSQLGeneric($value); + $queries[$key] = $this->genSQLGeneric($key, $value); } $this->queries = $queries; diff --git a/twe/sammo/Event/Action/CreateAdminNPC.php b/twe/sammo/Event/Action/CreateAdminNPC.php index cf511809..176dce6a 100644 --- a/twe/sammo/Event/Action/CreateAdminNPC.php +++ b/twe/sammo/Event/Action/CreateAdminNPC.php @@ -2,7 +2,7 @@ namespace sammo\Event\Action; //기존 event_4.php -class CreateAdminNPC extends sammo\Event\Action{ +class CreateAdminNPC extends \sammo\Event\Action{ public function __construct(){ } diff --git a/twe/sammo/Event/Action/CreateManyNPC.php b/twe/sammo/Event/Action/CreateManyNPC.php index 1c029c49..45c535a2 100644 --- a/twe/sammo/Event/Action/CreateManyNPC.php +++ b/twe/sammo/Event/Action/CreateManyNPC.php @@ -2,7 +2,7 @@ namespace sammo\Event\Action; //기존 event_3.php -class CreateManyNPC extends sammo\Event\Action{ +class CreateManyNPC extends \sammo\Event\Action{ public function __construct($npcCount = 200){ } diff --git a/twe/sammo/Event/Action/RaiseInvader.php b/twe/sammo/Event/Action/RaiseInvader.php index 07cff25b..62154903 100644 --- a/twe/sammo/Event/Action/RaiseInvader.php +++ b/twe/sammo/Event/Action/RaiseInvader.php @@ -13,7 +13,7 @@ use sammo\DB; * event_2.php, 약한 이민족 : npcEachCount = -0.5, specAvg = 150, specDist = 20, tech = -1, dex = 0 * event_3.php, 엄청 약한 이민족 : npcEachCount = 100, specAvg = 50, specDist = 5, tech = 0, dex = 0 */ -class RaiseInvader extends sammo\Event\Action{ +class RaiseInvader extends \sammo\Event\Action{ private $npcEachCount; private $specAvg; private $specDist; diff --git a/twe/sammo/Event/EventHandler.php b/twe/sammo/Event/EventHandler.php index 2dc82619..3cc01a3e 100644 --- a/twe/sammo/Event/EventHandler.php +++ b/twe/sammo/Event/EventHandler.php @@ -8,7 +8,7 @@ class EventHandler{ public function __construct($rawCondition, $rawActions){ $this->condition = Condition::build($rawCondition); - foreach($rawActions as $rawActio){ + foreach($rawActions as $rawAction){ $this->condition = Action::build($rawAction); } diff --git a/twe/sammo/Scenario.php b/twe/sammo/Scenario.php index 4f1d194b..8c68b5f9 100644 --- a/twe/sammo/Scenario.php +++ b/twe/sammo/Scenario.php @@ -9,6 +9,9 @@ class Scenario{ private $data; + private $initialEvents; + private $events; + public function __construct(int $scenarioIdx){ $scenarioPath = self::SCENARIO_PATH."/scenario_{$scenarioIdx}.json"; @@ -16,6 +19,10 @@ class Scenario{ $this->scenarioPath = $scenarioPath; $this->data = Json::decode(file_get_contents($scenarioPath)); + + $this->initialEvents = array_map(function($rawEvent){ + return new \sammo\Event\EventHandler($rawEvent[0], array_slice($rawEvent, 1)); + }, Util::array_get($this->data['initialEvents'], [])); } public function getScenarioIdx(){