-
Notifications
You must be signed in to change notification settings - Fork 0
/
javascript.js
143 lines (116 loc) · 3.46 KB
/
javascript.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
var playerScore = 0;
var evylenScore = 0;
var roundNumber = 1;
function evylenMove(){
//gives evylen random numbers to choose from and prompts
//the player for a choice
const evylenOptions = [ 0, 1, 2];
const evylen = Math.floor(Math.random() *3);
const evylenChoice = evylenOptions[evylen];
const message = "which do you choose";
const playerChoice = prompt(message);
var playerHex = " ";
//convert playerChoice into numbers for Evylen to chew on
if (playerChoice === "rock") {
playerHex = "0";
}
if (playerChoice === "paper") {
playerHex = "1";
}
if (playerChoice === "scissors") {
playerHex = "2";
}
//evylen's choice converted from number to string for human chewing
if (evylenChoice == 0) {
console.log("Evylen chose" + " rock");
}
else if(evylenChoice == 1) {
console.log("Evylen chose" + " paper");
}
else if(evylenChoice == 2) {
console.log("Evylen chose" + " scissors");
}
if (playerHex === "0") {
console.log("you chose rock");
}
else if (playerHex === "1") {
console.log("you chose paper");
}
else if (playerHex === "2") {
console.log("you chose scissors")
}
//DETERMINE WINRAR
if (playerHex == "0" && evylenChoice == "2") {
console.log("WINNER");
playerScore += 1;
playGame();
}
else if (playerHex == "1" && evylenChoice == "0"){
console.log("WINNER");
playerScore += 1;
playGame();
}
else if (playerHex == "2" && evylenChoice == "1"){
console.log("WINNER");
playerScore += 1;
playGame();
}
if (evylenChoice == "0" && playerHex == "2") {
console.log("LOSER");
evylenScore += 1;
playGame();
}
else if (evylenChoice == "1" && playerHex == "0"){
console.log("LOSER");
evylenScore += 1;
}
else if (evylenChoice == "2" && playerHex== "1"){
console.log("LOSER");
evylenScore += 1;
}
else if (evylenChoice == playerHex) {
console.log("tie! try again")
}
}
function playAgain(){
const playAgainMessage = "Take another Whack at it?";
evylenMove();
nextLevel();
gameOver();
}
function nextLevel(){
if (playerScore < 5) {
playAgain();
}
}
function gameOver() {
if (evylenScore, playerScore >= 5) {
console.log("Game Over!");
console.log("Evylen scored " + evylenScore + " points!");
console.log("you scored " + playerScore + " points!");
}
if (evylenScore > playerScore && evylenScore == 5) {
alert("YOU LOST. REFRESH THE PAGE TO TRY AGAIN...");
evylenScore, playerScore = 0;
roundNumber = 1;
}
else if (playerScore > evylenScore && playerScore ==5) {
alert("YOU WON! CONGRATULATIONS! REFRESH THE PAGE TO TRY AGAIN!!!");
evylenScore, playerScore = 0;
roundNumber = 1;
}
}
function playGame(playerHex, evylenChoice) {
console.log(playerScore);
}
function diceRoll() {
const d20 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
const roll = Math.floor(Math.random()*19);
const result = d20[roll];
console.log(result);
}
evylenMove();
diceRoll();
nextLevel();
playGame();
gameOver();