test: Ref 명령 행렬 fixture의 결정성을 보강한다
This commit is contained in:
@@ -28,13 +28,24 @@ interface EntityIdentity {
|
||||
semantic: boolean;
|
||||
}
|
||||
|
||||
const entityIdentity = (value: Record<string, unknown>, index: number): EntityIdentity => {
|
||||
const entityIdentity = (value: Record<string, unknown>, index: number, path: string): EntityIdentity => {
|
||||
if (
|
||||
(typeof value.generalId === 'number' || typeof value.generalId === 'string') &&
|
||||
typeof value.type === 'string'
|
||||
) {
|
||||
return { key: `${String(value.generalId)}:${value.type}`, semantic: true };
|
||||
}
|
||||
if (
|
||||
(path === 'world.generalCooldowns' || path === 'world.nationCooldowns') &&
|
||||
typeof value.actionName === 'string'
|
||||
) {
|
||||
for (const key of ['generalId', 'nationId']) {
|
||||
const candidate = value[key];
|
||||
if (typeof candidate === 'number' || typeof candidate === 'string') {
|
||||
return { key: `${String(candidate)}:${value.actionName}`, semantic: true };
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const key of ['id', 'generalId', 'nationId', 'fromNationId']) {
|
||||
const candidate = value[key];
|
||||
if (typeof candidate === 'number' || typeof candidate === 'string') {
|
||||
@@ -62,7 +73,7 @@ const flatten = (value: unknown, path: string, output: FlatSnapshot): void => {
|
||||
path === 'logs' || path === 'messages'
|
||||
? { key: String(index), semantic: false }
|
||||
: typeof entry === 'object' && entry !== null && !Array.isArray(entry)
|
||||
? entityIdentity(entry as Record<string, unknown>, index)
|
||||
? entityIdentity(entry as Record<string, unknown>, index, path)
|
||||
: { key: String(index), semantic: false };
|
||||
if (identity.semantic) {
|
||||
const firstIndex = semanticKeys.get(identity.key);
|
||||
|
||||
@@ -72,6 +72,8 @@ export interface TurnCommandFixtureRequest {
|
||||
initMonth?: number;
|
||||
year?: number;
|
||||
month?: number;
|
||||
develCost?: number;
|
||||
isUnited?: 0 | 1 | 2 | 3;
|
||||
hiddenSeed?: string;
|
||||
scenarioEffect?: string | null;
|
||||
staticEventHandlers?: Record<string, string[]>;
|
||||
@@ -333,6 +335,9 @@ const buildGeneral = (row: Record<string, unknown>, fallbackTurnTime: Date): Tur
|
||||
: row.hasOwner === true
|
||||
? 'turn-differential-owner'
|
||||
: null,
|
||||
inheritancePoints: {
|
||||
active_action: readNumber(row, 'inheritActiveActionPoints'),
|
||||
},
|
||||
penalty: row.penalty,
|
||||
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
|
||||
meta: {
|
||||
@@ -376,6 +381,7 @@ const buildGeneral = (row: Record<string, unknown>, fallbackTurnTime: Date): Tur
|
||||
belong: readNumber(row, 'belong', readNumber(meta, 'belong')),
|
||||
permission: readString(row, 'permission', readString(meta, 'permission', 'normal')),
|
||||
block: readNumber(row, 'blockState', readNumber(meta, 'block')),
|
||||
inherit_active_action: readNumber(row, 'inheritActiveActionPoints') / 3,
|
||||
},
|
||||
...(lastTurn ? { lastTurn } : {}),
|
||||
...(typeof row.turnTick === 'number' ? { turnTick: row.turnTick } : {}),
|
||||
|
||||
Reference in New Issue
Block a user