-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.js
118 lines (116 loc) · 4.94 KB
/
events.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
//instructions events
$(document).ready(function(){
//green buttons on click
$("#playerGreenB").click(function(){
$("#enemyGreenB").attr('disabled', 'true');
$("#playerRedB").attr('disabled', 'true');
$("#playerBlueB").attr('disabled', 'true');
$("#playerYellowB").attr('disabled', 'true');
$("#playerTeam").text("green");
$("#fakeDice").attr('class', 'btn btn-success');
});
$("#enemyGreenB").click(function(){
$("#playerGreenB").attr('disabled', 'true');
$("#enemyRedB").attr('disabled', 'true');
$("#enemyBlueB").attr('disabled', 'true');
$("#enemyYellowB").attr('disabled', 'true');
$("#enemyTeam").text("green");
});
//red buttons on click
$("#playerRedB").click(function(){
$("#enemyRedB").attr('disabled', 'true');
$("#playerGreenB").attr('disabled', 'true');
$("#playerBlueB").attr('disabled', 'true');
$("#playerYellowB").attr('disabled', 'true');
$("#playerTeam").text("red");
$("#fakeDice").attr('class', 'btn btn-danger');
});
$("#enemyRedB").click(function(){
$("#playerRedB").attr('disabled', 'true');
$("#enemyGreenB").attr('disabled', 'true');
$("#enemyBlueB").attr('disabled', 'true');
$("#enemyYellowB").attr('disabled', 'true');
$("#enemyTeam").text("red");
});
//blue buttons on click
$("#playerBlueB").click(function(){
$("#enemyBlueB").attr('disabled', 'true');
$("#playerGreenB").attr('disabled', 'true');
$("#playerRedB").attr('disabled', 'true');
$("#playerYellowB").attr('disabled', 'true');
$("#playerTeam").text("blue");
$("#fakeDice").attr('class', 'btn btn-primary');
});
$("#enemyBlueB").click(function(){
$("#playerBlueB").attr('disabled', 'true');
$("#enemyGreenB").attr('disabled', 'true');
$("#enemyRedB").attr('disabled', 'true');
$("#enemyYellowB").attr('disabled', 'true');
$("#enemyTeam").text("blue");
});
//yellow buttons on click
$("#playerYellowB").click(function(){
$("#enemyYellowB").attr('disabled', 'true');
$("#playerGreenB").attr('disabled', 'true');
$("#playerRedB").attr('disabled', 'true');
$("#playerBlueB").attr('disabled', 'true');
$("#playerTeam").text("yellow");
$("#fakeDice").attr('class', 'btn btn-warning');
});
$("#enemyYellowB").click(function(){
$("#playerYellowB").attr('disabled', 'true');
$("#enemyGreenB").attr('disabled', 'true');
$("#enemyRedB").attr('disabled', 'true');
$("#enemyBlueB").attr('disabled', 'true');
$("#enemyTeam").text("yellow");
});
$("#closeInstructions").click(function(){
initGame();
});
$("#closeInstructions2").click(function(){
initGame();
});
$("#goBack1").click(function(){
window.history.back();
});
$("#goBack2").click(function(){
window.history.back();
});
$("#goBack3").click(function(){
window.history.back();
});
$("#goBack4").click(function(){
window.history.back();
});
$("#dice").click(function(){
$("#dice").attr('disabled', 'true');
});
});
function initGame()
{
var enemyColor = $("#enemyTeam").text();
var playerColor = $("#playerTeam").text();
if( enemyColor.length < 1 || playerColor.length < 1)
{
location.reload();
}
else
{
if( playerColor === "green" )
{
$("#dice").attr('class', 'btn btn-success');
}
else if(playerColor === "red" )
{
$("#dice").attr('class', 'btn btn-danger');
}
else if(playerColor === "blue" )
{
$("#dice").attr('class', 'btn btn-primary');
}
else if(playerColor === "yellow" )
{
$("#dice").attr('class', 'btn btn-warning');
}
}
}