feat: 국가 멸망 처리 로직 추가 및 관련 테스트 케이스 작성

This commit is contained in:
2026-01-24 18:47:25 +00:00
parent 5627c80f4a
commit cc797c185d
3 changed files with 343 additions and 0 deletions
+18
View File
@@ -241,6 +241,7 @@ export const createDatabaseTurnHooks = async (
troops,
deletedTroops,
deletedGenerals,
deletedNations,
diplomacy,
logs,
createdGenerals,
@@ -309,6 +310,23 @@ export const createDatabaseTurnHooks = async (
});
}
if (deletedNations.length > 0) {
await prisma.diplomacy.deleteMany({
where: {
OR: [
{ srcNationId: { in: deletedNations } },
{ destNationId: { in: deletedNations } },
],
},
});
await prisma.nationTurn.deleteMany({
where: { nationId: { in: deletedNations } },
});
await prisma.nation.deleteMany({
where: { id: { in: deletedNations } },
});
}
await Promise.all([
...generals
.filter((general) => !createdIds.has(general.id))