51 lines
1.8 KiB
JavaScript
51 lines
1.8 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;
|
|
}
|
|
|
|
create() {
|
|
const slugDispatch = { backgammon: 'Backgammon', holdem: 'HoldemGame', blackjack: 'BlackjackGame', parchisi: 'ParchisiGame', yatzi: 'YatziGame', skipbo: 'SkipBoGame', phase10: 'Phase10Game', chinesecheckers: 'ChineseCheckersGame', gofish: 'GoFishGame', uno: 'UnoGame' };
|
|
if (slugDispatch[this.game.slug]) {
|
|
this.scene.start(slugDispatch[this.game.slug], {
|
|
game: this.game,
|
|
opponents: this.opponents,
|
|
playfield: this.playfield,
|
|
cardBack: this.cardBack,
|
|
});
|
|
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'));
|
|
}
|
|
}
|