feat(engine): finalize unification archives atomically

This commit is contained in:
2026-07-31 14:10:22 +00:00
parent 8ea8e6e26f
commit 02515303fd
20 changed files with 1516 additions and 843 deletions
+1
View File
@@ -16,4 +16,5 @@ export * from './turnDaemon/types.js';
export * from './realtime/keys.js';
export * from './realtime/types.js';
export * from './ranking/types.js';
export * from './ranking/legacyColor.js';
export * from './auth/accountIconProjection.js';
@@ -0,0 +1,23 @@
const LEGACY_WHITE_TEXT_COLORS = new Set([
'',
'#330000',
'#FF0000',
'#800000',
'#A0522D',
'#FF6347',
'#808000',
'#008000',
'#2E8B57',
'#008080',
'#6495ED',
'#0000FF',
'#000080',
'#483D8B',
'#7B68EE',
'#800080',
'#A9A9A9',
'#000000',
]);
export const resolveLegacyTextColor = (backgroundColor: string): '#ffffff' | '#000000' =>
LEGACY_WHITE_TEXT_COLORS.has(backgroundColor.toUpperCase()) ? '#ffffff' : '#000000';
+13
View File
@@ -416,6 +416,19 @@ model Emperor {
@@map("emperior")
}
model UnificationFinalization {
generationKey String @id @map("generation_key")
serverId String @unique @map("server_id")
profileName String @map("profile_name")
winnerNation Int @map("winner_nation")
year Int
month Int
completedAt DateTime @map("completed_at")
createdAt DateTime @default(now()) @map("created_at")
@@map("unification_finalization")
}
model Troop {
troopLeaderId Int @id @map("troop_leader")
nationId Int @map("nation")
@@ -0,0 +1,24 @@
ALTER TABLE "ng_old_nations"
ALTER COLUMN "server_id" TYPE TEXT;
ALTER TABLE "ng_old_generals"
ALTER COLUMN "server_id" TYPE TEXT;
ALTER TABLE "emperior"
ALTER COLUMN "server_id" TYPE TEXT;
CREATE TABLE "unification_finalization" (
"generation_key" TEXT NOT NULL,
"server_id" TEXT NOT NULL,
"profile_name" TEXT NOT NULL,
"winner_nation" INTEGER NOT NULL,
"year" INTEGER NOT NULL,
"month" INTEGER NOT NULL,
"completed_at" TIMESTAMP(3) NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "unification_finalization_pkey" PRIMARY KEY ("generation_key")
);
CREATE UNIQUE INDEX "unification_finalization_server_id_key"
ON "unification_finalization" ("server_id");
+1
View File
@@ -310,6 +310,7 @@ export interface TurnEngineNationUpdateInput {
chiefGeneralId: number | null;
gold: number;
rice: number;
tech: number;
level: number;
typeCode: string;
meta: InputJsonValue;