-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathgame_command_handler.js
More file actions
33 lines (28 loc) · 960 Bytes
/
game_command_handler.js
File metadata and controls
33 lines (28 loc) · 960 Bytes
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
const CommandHandler = require ("./command_handler");
const GuessingGame = require ('../games/guessing_game');
const GAME_GUESS_NUM = 0;
module.exports = class GameCommandHandler extends CommandHandler {
constructor(gameSessions) {
super('game');
this.games = [];
this.initCommands();
this.gameSessions = gameSessions
}
initCommands() {
this.games[GAME_GUESS_NUM] = false;
super.addCommand(
"guess-num",
"Begins a very fun session of guessing numbers",
">game guess-num",
this.guessNumber.bind(this)
)
}
guessNumber(message) {
if (!this.games[GAME_GUESS_NUM]) {
this.games[GAME_GUESS_NUM] = true;
this.gameSessions.push(new GuessingGame(message.channel, this.gameSessions));
return;
}
message.channel.send("Sorry but guessing number game is already active.");
}
};