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

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
+1 -7
View File
@@ -1,7 +1,7 @@
<?php
namespace sammo;
class GameConst
class GameConst extends GameCustomConst
{
/** @var string 버전 */
public static $title = "삼국지 모의전투 PHP HiDCHe";
@@ -45,12 +45,6 @@ class GameConst
public static $sabotageDefaultAmount = 100;
/** @var int 계략시 수치 감소량($firingbase ~ $firingpower)*/
public static $sabotageAmountCoef = 400;
/** @var int 명장,지장에 사용될 통솔 제한*/
public static $goodgenleader = 65;
/** @var int 명장에 사용될 무력 제한*/
public static $goodgenpower = 65;
/** @var int 지장에 사용될 지력 제한*/
public static $goodgenintel = 65;
/** @var string 기본 배경색깔 푸른색*/
public static $basecolor = "#000044";
/** @var string 기본 배경색깔 초록색*/
+4 -1
View File
@@ -127,8 +127,9 @@ class ResetHelper{
}
$scenarioObj = new Scenario($scenario, false);
$startyear = $scenarioObj->getYear()??GameConst::$defaultStartYear;
$scenarioObj->buildConf();
$startyear = $scenarioObj->getYear()??GameConst::$defaultStartYear;
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
@@ -160,6 +161,8 @@ class ResetHelper{
$killturn = 4800 / $turnterm;
if($npcmode == 1) { $killturn = intdiv($killturn, 3); }
$env = [
'scenario'=>$scenario,
'scenario_text'=>$scenarioObj->getTitle(),
+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){