feat: 시나리오 event 포맷에서 target, priority 추가

This commit is contained in:
2022-02-05 07:43:27 +00:00
committed by Gitea
parent 4e359f5eb9
commit 3e4cf764c8
10 changed files with 73 additions and 46 deletions
+16 -2
View File
@@ -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
];
@@ -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'])
];
+2
View File
@@ -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"]
+2
View File
@@ -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"]
+2
View File
@@ -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"]
+2
View File
@@ -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"]
+3
View File
@@ -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
+2
View File
@@ -11,11 +11,13 @@
],
"events": [
[
"month", 1000,
["Date", "==", null, 12],
["CreateManyNPC", 100, 0],
["DeleteEvent"]
],
[
"month", 1000,
["Date", "==", 181, 12],
["ChangeCity", "occupied", {
"pop": "+60000",