fix: 지난 플레이 전투 자료를 보존한다
통일·장수 삭제·게임 취소 archive에 전투 집계와 숙련도, 전투 결과를 저장한다. 개인 기록과 전투 상세는 보존 대상에서 제외하고 기존 Core snapshot도 정규화한다.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
||||
import { asRecord } from '@sammo-ts/common';
|
||||
import { asRecord, normalizeArchivedGeneral, type ArchivedJsonValue } from '@sammo-ts/common';
|
||||
import { createGamePostgresConnector, type GamePrismaClient } from '@sammo-ts/infra';
|
||||
import { LogCategory, LogScope } from '@sammo-ts/logic';
|
||||
|
||||
@@ -98,6 +98,10 @@ integration('general turn lifecycle persistence', () => {
|
||||
inherit_active_action: 2,
|
||||
inheritRandomUnique: true,
|
||||
dex1: 1_000,
|
||||
dex2: 1,
|
||||
dex3: 1,
|
||||
dex4: 1,
|
||||
dex5: 1,
|
||||
},
|
||||
});
|
||||
await db.generalAccessLog.create({
|
||||
@@ -110,6 +114,10 @@ integration('general turn lifecycle persistence', () => {
|
||||
data: [
|
||||
{ generalId: general.id, nationId: 0, type: 'warnum', value: 2 },
|
||||
{ generalId: general.id, nationId: 0, type: 'firenum', value: 1 },
|
||||
{ generalId: general.id, nationId: 0, type: 'killnum', value: 1 },
|
||||
{ generalId: general.id, nationId: 0, type: 'deathnum', value: 1 },
|
||||
{ generalId: general.id, nationId: 0, type: 'killcrew', value: 400 },
|
||||
{ generalId: general.id, nationId: 0, type: 'deathcrew', value: 300 },
|
||||
],
|
||||
});
|
||||
await db.logEntry.createMany({
|
||||
@@ -130,6 +138,30 @@ integration('general turn lifecycle persistence', () => {
|
||||
generalId: general.id,
|
||||
text: '<Y>●</>둘째 기록',
|
||||
},
|
||||
{
|
||||
scope: LogScope.GENERAL,
|
||||
category: LogCategory.ACTION,
|
||||
year: 200,
|
||||
month: 1,
|
||||
generalId: general.id,
|
||||
text: '보존하지 않을 개인 기록',
|
||||
},
|
||||
{
|
||||
scope: LogScope.GENERAL,
|
||||
category: LogCategory.BATTLE_DETAIL,
|
||||
year: 200,
|
||||
month: 1,
|
||||
generalId: general.id,
|
||||
text: '보존하지 않을 전투 기록',
|
||||
},
|
||||
{
|
||||
scope: LogScope.GENERAL,
|
||||
category: LogCategory.BATTLE_BRIEF,
|
||||
year: 200,
|
||||
month: 1,
|
||||
generalId: general.id,
|
||||
text: '보존할 전투 결과',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
@@ -150,6 +182,22 @@ integration('general turn lifecycle persistence', () => {
|
||||
expect(archivedData.history).toEqual(['<Y>●</>둘째 기록', '<C>●</>첫 기록']);
|
||||
expect(asRecord(archivedData.meta)).not.toHaveProperty('inheritRandomUnique');
|
||||
expect(asRecord(archivedData.meta)).not.toHaveProperty('inheritSpecificSpecialWar');
|
||||
const snapshot = normalizeArchivedGeneral(archived.data as ArchivedJsonValue, archived.name).snapshot;
|
||||
expect(snapshot).toMatchObject({
|
||||
mastery: { infantry: 1_000, archery: 1, cavalry: 1, special: 1, siege: 1 },
|
||||
battle: {
|
||||
battles: 2,
|
||||
wins: 1,
|
||||
losses: 1,
|
||||
fireSuccesses: 1,
|
||||
killedCrew: 400,
|
||||
lostCrew: 300,
|
||||
},
|
||||
records: { battleResult: ['보존할 전투 결과'] },
|
||||
availability: { battleResultLogs: true, battleDetailLogs: false },
|
||||
});
|
||||
expect(JSON.stringify(archived.data)).not.toContain('보존하지 않을 개인 기록');
|
||||
expect(JSON.stringify(archived.data)).not.toContain('보존하지 않을 전투 기록');
|
||||
expect(
|
||||
await db.inheritancePoint.findUnique({
|
||||
where: { userId_key: { userId: general.userId!, key: 'previous' } },
|
||||
|
||||
Reference in New Issue
Block a user