test: trace monthly NPC registration
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"action": "RegNeutralNPC",
|
||||||
|
"args": [
|
||||||
|
0,
|
||||||
|
"등록재야",
|
||||||
|
null,
|
||||||
|
0,
|
||||||
|
33,
|
||||||
|
45,
|
||||||
|
55,
|
||||||
|
65,
|
||||||
|
180,
|
||||||
|
245,
|
||||||
|
null,
|
||||||
|
"무쌍",
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"setup": {
|
||||||
|
"syncEnvironment": true
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"year": 200,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190,
|
||||||
|
"turnterm": 10,
|
||||||
|
"turntime": "0200-01-01 00:00:00",
|
||||||
|
"show_img_level": 3,
|
||||||
|
"fiction": [0]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [],
|
||||||
|
"cityIds": [33],
|
||||||
|
"nationIds": [1]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"action": "RegNPC",
|
||||||
|
"args": [
|
||||||
|
0,
|
||||||
|
"등록장수",
|
||||||
|
null,
|
||||||
|
0,
|
||||||
|
33,
|
||||||
|
60,
|
||||||
|
50,
|
||||||
|
40,
|
||||||
|
7,
|
||||||
|
186,
|
||||||
|
240,
|
||||||
|
null,
|
||||||
|
"인덕",
|
||||||
|
"등록 대사"
|
||||||
|
],
|
||||||
|
"setup": {
|
||||||
|
"syncEnvironment": true
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"year": 200,
|
||||||
|
"month": 1,
|
||||||
|
"startyear": 190,
|
||||||
|
"turnterm": 10,
|
||||||
|
"turntime": "0200-01-01 00:00:00",
|
||||||
|
"show_img_level": 3,
|
||||||
|
"fiction": [0]
|
||||||
|
},
|
||||||
|
"observe": {
|
||||||
|
"generalIds": [],
|
||||||
|
"cityIds": [33],
|
||||||
|
"nationIds": [1]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -186,6 +186,8 @@ function comparisonMonthlyEventTraceMain(): void
|
|||||||
'ProcessWarIncome',
|
'ProcessWarIncome',
|
||||||
'CreateAdminNPC',
|
'CreateAdminNPC',
|
||||||
'CreateManyNPC',
|
'CreateManyNPC',
|
||||||
|
'RegNPC',
|
||||||
|
'RegNeutralNPC',
|
||||||
];
|
];
|
||||||
if (!in_array($actionName, $supportedActions, true)) {
|
if (!in_array($actionName, $supportedActions, true)) {
|
||||||
throw new \InvalidArgumentException('unsupported monthly action');
|
throw new \InvalidArgumentException('unsupported monthly action');
|
||||||
@@ -276,10 +278,13 @@ function comparisonMonthlyEventTraceMain(): void
|
|||||||
throw new \InvalidArgumentException('ProcessSemiAnnual requires resource');
|
throw new \InvalidArgumentException('ProcessSemiAnnual requires resource');
|
||||||
}
|
}
|
||||||
$action = new $actionClass($resource);
|
$action = new $actionClass($resource);
|
||||||
} elseif ($actionName === 'CreateManyNPC') {
|
} elseif (in_array($actionName, ['CreateManyNPC', 'RegNPC', 'RegNeutralNPC'], true)) {
|
||||||
$args = $request['args'] ?? [];
|
$args = $request['args'] ?? [];
|
||||||
if (!is_array($args) || count($args) > 2) {
|
if (!is_array($args)) {
|
||||||
throw new \InvalidArgumentException('CreateManyNPC args must be an array with at most two entries');
|
throw new \InvalidArgumentException("{$actionName} args must be an array");
|
||||||
|
}
|
||||||
|
if ($actionName === 'CreateManyNPC' && count($args) > 2) {
|
||||||
|
throw new \InvalidArgumentException('CreateManyNPC args must have at most two entries');
|
||||||
}
|
}
|
||||||
$action = new $actionClass(...$args);
|
$action = new $actionClass(...$args);
|
||||||
} else {
|
} else {
|
||||||
@@ -299,19 +304,29 @@ function comparisonMonthlyEventTraceMain(): void
|
|||||||
$actionEnvironment['killturn'] = $killturn;
|
$actionEnvironment['killturn'] = $killturn;
|
||||||
$actionEnvironment['turnterm'] = $turnterm;
|
$actionEnvironment['turnterm'] = $turnterm;
|
||||||
}
|
}
|
||||||
if ($actionName === 'CreateManyNPC') {
|
if (in_array($actionName, ['CreateManyNPC', 'RegNPC', 'RegNeutralNPC'], true)) {
|
||||||
$turnterm = $environment['turnterm'] ?? null;
|
$turnterm = $environment['turnterm'] ?? null;
|
||||||
$turntime = $environment['turntime'] ?? null;
|
$turntime = $environment['turntime'] ?? null;
|
||||||
if (!is_int($turnterm) || $turnterm <= 0 || !is_string($turntime)) {
|
$showImgLevel = $environment['show_img_level'] ?? 3;
|
||||||
throw new \InvalidArgumentException('CreateManyNPC requires positive turnterm and string turntime');
|
$fiction = $environment['fiction'] ?? [0];
|
||||||
|
if (
|
||||||
|
!is_int($turnterm)
|
||||||
|
|| $turnterm <= 0
|
||||||
|
|| !is_string($turntime)
|
||||||
|
|| !is_int($showImgLevel)
|
||||||
|
|| !is_array($fiction)
|
||||||
|
) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
"{$actionName} requires positive turnterm, string turntime, integer show_img_level, and array fiction",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$actionEnvironment += [
|
$actionEnvironment += [
|
||||||
'turnterm' => $turnterm,
|
'turnterm' => $turnterm,
|
||||||
'turntime' => $turntime,
|
'turntime' => $turntime,
|
||||||
'show_img_level' => 3,
|
'show_img_level' => $showImgLevel,
|
||||||
'stored_icons' => [],
|
'stored_icons' => $environment['stored_icons'] ?? [],
|
||||||
'icon_path' => '.',
|
'icon_path' => $environment['icon_path'] ?? '.',
|
||||||
'fiction' => [0],
|
'fiction' => $fiction,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$action->run($actionEnvironment);
|
$action->run($actionEnvironment);
|
||||||
@@ -321,7 +336,7 @@ function comparisonMonthlyEventTraceMain(): void
|
|||||||
$after = comparisonTurnStateSnapshot($snapshotRequest);
|
$after = comparisonTurnStateSnapshot($snapshotRequest);
|
||||||
$afterDetails = comparisonMonthlyDetails($snapshotRequest['observe'], $worldHistoryAfterId);
|
$afterDetails = comparisonMonthlyDetails($snapshotRequest['observe'], $worldHistoryAfterId);
|
||||||
$createdGenerals = [];
|
$createdGenerals = [];
|
||||||
if ($actionName === 'CreateManyNPC') {
|
if (in_array($actionName, ['CreateManyNPC', 'RegNPC', 'RegNeutralNPC'], true)) {
|
||||||
foreach ($db->query('SELECT * FROM general WHERE no > %i ORDER BY no', $generalIdBeforeAction) as $row) {
|
foreach ($db->query('SELECT * FROM general WHERE no > %i ORDER BY no', $generalIdBeforeAction) as $row) {
|
||||||
$generalId = (int)$row['no'];
|
$generalId = (int)$row['no'];
|
||||||
$turnRows = $db->query(
|
$turnRows = $db->query(
|
||||||
@@ -385,7 +400,7 @@ function comparisonMonthlyEventTraceMain(): void
|
|||||||
'after' => $after,
|
'after' => $after,
|
||||||
'afterDetails' => $afterDetails,
|
'afterDetails' => $afterDetails,
|
||||||
];
|
];
|
||||||
if ($actionName === 'CreateManyNPC') {
|
if (in_array($actionName, ['CreateManyNPC', 'RegNPC', 'RegNeutralNPC'], true)) {
|
||||||
$response['createdGenerals'] = $createdGenerals;
|
$response['createdGenerals'] = $createdGenerals;
|
||||||
}
|
}
|
||||||
echo json_encode(
|
echo json_encode(
|
||||||
|
|||||||
Reference in New Issue
Block a user