merge: add semi-annual monthly comparison fixture
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
{
|
||||
"action": "ProcessSemiAnnual",
|
||||
"resource": "gold",
|
||||
"environment": {
|
||||
"year": 193,
|
||||
"month": 1,
|
||||
"startyear": 190
|
||||
},
|
||||
"setup": {
|
||||
"resetCities": true,
|
||||
"resetGenerals": true,
|
||||
"nation": [
|
||||
{
|
||||
"id": 1,
|
||||
"values": {
|
||||
"name": "반기검증국",
|
||||
"gold": 100001,
|
||||
"rice": 7777,
|
||||
"rate_tmp": 20,
|
||||
"type": "che_도가"
|
||||
}
|
||||
}
|
||||
],
|
||||
"city": [
|
||||
{
|
||||
"id": 1,
|
||||
"values": {
|
||||
"nation": 1,
|
||||
"supply": 1,
|
||||
"pop": 10000,
|
||||
"pop_max": 50000,
|
||||
"agri": 1001,
|
||||
"agri_max": 5000,
|
||||
"comm": 1001,
|
||||
"comm_max": 5000,
|
||||
"secu": 1001,
|
||||
"secu_max": 2000,
|
||||
"trust": 55,
|
||||
"def": 1001,
|
||||
"def_max": 5000,
|
||||
"wall": 1001,
|
||||
"wall_max": 5000,
|
||||
"dead": 123
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"values": {
|
||||
"nation": 1,
|
||||
"supply": 0,
|
||||
"pop": 10000,
|
||||
"pop_max": 50000,
|
||||
"agri": 1001,
|
||||
"agri_max": 5000,
|
||||
"comm": 1001,
|
||||
"comm_max": 5000,
|
||||
"secu": 1001,
|
||||
"secu_max": 2000,
|
||||
"trust": 55,
|
||||
"def": 1001,
|
||||
"def_max": 5000,
|
||||
"wall": 1001,
|
||||
"wall_max": 5000,
|
||||
"dead": 123
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"values": {
|
||||
"nation": 0,
|
||||
"supply": 1,
|
||||
"pop": 10000,
|
||||
"pop_max": 50000,
|
||||
"agri": 1001,
|
||||
"agri_max": 5000,
|
||||
"comm": 1001,
|
||||
"comm_max": 5000,
|
||||
"secu": 1001,
|
||||
"secu_max": 2000,
|
||||
"trust": 55,
|
||||
"def": 1001,
|
||||
"def_max": 5000,
|
||||
"wall": 1001,
|
||||
"wall_max": 5000,
|
||||
"dead": 123
|
||||
}
|
||||
}
|
||||
],
|
||||
"general": [
|
||||
{
|
||||
"id": 1,
|
||||
"values": {
|
||||
"nation": 1,
|
||||
"city": 1,
|
||||
"gold": 10001,
|
||||
"rice": 8888
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"observe": {
|
||||
"generalIds": [1],
|
||||
"cityIds": [1, 2, 3],
|
||||
"nationIds": [1]
|
||||
}
|
||||
}
|
||||
@@ -26,19 +26,19 @@ function comparisonMonthlyPatch(string $table, int $id, array $values): void
|
||||
'name', 'level', 'nation', 'supply', 'front', 'pop', 'pop_max',
|
||||
'agri', 'agri_max', 'comm', 'comm_max', 'secu', 'secu_max',
|
||||
'trust', 'trade', 'def', 'def_max', 'wall', 'wall_max',
|
||||
'officer_set', 'state', 'region', 'term', 'conflict',
|
||||
'officer_set', 'state', 'region', 'term', 'conflict', 'dead',
|
||||
],
|
||||
],
|
||||
'nation' => [
|
||||
'idColumn' => 'nation',
|
||||
'allowed' => ['name', 'color', 'capital', 'gold', 'rice', 'level', 'type', 'aux'],
|
||||
'allowed' => ['name', 'color', 'capital', 'gold', 'rice', 'level', 'type', 'rate_tmp', 'aux'],
|
||||
],
|
||||
'general' => [
|
||||
'idColumn' => 'no',
|
||||
'allowed' => [
|
||||
'name', 'nation', 'city', 'officer_level', 'officer_city',
|
||||
'crew', 'train', 'atmos', 'owner', 'npc', 'killturn', 'belong',
|
||||
'horse', 'weapon', 'book', 'item', 'aux',
|
||||
'gold', 'rice', 'horse', 'weapon', 'book', 'item', 'aux',
|
||||
],
|
||||
],
|
||||
];
|
||||
@@ -90,6 +90,8 @@ function comparisonMonthlyDetails(array $observe, int $worldHistoryAfterId): arr
|
||||
'crew' => 'crew',
|
||||
'train' => 'train',
|
||||
'atmos' => 'atmos',
|
||||
'gold' => 'gold',
|
||||
'rice' => 'rice',
|
||||
],
|
||||
),
|
||||
comparisonRowsById('general', 'no', comparisonIntegerList($observe['generalIds'] ?? [], 'generalIds')),
|
||||
@@ -104,12 +106,33 @@ function comparisonMonthlyDetails(array $observe, int $worldHistoryAfterId): arr
|
||||
'frontState' => 'front',
|
||||
'officerSet' => 'officer_set',
|
||||
'term' => 'term',
|
||||
'dead' => 'dead',
|
||||
'population' => 'pop',
|
||||
'agriculture' => 'agri',
|
||||
'commerce' => 'comm',
|
||||
'security' => 'secu',
|
||||
'trust' => 'trust',
|
||||
'defence' => 'def',
|
||||
'wall' => 'wall',
|
||||
'conflict' => 'conflict',
|
||||
],
|
||||
['conflict'],
|
||||
),
|
||||
comparisonRowsById('city', 'city', comparisonIntegerList($observe['cityIds'] ?? [], 'cityIds')),
|
||||
);
|
||||
$nations = array_map(
|
||||
static fn(array $row): array => comparisonPickRow(
|
||||
$row,
|
||||
[
|
||||
'id' => 'nation',
|
||||
'gold' => 'gold',
|
||||
'rice' => 'rice',
|
||||
'rate' => 'rate_tmp',
|
||||
'typeCode' => 'type',
|
||||
],
|
||||
),
|
||||
comparisonRowsById('nation', 'nation', comparisonIntegerList($observe['nationIds'] ?? [], 'nationIds')),
|
||||
);
|
||||
$worldHistory = array_map(
|
||||
static fn(array $row): array => comparisonPickRow(
|
||||
$row,
|
||||
@@ -141,6 +164,7 @@ function comparisonMonthlyDetails(array $observe, int $worldHistoryAfterId): arr
|
||||
return [
|
||||
'generals' => $generals,
|
||||
'cities' => $cities,
|
||||
'nations' => $nations,
|
||||
'worldHistory' => $worldHistory,
|
||||
'inheritancePoints' => $inheritancePoints,
|
||||
];
|
||||
@@ -155,7 +179,7 @@ function comparisonMonthlyEventTraceMain(): void
|
||||
throw new \InvalidArgumentException('request must be an object');
|
||||
}
|
||||
$actionName = $request['action'] ?? null;
|
||||
if (!in_array($actionName, ['UpdateCitySupply', 'UpdateNationLevel'], true)) {
|
||||
if (!in_array($actionName, ['UpdateCitySupply', 'UpdateNationLevel', 'ProcessSemiAnnual'], true)) {
|
||||
throw new \InvalidArgumentException('unsupported monthly action');
|
||||
}
|
||||
$setup = $request['setup'] ?? [];
|
||||
@@ -236,7 +260,15 @@ function comparisonMonthlyEventTraceMain(): void
|
||||
}
|
||||
|
||||
$actionClass = "\\sammo\\Event\\Action\\{$actionName}";
|
||||
$action = new $actionClass();
|
||||
if ($actionName === 'ProcessSemiAnnual') {
|
||||
$resource = $request['resource'] ?? null;
|
||||
if (!is_string($resource)) {
|
||||
throw new \InvalidArgumentException('ProcessSemiAnnual requires resource');
|
||||
}
|
||||
$action = new $actionClass($resource);
|
||||
} else {
|
||||
$action = new $actionClass();
|
||||
}
|
||||
$actionEnvironment = [
|
||||
'year' => $year,
|
||||
'month' => $month,
|
||||
|
||||
Reference in New Issue
Block a user