Skip to content

Commit 2efe429

Browse files
committed
CG-0MM3B510O0P25F1S: Migrate The Mind to shared setup helpers
Replace TheMindSetupOptions interface with MultiplayerSetupOptions type alias and use resolveSetupOptions() with hardcoded playerCount: 2. Update test to expect shared default names ('Player 1', 'Player 2') instead of game-specific defaults ('Player', 'AI'). All 308 The Mind tests pass.
1 parent 88525fb commit 2efe429

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

example-games/the-mind/TheMindGameState.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import { Pile } from '../../src/card-system/Pile';
1717
import type { MindCard } from './MindCard';
1818
import { createMindDeck, shuffleDeck } from './MindCard';
1919

20+
import type { MultiplayerSetupOptions } from '../../src/core-engine/SetupOptions';
21+
import { resolveSetupOptions } from '../../src/core-engine/SetupOptions';
22+
2023
// ---------------------------------------------------------------------------
2124
// Constants
2225
// ---------------------------------------------------------------------------
@@ -60,14 +63,7 @@ export interface PlayResult {
6063
}
6164

6265
/** Setup options for creating a new game session. */
63-
export interface TheMindSetupOptions {
64-
/** Names for the two players. Defaults to ['Player', 'AI']. */
65-
playerNames?: [string, string];
66-
/** Which players are AI-controlled. Defaults to [false, true]. */
67-
isAI?: [boolean, boolean];
68-
/** Random number generator (injectable for tests). */
69-
rng?: () => number;
70-
}
66+
export type TheMindSetupOptions = MultiplayerSetupOptions;
7167

7268
/** Per-player state. */
7369
export interface MindPlayerState {
@@ -103,14 +99,15 @@ export interface TheMindSession {
10399
export function setupTheMindGame(
104100
options?: TheMindSetupOptions,
105101
): TheMindSession {
106-
const names = options?.playerNames ?? ['Player', 'AI'];
107-
const isAI = options?.isAI ?? [false, true];
108-
const rng = options?.rng ?? Math.random;
102+
const { players: playerInfos, rng } = resolveSetupOptions({
103+
...options,
104+
playerCount: 2,
105+
});
109106

110107
const session: TheMindSession = {
111108
players: [
112-
{ name: names[0], isAI: isAI[0], hand: [] },
113-
{ name: names[1], isAI: isAI[1], hand: [] },
109+
{ name: playerInfos[0].name, isAI: playerInfos[0].isAI, hand: [] },
110+
{ name: playerInfos[1].name, isAI: playerInfos[1].isAI, hand: [] },
114111
],
115112
pile: new Pile<MindCard>(),
116113
currentLevel: 0, // Will be set by dealLevel

tests/the-mind/game-state.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ describe('setupTheMindGame', () => {
6060

6161
it('uses default player names', () => {
6262
const session = setupTheMindGame({ rng: createSeededRng(1) });
63-
expect(session.players[0].name).toBe('Player');
64-
expect(session.players[1].name).toBe('AI');
63+
expect(session.players[0].name).toBe('Player 1');
64+
expect(session.players[1].name).toBe('Player 2');
6565
});
6666

6767
it('uses custom player names', () => {

0 commit comments

Comments
 (0)