feat: 시나리오 event 포맷에서 target, priority 추가
This commit is contained in:
+16
-2
@@ -211,12 +211,22 @@ class Scenario{
|
|||||||
|
|
||||||
$this->events = array_map(function($rawEvent){
|
$this->events = array_map(function($rawEvent){
|
||||||
//event는 여기서 풀지 않는다. 평가만 한다.
|
//event는 여기서 풀지 않는다. 평가만 한다.
|
||||||
$cond = $rawEvent[0];
|
$target = $rawEvent[0];
|
||||||
$action = array_slice($rawEvent, 1);
|
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);
|
new \sammo\Event\EventHandler($cond, $action);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
'target' => $target,
|
||||||
|
'priority' => $priority,
|
||||||
'cond' => $cond,
|
'cond' => $cond,
|
||||||
'action' => $action
|
'action' => $action
|
||||||
];
|
];
|
||||||
@@ -519,6 +529,8 @@ class Scenario{
|
|||||||
|
|
||||||
$actions[] = ['DeleteEvent'];
|
$actions[] = ['DeleteEvent'];
|
||||||
$this->events[] = [
|
$this->events[] = [
|
||||||
|
'target'=>'Month',
|
||||||
|
'priority'=>1000,
|
||||||
'cond'=>['Date', '>=', $targetYear, '1'],
|
'cond'=>['Date', '>=', $targetYear, '1'],
|
||||||
'action'=>$actions
|
'action'=>$actions
|
||||||
];
|
];
|
||||||
@@ -540,6 +552,8 @@ class Scenario{
|
|||||||
|
|
||||||
$events = array_map(function($rawEvent){
|
$events = array_map(function($rawEvent){
|
||||||
return [
|
return [
|
||||||
|
'target'=>$rawEvent['target'],
|
||||||
|
'priority'=>$rawEvent['priority'],
|
||||||
'condition'=>Json::encode($rawEvent['cond']),
|
'condition'=>Json::encode($rawEvent['cond']),
|
||||||
'action'=>Json::encode($rawEvent['action'])
|
'action'=>Json::encode($rawEvent['action'])
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -8,11 +8,13 @@
|
|||||||
},
|
},
|
||||||
"events":[
|
"events":[
|
||||||
[
|
[
|
||||||
|
"month", 1000,
|
||||||
["or", ["Date", "==", null, 12], ["Date", "==", null, 6]],
|
["or", ["Date", "==", null, 12], ["Date", "==", null, 6]],
|
||||||
["CreateManyNPC", 10, 10],
|
["CreateManyNPC", 10, 10],
|
||||||
["DeleteEvent"]
|
["DeleteEvent"]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
"month", 1000,
|
||||||
["Date", "==", 181, 1],
|
["Date", "==", 181, 1],
|
||||||
["RaiseNPCNation"],
|
["RaiseNPCNation"],
|
||||||
["DeleteEvent"]
|
["DeleteEvent"]
|
||||||
|
|||||||
@@ -11,11 +11,13 @@
|
|||||||
},
|
},
|
||||||
"events":[
|
"events":[
|
||||||
[
|
[
|
||||||
|
"month", 1000,
|
||||||
["or", ["Date", "==", null, 12], ["Date", "==", null, 6]],
|
["or", ["Date", "==", null, 12], ["Date", "==", null, 6]],
|
||||||
["CreateManyNPC", 10, 10],
|
["CreateManyNPC", 10, 10],
|
||||||
["DeleteEvent"]
|
["DeleteEvent"]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
"month", 1000,
|
||||||
["Date", "==", 181, 1],
|
["Date", "==", 181, 1],
|
||||||
["RaiseNPCNation"],
|
["RaiseNPCNation"],
|
||||||
["DeleteEvent"]
|
["DeleteEvent"]
|
||||||
|
|||||||
@@ -15,11 +15,13 @@
|
|||||||
},
|
},
|
||||||
"events":[
|
"events":[
|
||||||
[
|
[
|
||||||
|
"month", 1000,
|
||||||
["or", ["Date", "==", null, 12], ["Date", "==", null, 6]],
|
["or", ["Date", "==", null, 12], ["Date", "==", null, 6]],
|
||||||
["CreateManyNPC", 10, 10],
|
["CreateManyNPC", 10, 10],
|
||||||
["DeleteEvent"]
|
["DeleteEvent"]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
"month", 1000,
|
||||||
["Date", "==", 181, 1],
|
["Date", "==", 181, 1],
|
||||||
["RaiseNPCNation"],
|
["RaiseNPCNation"],
|
||||||
["DeleteEvent"]
|
["DeleteEvent"]
|
||||||
|
|||||||
@@ -99,11 +99,13 @@
|
|||||||
],
|
],
|
||||||
"events":[
|
"events":[
|
||||||
[
|
[
|
||||||
|
"month", 1000,
|
||||||
["or", ["Date", "==", null, 12], ["Date", "==", null, 6]],
|
["or", ["Date", "==", null, 12], ["Date", "==", null, 6]],
|
||||||
["CreateManyNPC", 10, 10],
|
["CreateManyNPC", 10, 10],
|
||||||
["DeleteEvent"]
|
["DeleteEvent"]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
"month", 1000,
|
||||||
["Date", "==", 181, 1],
|
["Date", "==", 181, 1],
|
||||||
["RaiseNPCNation"],
|
["RaiseNPCNation"],
|
||||||
["DeleteEvent"]
|
["DeleteEvent"]
|
||||||
|
|||||||
@@ -59,11 +59,13 @@
|
|||||||
},
|
},
|
||||||
"events":[
|
"events":[
|
||||||
[
|
[
|
||||||
|
"month", 1000,
|
||||||
["Date", "==", null, 12],
|
["Date", "==", null, 12],
|
||||||
["CreateManyNPC", 10, 10],
|
["CreateManyNPC", 10, 10],
|
||||||
["DeleteEvent"]
|
["DeleteEvent"]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
"month", 1000,
|
||||||
["Date", "==", 182, 1],
|
["Date", "==", 182, 1],
|
||||||
["ChangeCity", "occupied", {
|
["ChangeCity", "occupied", {
|
||||||
"trade":100
|
"trade":100
|
||||||
@@ -71,6 +73,7 @@
|
|||||||
["DeleteEvent"]
|
["DeleteEvent"]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
"month", 1000,
|
||||||
["Date", "==", 182, 7],
|
["Date", "==", 182, 7],
|
||||||
["ChangeCity", "occupied", {
|
["ChangeCity", "occupied", {
|
||||||
"trade":100
|
"trade":100
|
||||||
|
|||||||
@@ -11,11 +11,13 @@
|
|||||||
],
|
],
|
||||||
"events": [
|
"events": [
|
||||||
[
|
[
|
||||||
|
"month", 1000,
|
||||||
["Date", "==", null, 12],
|
["Date", "==", null, 12],
|
||||||
["CreateManyNPC", 100, 0],
|
["CreateManyNPC", 100, 0],
|
||||||
["DeleteEvent"]
|
["DeleteEvent"]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
"month", 1000,
|
||||||
["Date", "==", 181, 12],
|
["Date", "==", 181, 12],
|
||||||
["ChangeCity", "occupied", {
|
["ChangeCity", "occupied", {
|
||||||
"pop": "+60000",
|
"pop": "+60000",
|
||||||
|
|||||||
Reference in New Issue
Block a user