-
Notifications
You must be signed in to change notification settings - Fork 0
/
baseGame.js
76 lines (62 loc) · 2.27 KB
/
baseGame.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"use strict"
const prompt = require("prompt-sync");
class BaseGame {
constructor() {
this.playerOne = playerOne;
this.playerTwo = playerTwo;
this.gameRules = ("Each player picks a move: rock, paper, scissors, lizard, or Spock. The winner of the round is based on the following:\nRock crushes scissors, scissors cuts paper, paper covers rock, rock crushes lizard, lizard poisons Spock, Spock smashes scissors, scissors decapitates lizard, lizard eats paper, paper disproves Spock, Spock vaporizes rock.\nIf both players draw the same move, the round is marked as a tie. The first player to win 3 total rounds wins the game!");
}
displayWelcome() {
console.log("Welcome to Rock, Paper, Scissors, Lizard, Spock!");
}
determineNumberOfPlayers() {
const numberOfPlayers = prompt("How many players are there? (one, two)");
if (numberOfPlayers === "one") {
setName(playerOne);
let playerTwo = ComputerPlayer;
}
else if (numberOfPlayers === "two") {
setName(playerOne);
setName(playerTwo);
}
return numberOfPlayers;
}
diplayRules(gameRules) {
console.log(`How to play: ${gameRules}`);
prompt("Press any key to begin the game.");
}
runRounds() {
for(let i=0; i < 3; i++) {
let playerOneChoice = makeMove(playerOne);
let playerTwoChoice = makeMove(playerTwo);
if(numberOfPlayers = "one") {
let playerTwoChoice = computerMakeMove(gestures);
}
}
}
compareGestures() {
if(playerOneChoice === playerTwoChoice) {
console.log("Draw!");
}
// else if();
// else if();
// else if();
// else if();
// else if();
// else if();
// else if();
// else if();
// else if();
else {}
}
// checkWinner() return xyzResult
displayWinner(winnerName) {
console.log(`${winnerName} won 3 rounds and has won the game!`);
}
// runGame()
askToRestart(playAgain) {
const playAgain = prompt("Would you like to play again? (y/n)");
return playAgain;
}
}
module.exports = BaseGame;