-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.ts
34 lines (27 loc) · 894 Bytes
/
demo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Game from './lib/Game';
import Player from './lib/Player';
/*
* This file is just to give an idea of how one might implement a game using this library
*/
// TODO implement
const ui: any = {
getPlayers: () => [ new Player(), new Player()],
};
// Create game
const game = new Game(ui.getPlayers());
// Game turn loop
while (!game.over()) {
// Make user select placement option
ui.displayTileOptions(game.turn.placementOptions);
const option = ui.getUserInput(game.turn.player);
const placement = game.turn.placementOptions[option];
// Prompt followers
if (ui.askIfTheyWantToAddFollower()) {
const option = ui.displayFollowerOptions(placement.getFollowerOptions());
placement.setFollower(placement.getFollowerOptions()[option]);
}
// Execute turn
game.turn.act(placement);
}
// TODO
// ui.displayScore(game.calculateScore());