feat: port monthly invader lifecycle
This commit is contained in:
@@ -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 } },
|
||||
|
||||
Reference in New Issue
Block a user