v1.3.0: per-player money & reputation in engine + actions (ISS-110)
CI / build + unit + e2e (pull_request) Successful in 13m20s

This commit is contained in:
2026-09-26 17:03:15 +00:00
parent 306f81aec6
commit d00a012c4b
14 changed files with 153 additions and 35 deletions
+7 -7
View File
@@ -2,10 +2,10 @@ import { eq } from 'drizzle-orm';
import type { GameDb } from './client';
import * as schema from './schema';
// v1.0.0 (ISS-105): TEMPORARY single-player economy access — resolves the local player row so all
// pre-multiplayer code keeps working while `account` is replaced by `players`. A later step
// parameterizes these by playerId for real multiplayer; until then every read/write of the
// singleton economy goes through this file and nowhere else.
// v1.0.0 (ISS-105): single-player economy access — resolves the seeded local player row. As of
// v1.3.0 (ISS-110) every per-player read/write goes through getPlayer/updatePlayerEconomy below;
// these 'local' helpers remain ONLY for world-level reads with no acting session (the engine's
// shared-pool spawn quality, the SSE broadcast account) and env-gated /api/test/* admin hooks.
export const LOCAL_PLAYER = { id: 'local', provider: 'local', username: 'kamilkrzywda' } as const;
@@ -22,9 +22,9 @@ export async function updateLocalPlayerEconomy(
await inst.db.update(schema.players).set(patch).where(eq(schema.players.id, LOCAL_PLAYER.id));
}
// v1.2.0 (ISS-109): per-player variants — the actions thread the session player's id through and
// read/write THAT row instead of the local one; getLocalPlayer stays for the snapshot/engine until
// per-player views land in a later multiplayer step.
// v1.2.0 (ISS-109), standard path since v1.3.0 (ISS-110): actions, engine delivery/top-up and
// session-scoped snapshots thread the acting player's id through and read/write THAT row; the
// 'local' helpers above are reserved for world-level reads with no acting session.
export async function getPlayer(inst: GameDb, id: string): Promise<schema.PlayerRow> {
const [row] = await inst.db.select().from(schema.players).where(eq(schema.players.id, id));
if (!row) throw new Error(`player ${id} missing`);