fertig-classic-games/public/src/scenes/GameRoomScene.js

61 lines
2.7 KiB
JavaScript

import * as Phaser from 'phaser';
import { GAME_HEIGHT, GAME_WIDTH, COLORS } from '../config.js';
import { Button } from '../ui/Button.js';
// Generic room shell. Dispatches to the concrete game scene
// (Backgammon, Blackjack, etc.) based on `data.game.slug`.
export default class GameRoomScene extends Phaser.Scene {
constructor() { super('GameRoom'); }
init(data) {
this.game = data.game;
this.opponents = data.opponents ?? [];
this.playfield = data.playfield ?? null;
this.cardBack = data.cardBack ?? null;
this.tilePlacement = data.tilePlacement ?? 'standard';
this.expansion = data.expansion ?? 'base';
this.scenario = data.scenario ?? null;
this.deckMode = data.deckMode ?? 'standard';
this.wordLength = data.wordLength ?? 4;
}
create() {
const slugDispatch = { backgammon: 'Backgammon', holdem: 'HoldemGame', blackjack: 'BlackjackGame', parchisi: 'ParchisiGame', yatzi: 'YatziGame', skipbo: 'SkipBoGame', phase10: 'Phase10Game', chinesecheckers: 'ChineseCheckersGame', gofish: 'GoFishGame', uno: 'UnoGame', craps: 'CrapsGame', roulette: 'RouletteGame', mexicantrain: 'MexicanTrainGame', hearts: 'HeartsGame', catan: 'CatanGame', nerts: 'NertsGame', bingo: 'BingoGame', baccarat: 'BaccaratGame', dominion: 'DominionGame', checkers: 'CheckersGame', chess: 'ChessGame', wordle: 'WordleGame', scrabble: 'ScrabbleGame', ghost: 'GhostGame', wordladder: 'WordLadderGame', wordsearch: 'WordSearchGame' };
if (slugDispatch[this.game.slug]) {
this.scene.start(slugDispatch[this.game.slug], {
game: this.game,
opponents: this.opponents,
playfield: this.playfield,
cardBack: this.cardBack,
tilePlacement: this.tilePlacement,
expansion: this.expansion,
scenario: this.scenario,
deckMode: this.deckMode,
wordLength: this.wordLength,
});
return;
}
const cx = GAME_WIDTH / 2;
this.add.text(cx, 80, `${this.game.name}`, {
fontFamily: 'Righteous',
fontSize: '52px',
color: COLORS.textHex,
}).setOrigin(0.5);
this.add.text(cx, 150, 'Single-player table',
{ fontSize: '24px', color: COLORS.mutedHex }).setOrigin(0.5);
// Placeholder table felt
this.add.rectangle(cx, GAME_HEIGHT / 2 + 40, 1400, 700, 0x14532d).setStrokeStyle(4, COLORS.accent);
this.add.text(cx, GAME_HEIGHT / 2 + 40, `${this.game.name} board placeholder\n(game logic plugs in here)`, {
fontFamily: '"Julius Sans One"',
fontSize: '28px',
color: COLORS.mutedHex,
align: 'center',
}).setOrigin(0.5);
new Button(this, cx, GAME_HEIGHT - 100, 'Leave table', () => this.scene.start('GameMenu'));
}
}