install.php에 1차적으로 ChangeCity를 물림

This commit is contained in:
2018-03-28 17:20:35 +09:00
parent c1976b5b7a
commit 9b139e54f4
7 changed files with 16 additions and 9 deletions
+2 -2
View File
@@ -2,7 +2,7 @@
namespace sammo\Event; namespace sammo\Event;
abstract class Action{ abstract class Action{
public abstract function __construct($args=null); //public abstract function __construct(...$args);
public abstract function run($env=null); public abstract function run($env=null);
public static function build($actionArgs){ public static function build($actionArgs){
@@ -10,7 +10,7 @@ abstract class Action{
throw new \InvalidArgumentException('action을 입력해야 합니다.'); throw new \InvalidArgumentException('action을 입력해야 합니다.');
} }
$className = ___NAMESPACE__.'\\Action\\'.$actionArgs[0]; $className = __NAMESPACE__.'\\Action\\'.$actionArgs[0];
if(!class_exists($className)){ if(!class_exists($className)){
throw new \InvalidArgumentException('존재하지 않는 Action입니다 :'.$actionArgs[0]); throw new \InvalidArgumentException('존재하지 않는 Action입니다 :'.$actionArgs[0]);
} }
+3 -3
View File
@@ -4,7 +4,7 @@ use sammo\Util;
use sammo\DB; use sammo\DB;
//기존 시나리오에서 개시 1월에 내정을 깎는 것을 모사. //기존 시나리오에서 개시 1월에 내정을 깎는 것을 모사.
class ChangeCity extends sammo\Event\Action{ class ChangeCity extends \sammo\Event\Action{
const AVAILABLE_KEY = [ const AVAILABLE_KEY = [
'pop'=>true, 'pop'=>true,
'agri'=>true, 'agri'=>true,
@@ -20,7 +20,7 @@ class ChangeCity extends sammo\Event\Action{
private $queries; private $queries;
private $targetType = 'all'; private $targetType = 'all';
private $targetArgs = []; private $targetArgs = [];
public function __construct(array $target = null, array $actions){ public function __construct($target = null, array $actions){
//values 포맷은 key, value로 //values 포맷은 key, value로
@@ -54,7 +54,7 @@ class ChangeCity extends sammo\Event\Action{
continue; continue;
} }
$queries[$key] = $this->genSQLGeneric($value); $queries[$key] = $this->genSQLGeneric($key, $value);
} }
$this->queries = $queries; $this->queries = $queries;
+1 -1
View File
@@ -2,7 +2,7 @@
namespace sammo\Event\Action; namespace sammo\Event\Action;
//기존 event_4.php //기존 event_4.php
class CreateAdminNPC extends sammo\Event\Action{ class CreateAdminNPC extends \sammo\Event\Action{
public function __construct(){ public function __construct(){
} }
+1 -1
View File
@@ -2,7 +2,7 @@
namespace sammo\Event\Action; namespace sammo\Event\Action;
//기존 event_3.php //기존 event_3.php
class CreateManyNPC extends sammo\Event\Action{ class CreateManyNPC extends \sammo\Event\Action{
public function __construct($npcCount = 200){ public function __construct($npcCount = 200){
} }
+1 -1
View File
@@ -13,7 +13,7 @@ use sammo\DB;
* event_2.php, 약한 이민족 : npcEachCount = -0.5, specAvg = 150, specDist = 20, tech = -1, dex = 0 * 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 * 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 $npcEachCount;
private $specAvg; private $specAvg;
private $specDist; private $specDist;
+1 -1
View File
@@ -8,7 +8,7 @@ class EventHandler{
public function __construct($rawCondition, $rawActions){ public function __construct($rawCondition, $rawActions){
$this->condition = Condition::build($rawCondition); $this->condition = Condition::build($rawCondition);
foreach($rawActions as $rawActio){ foreach($rawActions as $rawAction){
$this->condition = Action::build($rawAction); $this->condition = Action::build($rawAction);
} }
+7
View File
@@ -9,6 +9,9 @@ class Scenario{
private $data; private $data;
private $initialEvents;
private $events;
public function __construct(int $scenarioIdx){ public function __construct(int $scenarioIdx){
$scenarioPath = self::SCENARIO_PATH."/scenario_{$scenarioIdx}.json"; $scenarioPath = self::SCENARIO_PATH."/scenario_{$scenarioIdx}.json";
@@ -16,6 +19,10 @@ class Scenario{
$this->scenarioPath = $scenarioPath; $this->scenarioPath = $scenarioPath;
$this->data = Json::decode(file_get_contents($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(){ public function getScenarioIdx(){