-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
77 lines (63 loc) · 1.59 KB
/
Copy pathscript.js
File metadata and controls
77 lines (63 loc) · 1.59 KB
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
"use strict";
var selection;
function shuffle() {
var ai = Math.floor(Math.random() * 3), play = ai === 0 ? "<img src='images/rock.png'>" : ai === 1 ? "<img src='images/paper.png'>" : "<img src='images/scissors.png'>";
$("#" + 0).removeClass("selected");
$("#" + 1).removeClass("selected");
$("#" + 2).removeClass("selected");
$("#" + ai).addClass("selected");
if (ai === selection) {
$("#result").html("Tie");
$("#you").addClass("winner");
$("#computer").addClass("winner");
}
else if (ai === 0) { //rock
if (selection === 1)
{
indicateWinner(true);
}
else if (selection === 2)
{
indicateWinner(false);
}
}
else if(ai == 1) //paper
{
if(selection == 0)
{
indicateWinner(false);
}
else if(selection == 2)
{
indicateWinner(true);
}
}
else if(ai == 2)
{
if(selection == 1)
{
indicateWinner(false);
}
else if(selection == 0)
{
indicateWinner(true);
}
}
}
function stuff(arg1)
{
selection = arg1;
$('#btnPlay').removeAttr('disabled');
$("#00").removeClass("selected");
$("#11").removeClass("selected");
$("#22").removeClass("selected");
}
function indicateWinner(you)
{
$("#you").removeClass("winner");
$("#computer").removeClass("winner");
if(you)
$("#you").addClass("winner");
else
$("#computer").addClass("winner");
}