feat: 시나리오 event 포맷에서 target, priority 추가
This commit is contained in:
+54
-40
@@ -19,7 +19,7 @@ class Scenario{
|
||||
private $title;
|
||||
|
||||
private $history;
|
||||
|
||||
|
||||
/** @var \sammo\Scenario\Nation[] */
|
||||
private $nations;
|
||||
/** @var \sammo\Scenario\Nation[] */
|
||||
@@ -52,7 +52,7 @@ class Scenario{
|
||||
}
|
||||
|
||||
list(
|
||||
$affinity, $name, $picturePath, $nationName, $locatedCity,
|
||||
$affinity, $name, $picturePath, $nationName, $locatedCity,
|
||||
$leadership, $strength, $intel, $officerLevel, $birth, $death, $ego,
|
||||
$char, $text
|
||||
) = $rawGeneral;
|
||||
@@ -70,9 +70,9 @@ class Scenario{
|
||||
$this->tmpGeneralQueue[$name] = $rawGeneral;
|
||||
|
||||
$obj = (new Scenario\GeneralBuilder(
|
||||
$name,
|
||||
$name,
|
||||
false,
|
||||
$picturePath,
|
||||
$picturePath,
|
||||
$nationID
|
||||
));
|
||||
if(!$initFull){
|
||||
@@ -110,22 +110,22 @@ class Scenario{
|
||||
$this->nations = [];
|
||||
$this->nations[0] = $neutralNation;
|
||||
$this->nationsInv = [$neutralNation->getName() => $neutralNation];
|
||||
|
||||
|
||||
foreach (Util::array_get($data['nation'],[]) as $idx=>$rawNation) {
|
||||
list($name, $color, $gold, $rice, $infoText, $tech, $type, $nationLevel, $cities) = $rawNation;
|
||||
$nationID = $idx+1;
|
||||
|
||||
|
||||
|
||||
$nation = new Scenario\Nation(
|
||||
$nationID,
|
||||
$name,
|
||||
$color,
|
||||
$gold,
|
||||
$rice,
|
||||
$infoText,
|
||||
$tech,
|
||||
$type,
|
||||
$nationLevel,
|
||||
$nationID,
|
||||
$name,
|
||||
$color,
|
||||
$gold,
|
||||
$rice,
|
||||
$infoText,
|
||||
$tech,
|
||||
$type,
|
||||
$nationLevel,
|
||||
$cities
|
||||
);
|
||||
$this->nations[$nationID] = $nation;
|
||||
@@ -134,7 +134,7 @@ class Scenario{
|
||||
|
||||
$this->diplomacy = Util::array_get($data['diplomacy'], []);
|
||||
|
||||
|
||||
|
||||
$this->generals = array_map(function($rawGeneral){
|
||||
return $this->generateGeneral($rawGeneral, false, 2);
|
||||
}, Util::array_get($data['general'], []));
|
||||
@@ -166,22 +166,22 @@ class Scenario{
|
||||
$this->nations = [];
|
||||
$this->nations[0] = $neutralNation;
|
||||
$this->nationsInv = [$neutralNation->getName() => $neutralNation];
|
||||
|
||||
|
||||
foreach (Util::array_get($data['nation'],[]) as $idx=>$rawNation) {
|
||||
list($name, $color, $gold, $rice, $infoText, $tech, $type, $nationLevel, $cities) = $rawNation;
|
||||
$nationID = $idx+1;
|
||||
|
||||
|
||||
|
||||
$nation = new Scenario\Nation(
|
||||
$nationID,
|
||||
$name,
|
||||
$color,
|
||||
$gold,
|
||||
$rice,
|
||||
$infoText,
|
||||
$tech,
|
||||
$type,
|
||||
$nationLevel,
|
||||
$nationID,
|
||||
$name,
|
||||
$color,
|
||||
$gold,
|
||||
$rice,
|
||||
$infoText,
|
||||
$tech,
|
||||
$type,
|
||||
$nationLevel,
|
||||
$cities
|
||||
);
|
||||
$this->nations[$nationID] = $nation;
|
||||
@@ -190,7 +190,7 @@ class Scenario{
|
||||
|
||||
$this->diplomacy = Util::array_get($data['diplomacy'], []);
|
||||
|
||||
|
||||
|
||||
$this->generals = array_map(function($rawGeneral){
|
||||
return $this->generateGeneral($rawGeneral, true, 2);
|
||||
}, Util::array_get($data['general'], []));
|
||||
@@ -211,12 +211,22 @@ class Scenario{
|
||||
|
||||
$this->events = array_map(function($rawEvent){
|
||||
//event는 여기서 풀지 않는다. 평가만 한다.
|
||||
$cond = $rawEvent[0];
|
||||
$action = array_slice($rawEvent, 1);
|
||||
|
||||
$target = $rawEvent[0];
|
||||
if(is_string($target)){
|
||||
throw new \RuntimeException("{$target}이 문자열이 아님");
|
||||
}
|
||||
$priority = $rawEvent[1];
|
||||
if(is_int($priority)){
|
||||
throw new \RuntimeException("{$priority}가 정수가 아님");
|
||||
}
|
||||
$cond = $rawEvent[2];
|
||||
$action = array_slice($rawEvent, 3);
|
||||
|
||||
new \sammo\Event\EventHandler($cond, $action);
|
||||
|
||||
|
||||
return [
|
||||
'target' => $target,
|
||||
'priority' => $priority,
|
||||
'cond' => $cond,
|
||||
'action' => $action
|
||||
];
|
||||
@@ -310,7 +320,7 @@ class Scenario{
|
||||
$this->initLite();
|
||||
return $this->nations;
|
||||
}
|
||||
|
||||
|
||||
public function getMapTheme(){
|
||||
return $this->gameConf['mapName'];
|
||||
}
|
||||
@@ -377,7 +387,7 @@ class Scenario{
|
||||
private function buildGenerals($env){
|
||||
$this->initFull();
|
||||
|
||||
|
||||
|
||||
try{
|
||||
$text = \file_get_contents(ServConfig::getSharedIconPath('../hook/list.json?1'));
|
||||
$storedIcons = Json::decode($text);
|
||||
@@ -398,7 +408,7 @@ class Scenario{
|
||||
}
|
||||
|
||||
$rawGeneral = $this->tmpGeneralQueue[$general->getGeneralRawName()];
|
||||
$birth = $general->getBirthYear();
|
||||
$birth = $general->getBirthYear();
|
||||
if(!key_exists($birth, $remainGenerals)){
|
||||
$remainGenerals[$birth] = [];
|
||||
}
|
||||
@@ -432,13 +442,13 @@ class Scenario{
|
||||
}
|
||||
|
||||
$rawGeneral = $this->tmpGeneralQueue[$general->getGeneralRawName()];
|
||||
$birth = $general->getBirthYear();
|
||||
$birth = $general->getBirthYear();
|
||||
if(!key_exists($birth, $remainGenerals)){
|
||||
$remainGenerals[$birth] = [];
|
||||
}
|
||||
$remainGenerals[$birth][] = array_merge(['RegNeutralNPC'], $rawGeneral);
|
||||
}
|
||||
|
||||
|
||||
return $remainGenerals;
|
||||
}
|
||||
|
||||
@@ -508,7 +518,7 @@ class Scenario{
|
||||
|
||||
$nation->build($env);
|
||||
}
|
||||
|
||||
|
||||
refreshNationStaticInfo();
|
||||
CityHelper::flushCache();
|
||||
|
||||
@@ -519,6 +529,8 @@ class Scenario{
|
||||
|
||||
$actions[] = ['DeleteEvent'];
|
||||
$this->events[] = [
|
||||
'target'=>'Month',
|
||||
'priority'=>1000,
|
||||
'cond'=>['Date', '>=', $targetYear, '1'],
|
||||
'action'=>$actions
|
||||
];
|
||||
@@ -540,6 +552,8 @@ class Scenario{
|
||||
|
||||
$events = array_map(function($rawEvent){
|
||||
return [
|
||||
'target'=>$rawEvent['target'],
|
||||
'priority'=>$rawEvent['priority'],
|
||||
'condition'=>Json::encode($rawEvent['cond']),
|
||||
'action'=>Json::encode($rawEvent['action'])
|
||||
];
|
||||
@@ -549,7 +563,7 @@ class Scenario{
|
||||
$db->insert('event', $events);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
pushGlobalHistoryLog($this->history, $env['year'], $env['month']);
|
||||
|
||||
@@ -568,7 +582,7 @@ class Scenario{
|
||||
foreach(glob(self::SCENARIO_PATH.'/scenario_*.json') as $scenarioPath){
|
||||
$scenarioName = pathinfo(basename($scenarioPath), PATHINFO_FILENAME);
|
||||
$scenarioIdx = Util::array_last(explode('_', $scenarioName));
|
||||
|
||||
|
||||
if(!is_numeric($scenarioIdx)){
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -8,11 +8,13 @@
|
||||
},
|
||||
"events":[
|
||||
[
|
||||
"month", 1000,
|
||||
["or", ["Date", "==", null, 12], ["Date", "==", null, 6]],
|
||||
["CreateManyNPC", 10, 10],
|
||||
["DeleteEvent"]
|
||||
],
|
||||
[
|
||||
"month", 1000,
|
||||
["Date", "==", 181, 1],
|
||||
["RaiseNPCNation"],
|
||||
["DeleteEvent"]
|
||||
|
||||
@@ -11,11 +11,13 @@
|
||||
},
|
||||
"events":[
|
||||
[
|
||||
"month", 1000,
|
||||
["or", ["Date", "==", null, 12], ["Date", "==", null, 6]],
|
||||
["CreateManyNPC", 10, 10],
|
||||
["DeleteEvent"]
|
||||
],
|
||||
[
|
||||
"month", 1000,
|
||||
["Date", "==", 181, 1],
|
||||
["RaiseNPCNation"],
|
||||
["DeleteEvent"]
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
]],
|
||||
["황건적", "#FFD700", 10000, 10000, "황건적", 500, "태평도", 2, [
|
||||
"업","계교","진류","관도","정도","평원","복양","패","허창","초"
|
||||
]]
|
||||
]]
|
||||
],
|
||||
"diplomacy":[
|
||||
],
|
||||
@@ -703,7 +703,7 @@
|
||||
],
|
||||
"history":[
|
||||
"<C>●</>184년 1월:<L><b>【역사모드1】</b></>황건적의 난",
|
||||
"<C>●</>184년 1월:<Y><b>【황건적】</b></>전국 각지에서 황건적이 들고 일어서고 있습니다."
|
||||
"<C>●</>184년 1월:<Y><b>【황건적】</b></>전국 각지에서 황건적이 들고 일어서고 있습니다."
|
||||
],
|
||||
"initialEvents":[
|
||||
[
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"진류"
|
||||
]],
|
||||
["유언", "#483D8B", 10000, 10000, "익주 주자사 유언", 1000, "유가", 3, [
|
||||
"성도", "면죽", "자동", "강주"
|
||||
"성도", "면죽", "자동", "강주"
|
||||
]],
|
||||
["원술", "#FFC0CB", 10000, 10000, "4세 5공 명문 혈통 원소의 사촌 원술", 1000, "병가", 2, [
|
||||
"완"
|
||||
@@ -67,7 +67,7 @@
|
||||
["공주", "#800080", 10000, 10000, "공주", 1000, "도가", 3, [
|
||||
"초"
|
||||
]]
|
||||
|
||||
|
||||
],
|
||||
"diplomacy":[
|
||||
[1, 2, 1, 36],
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
},
|
||||
"nation":[
|
||||
["조조", "#000080", 10000, 10000, "하북을 제패하고 대군을 이끌고 남하하는 조조", 1000, "병가", 6, [
|
||||
"허창", "역경", "계교", "관도", "호관", "정도", "호로", "사곡", "함곡", "사수", "서주", "계",
|
||||
"북평", "진양", "남피", "평원", "하내", "업", "북해", "복양", "장안", "홍농", "낙양", "진류",
|
||||
"허창", "역경", "계교", "관도", "호관", "정도", "호로", "사곡", "함곡", "사수", "서주", "계",
|
||||
"북평", "진양", "남피", "평원", "하내", "업", "북해", "복양", "장안", "홍농", "낙양", "진류",
|
||||
"패", "초", "하비", "완", "여남", "수춘", "신야", "양양", "강릉", "장판"
|
||||
]],
|
||||
["손권", "#FF0000", 10000, 10000, "조조의 남하에 유비와 불가침으로 맞서는 손권", 1000, "덕가", 4, [
|
||||
|
||||
@@ -15,11 +15,13 @@
|
||||
},
|
||||
"events":[
|
||||
[
|
||||
"month", 1000,
|
||||
["or", ["Date", "==", null, 12], ["Date", "==", null, 6]],
|
||||
["CreateManyNPC", 10, 10],
|
||||
["DeleteEvent"]
|
||||
],
|
||||
[
|
||||
"month", 1000,
|
||||
["Date", "==", 181, 1],
|
||||
["RaiseNPCNation"],
|
||||
["DeleteEvent"]
|
||||
|
||||
@@ -99,11 +99,13 @@
|
||||
],
|
||||
"events":[
|
||||
[
|
||||
"month", 1000,
|
||||
["or", ["Date", "==", null, 12], ["Date", "==", null, 6]],
|
||||
["CreateManyNPC", 10, 10],
|
||||
["DeleteEvent"]
|
||||
],
|
||||
[
|
||||
"month", 1000,
|
||||
["Date", "==", 181, 1],
|
||||
["RaiseNPCNation"],
|
||||
["DeleteEvent"]
|
||||
|
||||
@@ -59,11 +59,13 @@
|
||||
},
|
||||
"events":[
|
||||
[
|
||||
"month", 1000,
|
||||
["Date", "==", null, 12],
|
||||
["CreateManyNPC", 10, 10],
|
||||
["DeleteEvent"]
|
||||
],
|
||||
[
|
||||
"month", 1000,
|
||||
["Date", "==", 182, 1],
|
||||
["ChangeCity", "occupied", {
|
||||
"trade":100
|
||||
@@ -71,6 +73,7 @@
|
||||
["DeleteEvent"]
|
||||
],
|
||||
[
|
||||
"month", 1000,
|
||||
["Date", "==", 182, 7],
|
||||
["ChangeCity", "occupied", {
|
||||
"trade":100
|
||||
|
||||
@@ -11,11 +11,13 @@
|
||||
],
|
||||
"events": [
|
||||
[
|
||||
"month", 1000,
|
||||
["Date", "==", null, 12],
|
||||
["CreateManyNPC", 100, 0],
|
||||
["DeleteEvent"]
|
||||
],
|
||||
[
|
||||
"month", 1000,
|
||||
["Date", "==", 181, 12],
|
||||
["ChangeCity", "occupied", {
|
||||
"pop": "+60000",
|
||||
|
||||
Reference in New Issue
Block a user