bring server files into project.
This commit is contained in:
25
src/lib/server/Game.ts
Normal file
25
src/lib/server/Game.ts
Normal file
@ -0,0 +1,25 @@
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user