feat: add dynasty management features including list and detail views
- Implemented `OldNation`, `OldGeneral`, and `Emperor` models in Prisma schema. - Created API routes for fetching dynasty lists and details. - Developed frontend views for displaying dynasty list and detail information. - Enhanced in-memory world to track deleted nation snapshots during unification. - Added functionality to settle dynasty information after unification events.
This commit is contained in:
@@ -193,6 +193,81 @@ model GameHistory {
|
||||
@@map("ng_games")
|
||||
}
|
||||
|
||||
model OldNation {
|
||||
id Int @id @default(autoincrement())
|
||||
serverId String @map("server_id")
|
||||
nation Int @default(0)
|
||||
data Json @default(dbgenerated("'{}'::jsonb"))
|
||||
date DateTime @default(now())
|
||||
|
||||
@@unique([serverId, nation])
|
||||
@@index([serverId, nation], name: "by_server")
|
||||
@@map("ng_old_nations")
|
||||
}
|
||||
|
||||
model OldGeneral {
|
||||
id Int @id @default(autoincrement())
|
||||
serverId String @map("server_id")
|
||||
generalNo Int @map("general_no")
|
||||
owner String? @map("owner")
|
||||
name String
|
||||
lastYearMonth Int @map("last_yearmonth")
|
||||
turnTime DateTime @map("turntime")
|
||||
data Json @default(dbgenerated("'{}'::jsonb"))
|
||||
|
||||
@@unique([serverId, generalNo], name: "by_no")
|
||||
@@index([serverId, name], name: "by_name")
|
||||
@@index([owner, serverId], name: "owner")
|
||||
@@map("ng_old_generals")
|
||||
}
|
||||
|
||||
model Emperor {
|
||||
id Int @id @default(autoincrement()) @map("no")
|
||||
serverId String? @map("server_id")
|
||||
phase String? @default("")
|
||||
nationCount String? @map("nation_count")
|
||||
nationName String? @map("nation_name")
|
||||
nationHist String? @map("nation_hist")
|
||||
genCount String? @map("gen_count")
|
||||
personalHist String? @map("personal_hist")
|
||||
specialHist String? @map("special_hist")
|
||||
name String? @default("")
|
||||
type String? @default("")
|
||||
color String? @default("")
|
||||
year Int? @default(0)
|
||||
month Int? @default(0)
|
||||
power Int? @default(0)
|
||||
gennum Int? @default(0)
|
||||
citynum Int? @default(0)
|
||||
pop String? @default("0")
|
||||
poprate String? @default("")
|
||||
gold Int? @default(0)
|
||||
rice Int? @default(0)
|
||||
l12name String? @default("")
|
||||
l12pic String? @default("")
|
||||
l11name String? @default("")
|
||||
l11pic String? @default("")
|
||||
l10name String? @default("")
|
||||
l10pic String? @default("")
|
||||
l9name String? @default("")
|
||||
l9pic String? @default("")
|
||||
l8name String? @default("")
|
||||
l8pic String? @default("")
|
||||
l7name String? @default("")
|
||||
l7pic String? @default("")
|
||||
l6name String? @default("")
|
||||
l6pic String? @default("")
|
||||
l5name String? @default("")
|
||||
l5pic String? @default("")
|
||||
tiger String? @default("")
|
||||
eagle String? @default("")
|
||||
gen String? @default("")
|
||||
history Json @default(dbgenerated("'{}'::jsonb"))
|
||||
aux Json @default(dbgenerated("'{}'::jsonb"))
|
||||
|
||||
@@map("emperior")
|
||||
}
|
||||
|
||||
model Troop {
|
||||
troopLeaderId Int @id @map("troop_leader")
|
||||
nationId Int @map("nation")
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
CREATE TABLE IF NOT EXISTS "ng_old_nations" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"server_id" VARCHAR(20) NOT NULL DEFAULT '0',
|
||||
"nation" INT NOT NULL DEFAULT 0,
|
||||
"data" JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
"date" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "ng_old_nations_server_id_nation" ON "ng_old_nations" ("server_id", "nation");
|
||||
CREATE INDEX IF NOT EXISTS "ng_old_nations_by_server" ON "ng_old_nations" ("server_id", "nation");
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "ng_old_generals" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"server_id" VARCHAR(20) NOT NULL,
|
||||
"general_no" INT NOT NULL,
|
||||
"owner" TEXT NULL,
|
||||
"name" VARCHAR(32) NOT NULL,
|
||||
"last_yearmonth" INT NOT NULL,
|
||||
"turntime" TIMESTAMP NOT NULL,
|
||||
"data" JSONB NOT NULL DEFAULT '{}'::jsonb
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "ng_old_generals_by_no" ON "ng_old_generals" ("server_id", "general_no");
|
||||
CREATE INDEX IF NOT EXISTS "ng_old_generals_by_name" ON "ng_old_generals" ("server_id", "name");
|
||||
CREATE INDEX IF NOT EXISTS "ng_old_generals_owner" ON "ng_old_generals" ("owner", "server_id");
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "emperior" (
|
||||
"no" SERIAL PRIMARY KEY,
|
||||
"server_id" VARCHAR(20) NULL DEFAULT '',
|
||||
"phase" VARCHAR(255) NULL DEFAULT '',
|
||||
"nation_count" VARCHAR(64) NULL DEFAULT '',
|
||||
"nation_name" TEXT NULL DEFAULT '',
|
||||
"nation_hist" TEXT NULL DEFAULT '',
|
||||
"gen_count" VARCHAR(64) NULL DEFAULT '',
|
||||
"personal_hist" TEXT NULL DEFAULT '',
|
||||
"special_hist" TEXT NULL DEFAULT '',
|
||||
"name" VARCHAR(64) NULL DEFAULT '',
|
||||
"type" VARCHAR(64) NULL DEFAULT '',
|
||||
"color" VARCHAR(7) NULL DEFAULT '',
|
||||
"year" INT NULL DEFAULT 0,
|
||||
"month" INT NULL DEFAULT 0,
|
||||
"power" INT NULL DEFAULT 0,
|
||||
"gennum" INT NULL DEFAULT 0,
|
||||
"citynum" INT NULL DEFAULT 0,
|
||||
"pop" VARCHAR(255) NULL DEFAULT '0',
|
||||
"poprate" VARCHAR(255) NULL DEFAULT '',
|
||||
"gold" INT NULL DEFAULT 0,
|
||||
"rice" INT NULL DEFAULT 0,
|
||||
"l12name" VARCHAR(64) NULL DEFAULT '',
|
||||
"l12pic" VARCHAR(32) NULL DEFAULT '',
|
||||
"l11name" VARCHAR(64) NULL DEFAULT '',
|
||||
"l11pic" VARCHAR(32) NULL DEFAULT '',
|
||||
"l10name" VARCHAR(64) NULL DEFAULT '',
|
||||
"l10pic" VARCHAR(32) NULL DEFAULT '',
|
||||
"l9name" VARCHAR(64) NULL DEFAULT '',
|
||||
"l9pic" VARCHAR(32) NULL DEFAULT '',
|
||||
"l8name" VARCHAR(64) NULL DEFAULT '',
|
||||
"l8pic" VARCHAR(32) NULL DEFAULT '',
|
||||
"l7name" VARCHAR(64) NULL DEFAULT '',
|
||||
"l7pic" VARCHAR(32) NULL DEFAULT '',
|
||||
"l6name" VARCHAR(64) NULL DEFAULT '',
|
||||
"l6pic" VARCHAR(32) NULL DEFAULT '',
|
||||
"l5name" VARCHAR(64) NULL DEFAULT '',
|
||||
"l5pic" VARCHAR(32) NULL DEFAULT '',
|
||||
"tiger" VARCHAR(128) NULL DEFAULT '',
|
||||
"eagle" VARCHAR(128) NULL DEFAULT '',
|
||||
"gen" TEXT NULL DEFAULT '',
|
||||
"history" JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
"aux" JSONB NOT NULL DEFAULT '{}'::jsonb
|
||||
);
|
||||
@@ -14,6 +14,9 @@ export interface DatabaseClient {
|
||||
rankData: GamePrisma.RankDataDelegate;
|
||||
hallOfFame: GamePrisma.HallOfFameDelegate;
|
||||
gameHistory: GamePrisma.GameHistoryDelegate;
|
||||
oldNation: GamePrisma.OldNationDelegate;
|
||||
oldGeneral: GamePrisma.OldGeneralDelegate;
|
||||
emperor: GamePrisma.EmperorDelegate;
|
||||
generalTurn: GamePrisma.GeneralTurnDelegate;
|
||||
nationTurn: GamePrisma.NationTurnDelegate;
|
||||
troop: GamePrisma.TroopDelegate;
|
||||
|
||||
Reference in New Issue
Block a user