forked from MathisHammel/RotINSA
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroti.html
292 lines (222 loc) · 8.5 KB
/
roti.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Rôti</title>
<link rel="stylesheet" href="font-awesome-4.6.3/css/font-awesome.min.css">
<meta name="description" content="La rôtisserie en ligne">
<meta name="author" content="Des gens rôti">
<link href='https://fonts.googleapis.com/css?family=Noto+Sans:400,700' rel='stylesheet' type='text/css'>
<!--Import Google Icon Font-->
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="materialize/css/materialize.min.css" media="screen,projection" />
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="roti.css">
<link rel="apple-touch-icon-precomposed" sizes="57x57" href="favicon/apple-touch-icon-57x57.png" />
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="favicon/apple-touch-icon-114x114.png" />
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="favicon/apple-touch-icon-72x72.png" />
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="favicon/apple-touch-icon-144x144.png" />
<link rel="apple-touch-icon-precomposed" sizes="60x60" href="favicon/apple-touch-icon-60x60.png" />
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="favicon/apple-touch-icon-120x120.png" />
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="favicon/apple-touch-icon-76x76.png" />
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="favicon/apple-touch-icon-152x152.png" />
<link rel="icon" type="image/png" href="favicon/favicon-196x196.png" sizes="196x196" />
<link rel="icon" type="image/png" href="favicon/favicon-96x96.png" sizes="96x96" />
<link rel="icon" type="image/png" href="favicon/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="favicon/favicon-16x16.png" sizes="16x16" />
<link rel="icon" type="image/png" href="favicon/favicon-128.png" sizes="128x128" />
<meta name="application-name" content=" " />
<meta name="msapplication-TileColor" content="#FFFFFF" />
<meta name="msapplication-TileImage" content="favicon/mstile-144x144.png" />
<meta name="msapplication-square70x70logo" content="favicon/mstile-70x70.png" />
<meta name="msapplication-square150x150logo" content="favicon/mstile-150x150.png" />
<meta name="msapplication-wide310x150logo" content="favicon/mstile-310x150.png" />
<meta name="msapplication-square310x310logo" content="favicon/mstile-310x310.png" />
<script type="text/javascript" src="loadCard.js"></script>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="vignette"></div>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="materialize/js/materialize.min.js"></script>
<div class="container">
<div class="center-block">
<div class="flip-container" onclick='turn()' ;>
<div class="flipper" id="flip">
<div class="front" id="front">
<div class="card suitregle">
<p> <b>Règles</b> : Chaque rôti tire une carte à tour de role dans le sens des aiguilles d'une montre.
</p>
</div>
</div>
<div class="back" id="back">
<div class="card suitregle">
<p> Un <i class="fa fa-beer" aria-hidden="true"></i> indique un shot de boisson. Chacun est libre de boire ce qu'il veut, du moment que ça rend rôti. <br/> <b> Bon Rôtissage !</b>
</p>
</div>
</div>
</div>
</div>
</div>
<p class="player-name" id="player-box" style="visibility: hidden;">Tour de : <span id="player-name"></span></p>
<div class="center-item">
<a class="waves-effect waves-light btn green lighten-1" onclick='turn();'>rôti-moi ! </a>
</div>
<div class="center-item">
<a class="waves-effect waves-light btn green lighten-1" href="index.html">Retour au choix de deck</a>
</div>
<div class="modal" id="deckend">
<div class="modal-content">
<h4>Fin du deck ! </h4>
<p>Tout le monde perd son rôle et toutes les règles sont annulés ! C'est reparti pour un tour !</p>
</div>
<div class="modal-footer">
<a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">Let's rôti !</a>
</div>
<div class="modal-footer">
<a href="http://kara71.github.io/RotINSA/" class=" modal-action modal-close waves-effect waves-green btn-flat">Je veux me rôtir autrement !</a>
</div>
</div>
</div>
<script type="text/javascript">
function escapeHtml(text) {
var map = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": '''
};
return text.replace(/[&<>"']/g, function(m) {
return map[m];
});
}
var count = 1;
var block = true;
var json = [];
var total_cards = [];
var deck = [];
var joueurs = JSON.parse(localStorage.getItem("joueurs"));
if (!joueurs) {
joueurs = ["Bob", "Alice", "Fred"];
}
playerTurn = Math.floor((Math.random() * (joueurs.length)));
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
// Charger le fichier de cartes
// TODO : Charger le nom du fichier à partir de la barre d'adresse
file = getUrlParameter("deck");
if (!file) {
file = localStorage.getItem("deck");
if (!file) {
file = "template.json";
}
}
file = "decks/" + file;
$.getJSON(file, function(data) {
json = data;
total_cards = json.cards;
/*for (var i = 0; i < deck.length / 10; i++)
{
deck.push(
{
"type":"action",
"content":"Toutes les règles en cours sont annulés."
}
);
}*/
deck = randomDeck(total_cards.slice());
block = false;
});
var showModalNextTurn = false;
var skipNextTurn = 0;
var turnPlayed = 0;
function turn() {
// Attentre que block soit dispo (pour eviter de tourner plusieurs cartes en même temps)
if (!block) {
// Attendre 2 tours avant de show les noms de gens
turnPlayed++;
if (turnPlayed == 2) {
$("#player-box").removeAttr("style");
}
block = true;
$("#player-name").html(escapeHtml(joueurs[playerTurn]));
// Gerer le sautage de tours
playerTurn = (playerTurn + skipNextTurn) % joueurs.length;
if (skipNextTurn != 1) {
skipNextTurn = 1;
}
if (showModalNextTurn == true) {
$("#deckend").openModal();
showModalNextTurn = false;
}
// Si le deck est vide, le recharger
if (deck.length == 0) {
deck = randomDeck(total_cards.slice());
showModalNextTurn = true;
}
// Faire tourner la carte
$("#flip").addClass('rotate');
// Attendre la fin de l'animation
$("#flip").one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',
function(e) {
// Copier la carte au back sur le front
$("#front").html($("#back").html());
// Enlever la rotation (la carte front repasse devant)
$("#flip").removeClass('rotate');
// Charger ici le back de la prochaine carte à jouer (back)
var id = Math.floor((Math.random() * (deck.length)));
loadCard("#back .card", deck, id);
// Verifier qu'il n'y à pas de noturn sur la carte
if (typeof deck[id].skipTurn != 'undefined') {
skipNextTurn = deck[id].skipTurn;
}
// Enlever la carte du deck
if (deck[id].count && deck[id].count > 1) {
deck[id].count--;
} else {
deck.splice(id, 1);
}
block = false;
});
}
};
function shuffle(array) {
var currentIndex = array.length,
temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
function randomDeck(original) {
rand = shuffle(original)
if (rand.length > 52) {
rand = rand.slice(0, 52);
}
return rand;
}
</script>
</body>
</html>