/
index.html
179 lines (128 loc) · 3.41 KB
/
index.html
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<style>
body {
width: 100%;
margin: 0 auto;
text-align: center;
}
h1 {
font-family: helvetica;
font-size: 5em;
}
#button-options {
margin-top: 5em;
}
button {
width: 200px;
height: 100px;
border-radius: none;
border: 1px solid #cfcfcf;
background-color: white;
font-size: 2em;
font-family: helvetica;
color: #cfcfcf;
}
#playbtn {
margin-top: 3em;
}
#play {
background-color: lightgreen;
color: white;
}
#endResult {
font-size: 5em;
color: orange;
font-weight: bold;
font-family: helvetica;
margin-top: -.1em;
}
#compsays {
font-family: helvetica;
font-size: 3em;
font-weight: bold;
color: #cfcfcf;
}
#phrase {
margin-top: 1em;
}
#vs {
font-family: helvetica;
color: #cfcfcf;
font-weight: bold;
font-size: 2em;
}
</style>
</head>
<body>
<!--<h1>Rock, Paper, Sissors!</h1>-->
<div id="button-options">
<button id="rock" onclick='choose("rock")'> ROCK </button>
<button id="paper" onclick='choose("paper")'> PAPER </button>
<button id="sissors" onclick='choose("scissors")'> SCISSORS </button>
</div>
<p id="vs">VS.</p>
<!-- <div id="playbtn">
<button id="play" onClick='compare(user, computerChoice)'> START! </button>
</div>-->
<div id="compsays">
<span id="compchoice"> </span>
</div>
<div id="answer">
<p id="endResult"></p>
</div>
<script type="text/javascript">
// alert("part 1")
function choose(whatTheHellTheyChose){
var computerChoice = Math.random();
console.log(computerChoice);
if (computerChoice <= 0.33) {
computerChoice = "rock";
}
else if (computerChoice >= 0.34 && computerChoice <= 0.66) {
computerChoice = "paper";
}
else {
computerChoice = "scissors";
}
document.getElementById("compchoice").innerHTML = '<span id="phrase"The computer picked</span> <img id="answer" src="images/'+computerChoice+'.jpg">';
compare(whatTheHellTheyChose, computerChoice);
}
// alert("part 2")
var compare = function(choice1, choice2) {
if (choice1 === choice2) {
document.getElementById("endResult").innerHTML = "Try again, we tied.";
}
else if (choice1 === "rock") {
if (choice2 === "scissors") {
document.getElementById("endResult").innerHTML = "You Win!";
}
else {
document.getElementById("endResult").innerHTML = "You Lose Sucka!";
}
}
else if (choice1 === "paper") {
if (choice2 === "rock") {
document.getElementById("endResult").innerHTML = "You Win!";
}
else if (choice2 ==="scissors") {
document.getElementById("endResult").innerHTML = "You Lose Sucka!";
}
}
else if (choice1 === "scissors") {
if (choice2 === "rock") {
document.getElementById("endResult").innerHTML = "You Win!";
}
else if (choice2 === "paper") {
document.getElementById("endResult").innerHTML = "You Lose Sucka!";
}
}
else {
document.getElementById("endResult").innerHTML = "ERROR!";
}
}
</script>
</body>
</html>