-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_game.js
45 lines (41 loc) · 1.02 KB
/
_game.js
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
35
36
37
38
39
40
41
42
43
44
45
//Require Dependencies
var Word = require('./_word.js');
//Game Constructor
var Game = function(){
this.word = new Word();
this.remainingGuesses = 10;
this.setUpGame = function(){
this.word.getNewWord();
};
this.guess = function(letter){
var incorrect = this.word.incorrectGuess(letter)
//Runs the incorrectGuess function on the Word.
//If incorrect (true) decrease remaining guesses.
if (incorrect) {
this.remainingGuesses--
} else if (!incorrect){
//Do nothing.
} else {
console.log(this.word.incorrectGuess(letter))
}
//console.log(this.word.guessedLetters)
this.update();
};
this.update = function(){
console.log(this.word.display() + ' Guesses Remaining: ' + this.remainingGuesses);
}
};
//Export Module
module.exports = Game;
//Testing Game Module
// var game = new Game();
// game.setUpGame()
// game.guess('t');
// game.guess('a');
// game.guess('i');
// game.guess('b');
// game.guess('o');
// game.guess('p');
// game.guess('r');
// game.guess('w');
// console.log(game.remainingGuesses);