feat: 국가 멸망 처리 로직 추가 및 관련 테스트 케이스 작성
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user