feat: 명예의 전당에 유산 획득량을 추가
명장 일람과 같은 inherit_earned 기록을 은퇴와 통일 정산에서 Hall에 보존하고 기수별 순위로 표시한다. API, 저장 경로와 실제 Chromium 회귀 검사를 함께 보강한다.
This commit is contained in:
@@ -251,6 +251,9 @@ integration('general turn lifecycle persistence', () => {
|
||||
await db.rankData.create({
|
||||
data: { generalId: general.id, nationId: 0, type: 'warnum', value: 10 },
|
||||
});
|
||||
await db.rankData.create({
|
||||
data: { generalId: general.id, nationId: 0, type: 'inherit_earned', value: 4_321 },
|
||||
});
|
||||
|
||||
await db.$transaction((tx) =>
|
||||
persistGeneralLifecycleEvents(
|
||||
@@ -278,6 +281,17 @@ integration('general turn lifecycle persistence', () => {
|
||||
},
|
||||
})
|
||||
).toMatchObject({ value: 1_000 });
|
||||
expect(
|
||||
await db.hallOfFame.findUnique({
|
||||
where: {
|
||||
serverId_type_generalNo: {
|
||||
serverId,
|
||||
type: 'inherit_earned',
|
||||
generalNo: general.id,
|
||||
},
|
||||
},
|
||||
})
|
||||
).toMatchObject({ value: 4_321 });
|
||||
expect(
|
||||
await db.inheritancePoint.findUnique({
|
||||
where: { userId_key: { userId: general.userId!, key: 'previous' } },
|
||||
|
||||
@@ -103,4 +103,62 @@ describe('general lifecycle archive history', () => {
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('stores the inheritance earned rank in the hall before a rebirth resets ranks', async () => {
|
||||
const general = archivedGeneral();
|
||||
const hallCreateMany = vi.fn(async () => ({ count: 1 }));
|
||||
const prisma = {
|
||||
generalAccessLog: {
|
||||
updateMany: vi.fn(async () => ({ count: 1 })),
|
||||
},
|
||||
rankData: {
|
||||
findMany: vi.fn(async () => [{ type: 'inherit_earned', value: 4_321 }]),
|
||||
updateMany: vi.fn(async () => ({ count: 1 })),
|
||||
},
|
||||
nation: {
|
||||
findUnique: vi.fn(async () => null),
|
||||
},
|
||||
gameHistory: {
|
||||
count: vi.fn(async () => 2),
|
||||
},
|
||||
hallOfFame: {
|
||||
findUnique: vi.fn(async () => null),
|
||||
createMany: hallCreateMany,
|
||||
update: vi.fn(async () => undefined),
|
||||
},
|
||||
} as unknown as GamePrisma.TransactionClient;
|
||||
const event: GeneralLifecycleEvent = {
|
||||
generalId: general.id,
|
||||
outcome: 'retired',
|
||||
before: general,
|
||||
after: general,
|
||||
year: 200,
|
||||
month: 1,
|
||||
};
|
||||
|
||||
await persistGeneralLifecycleEvents(
|
||||
prisma,
|
||||
[event],
|
||||
{ serverId: 'hall-fixture', season: 4, scenarioId: 22, isUnited: 0 },
|
||||
{}
|
||||
);
|
||||
|
||||
expect(hallCreateMany).toHaveBeenCalledWith({
|
||||
data: [
|
||||
expect.objectContaining({
|
||||
serverId: 'hall-fixture',
|
||||
season: 4,
|
||||
scenario: 22,
|
||||
generalNo: general.id,
|
||||
type: 'inherit_earned',
|
||||
value: 4_321,
|
||||
}),
|
||||
],
|
||||
skipDuplicates: true,
|
||||
});
|
||||
expect(prisma.rankData.updateMany).toHaveBeenCalledWith({
|
||||
where: { generalId: general.id },
|
||||
data: { value: 0 },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -214,6 +214,7 @@ describe('persistUnificationFinalization', () => {
|
||||
{ generalId: 1, type: 'firenum', value: 4 },
|
||||
{ generalId: 1, type: 'killcrew', value: 1_200 },
|
||||
{ generalId: 1, type: 'deathcrew', value: 800 },
|
||||
{ generalId: 1, type: 'inherit_earned', value: 4_321 },
|
||||
{ generalId: 1, type: 'ttw', value: 3 },
|
||||
{ generalId: 1, type: 'ttd', value: 2 },
|
||||
{ generalId: 1, type: 'ttl', value: 1 },
|
||||
@@ -268,6 +269,11 @@ describe('persistUnificationFinalization', () => {
|
||||
}),
|
||||
})
|
||||
);
|
||||
expect(hallCreate).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
data: expect.objectContaining({ type: 'inherit_earned', value: 4_321 }),
|
||||
})
|
||||
);
|
||||
expect(gameHistoryUpdate).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ data: expect.objectContaining({ winnerNation: 1 }) })
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user