feat: port monthly invader lifecycle

This commit is contained in:
2026-07-25 19:19:31 +00:00
parent 15713224f6
commit 7818b52d04
7 changed files with 1497 additions and 4 deletions
+19
View File
@@ -394,6 +394,7 @@ export const createDatabaseTurnHooks = async (
createdNations,
createdTroops,
createdDiplomacy,
createdEvents,
deletedEvents,
lifecycleEvents,
pendingNeutralAuctions,
@@ -592,6 +593,24 @@ export const createDatabaseTurnHooks = async (
data: createdDiplomacy.map(buildDiplomacyCreate),
});
}
if (createdEvents.length > 0) {
await prisma.event.createMany({
data: createdEvents.map((event) => ({
id: event.id,
targetCode: event.targetCode,
priority: event.priority,
condition: asJson(event.condition),
action: asJson(event.action),
meta: asJson(event.meta),
})),
});
await prisma.$queryRaw`
SELECT setval(
pg_get_serial_sequence('event', 'id'),
GREATEST((SELECT COALESCE(MAX(id), 1) FROM event), 1)
)
`;
}
if (deletedTroops.length > 0) {
await prisma.troop.deleteMany({
where: { troopLeaderId: { in: deletedTroops } },