Files
jamoke/src/lib/server/Game.ts

26 lines
455 B
TypeScript

import type { Id } from "./Id";
import type { GameData } from "../GameData";
import type { State } from "../State";
export class Game implements GameData {
players: Id[];
isStarted: boolean;
state: State;
constructor() {
this.players = [];
this.isStarted = false;
this.state = {};
}
addPlayer(id: Id) {
this.players.push(id);
}
start() {
if (this.isStarted) throw new Error("game is already started");
this.isStarted = true;
}
}