-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathslider.html
201 lines (182 loc) · 8.11 KB
/
slider.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
<!DOCTYPE html>
<html lang="fr">
<head>
<!-- Basic Page Needs
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta charset="utf-8">
<title>Choix du niveau</title>
<meta name="description" content="Kataku">
<meta name="author" content="LFB">
<!-- Mobile Specific Metas
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<!-- CSS
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/skeleton.css">
<!-- JS
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/alasql/0.6.1/alasql.min.js"></script>
<script src="js/ktk.js"></script>
<script src="js/img.js"></script>
<!-- Favicon
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="icon" type="image/png" href="assets/icon.png">
<link rel="apple-touch-icon" href="assets/icon192.png">
</head>
<body scroll="no" style="overflow: hidden">
<!-- Primary Page Layout
––––––––––––––––––––––––––––––––––––––––––––––––––-->
<div class="mainContainer">
<div class="menu">
<h5 id='titreMenu' style="margin-top:6%; width: 100%; white-space: nowrap;">On se met comment ?</h5>
<div style="width: 100%; max-height: 30vh;">
<img class="brainlet" src="assets/intensite/bouteille4.png" id='CetteSouffrance'>
</div>
<div style="width: 100%; font-size:1.5rem;" id='scoreChoisi'>- Festif -</div>
<input type="range" min="0" max="11" step="1" value="4" id='scoreSale'>
<div class='row' style='width: 100%; z-index: 10;'>
<button class="button-primary" style="padding: 0px 10px;" onclick="{
document.body.style.opacity = 0;
setTimeout(() => {
window.location.href = 'index.html';
}, 500);
}">
<</button> <button class="button-primary" onclick="GOjeu()">- Suivant -
</button>
</div>
<div class="logoktk">
<img class='logobot' src="assets/logo_kataku_transpar.png" />
</div>
</div>
</div>
<script>
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function array_move(arr, old_index, new_index) {
while (old_index < 0) {
old_index += arr.length;
}
while (new_index < 0) {
new_index += arr.length;
}
if (new_index >= arr.length) {
var k = new_index - arr.length + 1;
while (k--) {
arr.push(undefined);
}
}
arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
}
</script>
<script>
var codeActif;
if (localStorage.getItem('linkCode') == null || assocCode[localStorage.getItem('linkCode')] == undefined) {
codeActif = assocCode['classique']
} else {
codeActif = assocCode[localStorage.getItem('linkCode')]
}
</script>
<script>
var palliers = ['Doux', 'Ouvert', 'Osé', 'Joueur',
'Festif', 'Ambitieux', 'Stupide', 'Sans amour propre', 'Oubli',
'Misère', '911', 'Kataku.'
]
var slider = document.getElementById("scoreSale");
var output = document.getElementById("scoreChoisi");
slider.oninput = function () {
output.innerHTML = "- " + String(palliers[this.value]) + " -";
document.getElementById("CetteSouffrance").src = "assets/intensite/bouteille" + (parseInt(this.value) + 1) +
".png"
}
function GOjeu() {
function buildDeck(intens, idgroupe) {
var intensi_loc = "(" + String(intens) + ",0)";
let dbBrut = JSON.parse(localStorage.getItem("contenu"))
let LSTvirus = alasql("SELECT * from ? WHERE groupe in " + idgroupe + " AND type = 3 AND intens in " +
intensi_loc, [dbBrut]);
let LSTvotes = alasql("SELECT * from ? WHERE groupe in " + idgroupe + " AND type = 5 AND intens in " +
intensi_loc, [dbBrut]);
let LSTactions = alasql("SELECT * from ? WHERE groupe in " + idgroupe + " AND type = 1 AND intens in " +
intensi_loc, [dbBrut]);
let LSTequiv = alasql("SELECT * from ? WHERE groupe in " + idgroupe + " AND type in (2,4) AND intens in " +
intensi_loc, [
dbBrut
]);
let LSTzeroes = alasql("SELECT * from ? WHERE groupe in " + idgroupe + " AND intens = 0 ", [
dbBrut
]);
console.log(LSTzeroes)
for (let i = LSTactions.length - 1; i >= 17; --i) {
LSTactions.splice(Math.floor(Math.random() * LSTactions.length), 1)
}
for (let i = LSTvotes.length - 1; i >= 8; --i) {
LSTvotes.splice(Math.floor(Math.random() * LSTvotes.length), 1)
}
for (let i = LSTvirus.length - 1; i >= 4; --i) {
LSTvirus.splice(Math.floor(Math.random() * LSTvirus.length), 1)
}
let deckFinal = [];
let ActionEtVote = LSTactions.concat(LSTvotes)
let compte = 0
while (ActionEtVote.length > 0) {
position = Math.floor(Math.random() * ActionEtVote.length)
if (deckFinal.length == 0 || ActionEtVote[position].titre != deckFinal[deckFinal.length - 1].titre) {
deckFinal.push(ActionEtVote[position])
ActionEtVote.splice(position, 1)
} else {
compte++
}
if (compte == 40) {
break
}
}
for (let carte in LSTvirus) {
let posivir = getRandomInt(10, deckFinal.length)
deckFinal.splice(posivir, 0, LSTvirus[carte])
deckFinal.splice(posivir - getRandomInt(5, 8), 0, LSTequiv.filter(cartee => cartee.id == LSTvirus[carte]
.id_phrase)[0])
}
if (intens > 6) {
deckFinal.splice(Math.round(deckFinal.length * 0.25), 0, LSTzeroes.filter(cartee => cartee.id == 1)[0]);
deckFinal.splice(Math.round(deckFinal.length * 0.5), 0, LSTzeroes.filter(cartee => cartee.id == 1)[0]);
deckFinal.splice(Math.round(deckFinal.length * 0.75), 0, LSTzeroes.filter(cartee => cartee.id == 1)[0]);
deckFinal.unshift(LSTzeroes.filter(cartee => cartee.id == 3)[0]);
deckFinal.push(LSTzeroes.filter(cartee => cartee.id == 2)[0]);
}
deckFinal.push({
id: 001,
titre: "Fin",
text: "Bravo, c'est la fin. <br> Pensez à boire de l'eau aussi.. <br><br><span style='opacity:.6;font-size:16px'>(swipe pour retourner au menu)</span>",
intens: 0,
type: 0,
id_image: 60
})
for (let i = deckFinal.length - 1; i >= 0; i--) {
if (deckFinal[i].type == 5) {
deckFinal.splice(i, 0, LSTequiv.filter(cartee => cartee.id == deckFinal[i].id_phrase)[0])
}
}
localStorage.setItem("deckJeu", JSON.stringify(deckFinal))
}
buildDeck((parseInt(slider.value) + 1), codeActif['grpCarte'])
localStorage.setItem('intens', parseInt(slider.value) + 1);
//console.log(localStorage.getItem("deckJeu"))
document.body.style.transform = "rotateY(-90deg)";
setTimeout(() => {
window.location.href = 'jeu.html';
}, 500);
}
</script>
<script>
window.history.pushState("null", "null", "/")
</script>
<!-- End Document
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
</body>
</html>