전역 하드코드 이벤트를 동적 변경 영역으로 이동 (#230)
기존에 작성해두었던 EventHandler 시스템으로 하드코드 이벤트 이동 - 매달 - 보급선 설정 - 전쟁 단기 수입 설정 - 부대장 부여 - 1월 - 유산 포인트 계산 - 도시 인구 변화 - 수입 - 관직 제한 해제 - 재난 - 상인 - 새해 알림 - 특기 부여 - 4월 - 관직 제한 해제 - 재난 - 7월 - 유산 포인트 계산 - 도시 인구 변화 - 수입 - 관직 제한 해제 - 재난 - 상인 - 10월 - 관직 제한 해제 - 재난 - 천통 시 - 유산 포인트 계산 Reviewed-on: https://storage.hided.net/gitea/devsam/core/pulls/230
This commit was merged in pull request #230.
This commit is contained in:
+19
-5
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user