v1.5.0: shared-world spawn quality rule — max reputation across players (ISS-111)
CI / build + unit + e2e (pull_request) Successful in 13m53s

This commit is contained in:
2026-09-26 19:07:50 +00:00
parent c3fa5bf613
commit eae680c002
6 changed files with 79 additions and 17 deletions
+12 -4
View File
@@ -1,12 +1,12 @@
import { eq } from 'drizzle-orm';
import { eq, max } from 'drizzle-orm';
import type { GameDb } from './client';
import * as schema from './schema';
// 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 — pools are SHARED state, so the seeded row sets job quality) and
// env-gated /api/test/* admin hooks. Since v1.4.0 (ISS-112) even the SSE broadcast is per-player.
// these 'local' helpers remain ONLY for env-gated /api/test/* admin hooks that stage the SEEDED
// account with no acting session. Since v1.4.0 (ISS-112) even the SSE broadcast is per-player, and
// since v1.5.0 (ISS-111) shared-world job quality reads getSharedWorldReputation instead of a row.
export const LOCAL_PLAYER = { id: 'local', provider: 'local', username: 'kamilkrzywda' } as const;
@@ -39,3 +39,11 @@ export async function updatePlayerEconomy(
): Promise<void> {
await inst.db.update(schema.players).set(patch).where(eq(schema.players.id, id));
}
// v1.5.0 (ISS-111), the #101 decision point resolved: shared-world job quality is the MAX
// reputation across ALL player rows — spawned pool packages scale to the best-progressed player so
// nobody is stuck on low-rep jobs. 0 when there are no players (repRate floors at ×1 either way).
export async function getSharedWorldReputation(inst: GameDb): Promise<number> {
const [row] = await inst.db.select({ m: max(schema.players.reputation) }).from(schema.players);
return row?.m ?? 0;
}