gaia-project/viewer/vitest.setup.ts
coyotte508 49fc40dc40 feat(engine): simultaneous sealed bidding - any order, hidden until all in (BGS contract)
- engine.sealedBidPendingSeats(): seats still owing a bid (undefined outside bid phases)
- move()/loadTurnMoves: accept silentBid/preferenceBid from ANY pending seat regardless of
  playerToMove (was: strict turn-order assert -> 'not your turn to play' for off-turn bidders)
- bid phases resolve on the LAST pending bid, not on the sequential turn walk
- move() attributes the log line to the actual bidder, not playerToMove
- wrapper.currentPlayer() returns number[] of pending seats during bid phases (the platform's
  /move route authorizes any seat in game.currentPlayers, which it fills from currentPlayer())
- deterministic auction tiebreaks (last faction-nominator wins) replace the seeded PRNG, so the
  resolution no longer needs map.rng - which crashed hosted simultaneous bidding on a reloaded
  engine ('map.rng is not a function'); bids + nominations alone now reproduce the result
- viewer: SealedBidPanel drops the waiting-for-turn gate (every pending seat bids at once) and
  seat-prefixes the emitted move so the engine can parse the bidder

engine 4.12.0, viewer 5.16.0
2026-09-08 10:03:24 +02:00

33 lines
1.5 KiB
TypeScript

// vue-cli's mocha setup (mocha-webpack) ran specs against jsdom with localstorage enabled and
// chai's expect available globally. Vitest bundles expect itself; chai's deep-equal style
// assertions in the existing specs import chai explicitly - keep that working plus a DOM root.
import { expect } from "vitest";
// jsdom's localStorage is intermittently broken in this environment (getItem/setItem missing on
// `window.localStorage`). Several stores read/write it at module scope, so install a tiny in-memory
// polyfill whenever the real one is absent or non-functional.
(() => {
const broken =
typeof globalThis.localStorage === "undefined" || typeof globalThis.localStorage.getItem !== "function";
if (!broken) {
return;
}
const store = new Map<string, string>();
const ls = {
getItem: (k: string) => (store.has(String(k)) ? (store.get(String(k)) as string) : null),
setItem: (k: string, v: string) => void store.set(String(k), String(v)),
removeItem: (k: string) => void store.delete(String(k)),
clear: () => store.clear(),
key: (i: number) => Array.from(store.keys())[i] ?? null,
get length() {
return store.size;
},
};
for (const target of [globalThis, ...(typeof window !== "undefined" ? [window] : [])] as any[]) {
Object.defineProperty(target, "localStorage", { value: ls, configurable: true, writable: true });
}
})();
// Some specs mount components into document.body (launcher.spec.ts uses unique ids);
// jsdom provides the DOM. Nothing else needed globally - chai is imported per-spec.
export { expect };