시나리오마다 별도로 스탯 제한치를 설정 가능하도록 변경

This commit is contained in:
2018-05-21 05:10:44 +09:00
parent 2c3e577c4e
commit bf233f7552
16 changed files with 176 additions and 193 deletions
+35
View File
@@ -148,6 +148,24 @@ class Scenario{
}, Util::array_get($data['events'], []));
}
private function getGameConf(){
$defaultPath = self::SCENARIO_PATH."/default.json";
if(!file_exists($defaultPath)){
throw new \RuntimeException('기본 시나리오 설정 파일 없음!');
}
$default = Json::decode(file_get_contents($defaultPath));
$stat = [
'statTotal'=>$this->data['stat']['total']??$default['stat']['total'],
'statMin'=>$this->data['stat']['min']??$default['stat']['min'],
'statMax'=>$this->data['stat']['max']??$default['stat']['max'],
'statNPCMax'=>$this->data['stat']['npcMax']??$default['stat']['npcMax'],
'statChiefMin'=>$this->data['stat']['chiefMin']??$default['stat']['chiefMin'],
];
$this->gameConf = array_merge($stat);
}
public function __construct(int $scenarioIdx, bool $lazyInit = true){
$scenarioPath = self::SCENARIO_PATH."/scenario_{$scenarioIdx}.json";
@@ -157,6 +175,8 @@ class Scenario{
$data = Json::decode(file_get_contents($scenarioPath));
$this->data = $data;
$this->getGameConf();
$this->year = Util::array_get($data['startYear']);
$this->title = Util::array_get($data['title'] , '');
@@ -292,7 +312,19 @@ class Scenario{
}
}
public function buildConf(){
$path = __dir__.'/../d_setting';
Util::generateFileUsingSimpleTemplate(
$path.'/GameCustomConst.orig.php',
$path.'/GameCustomConst.php',
$this->gameConf,
true
);
}
public function build($env=[]){
$this->initFull();
//NOTE: 초기화가 되어있다고 가정함.
@@ -306,6 +338,9 @@ class Scenario{
event변수 : currentEventID
*/
$db = DB::db();
foreach($this->nations as $id=>$nation){