fix inheritance accounting for unowned generals

This commit is contained in:
2026-07-27 09:16:25 +00:00
parent 9614ba69f6
commit 12ac9c5f4d
4 changed files with 133 additions and 119 deletions
@@ -145,6 +145,7 @@ export const projectCoreDatabaseSnapshot = (rows: {
atmos: row.atmos,
age: row.age,
npcState: row.npcState,
hasOwner: typeof row.userId === 'string' && row.userId.length > 0,
turnTime: row.turnTime instanceof Date ? serializeDate(row.turnTime) : row.turnTime,
recentWarTime: row.recentWarTime instanceof Date ? serializeDate(row.recentWarTime) : row.recentWarTime,
lastTurn: row.lastTurn,
@@ -249,6 +249,7 @@ const buildGeneral = (row: Record<string, unknown>, fallbackTurnTime: Date): Tur
atmos: readNumber(row, 'atmos'),
age: readNumber(row, 'age', 30),
npcState: readNumber(row, 'npcState'),
userId: row.hasOwner === true ? 'turn-differential-owner' : null,
penalty: row.penalty,
triggerState: { flags: {}, counters: {}, modifiers: {}, meta: {} },
meta: {
@@ -585,6 +586,7 @@ const projectWorld = (
atmos: toDatabaseInt(general.atmos),
age: general.age,
npcState: general.npcState,
hasOwner: Boolean(general.userId),
turnTime: general.turnTime.toISOString(),
recentWarTime: general.recentWarTime?.toISOString() ?? null,
lastTurn: general.lastTurn ?? null,