|
|
@ -1,12 +1,3 @@ |
|
|
|
for (let i = 0; i < 10; i++) { |
|
|
|
console.log(i); |
|
|
|
for (var j = 0; j < 3; j++) { |
|
|
|
console.log(j); |
|
|
|
document.getElementsByClassName('cube__face--'+i)[j].style.transform = 'rotateX('+(i*36)+'deg) translateZ(calc(1.6vw /'+Math.tan(18* Math.PI / 180)+')'; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
let bac = 1000 |
|
|
|
let joueur = 100 |
|
|
|
let mise |
|
|
@ -17,10 +8,53 @@ const tirageDom = document.getElementById("tirage") |
|
|
|
bacDom.innerText = bac |
|
|
|
joueurDom.innerText = joueur |
|
|
|
|
|
|
|
function nbAlea(){ |
|
|
|
return Math.floor(Math.random()*9); |
|
|
|
} |
|
|
|
|
|
|
|
// Anime les rouleaux
|
|
|
|
function rotate(rouleau, angle){ |
|
|
|
let i = 0; |
|
|
|
let id = setInterval(() => { |
|
|
|
if (i >= angle) clearInterval(id); |
|
|
|
else { |
|
|
|
i += 9; |
|
|
|
rouleau.style.transform = 'rotate3d(1,0,0,'+i+'deg)'; |
|
|
|
} |
|
|
|
}, 5); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Anime la tirette
|
|
|
|
function tirette(){ |
|
|
|
let i = 0; |
|
|
|
let id = setInterval(() => { |
|
|
|
if (i > 360) clearInterval(id); |
|
|
|
else { |
|
|
|
if (i > 180){ |
|
|
|
document.getElementById('tirette').style.transform = 'rotate3d(1,0,0,'+(360-i)+'deg)'; |
|
|
|
} |
|
|
|
else { |
|
|
|
document.getElementById('tirette').style.transform = 'rotate3d(1,0,0,'+i+'deg)'; |
|
|
|
} |
|
|
|
i += 9; |
|
|
|
} |
|
|
|
}, 20); |
|
|
|
} |
|
|
|
|
|
|
|
function tirage(){ |
|
|
|
let numbers = [nbAlea()+1, nbAlea()+1, nbAlea()+1] |
|
|
|
console.log(numbers) |
|
|
|
rotate(document.getElementsByClassName("cube")[0], Math.floor(Math.random() * 15)*360+(numbers[0]-1)*36) |
|
|
|
rotate(document.getElementsByClassName("cube")[1], Math.floor(Math.random() * 15)*360+(numbers[1]-1)*36) |
|
|
|
rotate(document.getElementsByClassName("cube")[2], Math.floor(Math.random() * 15)*360+(numbers[2]-1)*36) |
|
|
|
return numbers |
|
|
|
} |
|
|
|
|
|
|
|
function jeu(){ |
|
|
|
mise = parseInt(document.getElementById("input").value) |
|
|
|
tirette() |
|
|
|
|
|
|
|
mise = parseInt(document.getElementById("mise_input").value) |
|
|
|
if(mise > 100 || mise < 0 || mise > joueur){ |
|
|
|
console.log("erreur: pas possible jouer") |
|
|
|
return |
|
|
@ -28,13 +62,11 @@ function jeu(){ |
|
|
|
joueur -= mise |
|
|
|
bac += mise |
|
|
|
|
|
|
|
let tirageNumbers = tirage() //[2,1,2]
|
|
|
|
console.log(tirageNumbers) |
|
|
|
tirageDom.innerText = tirageNumbers |
|
|
|
|
|
|
|
let tirage = [2,1,2]//[nbAlea(), nbAlea(), nbAlea()];
|
|
|
|
tirageDom.innerText = tirage |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let gain_retour = gain(tirage) |
|
|
|
let gain_retour = gain(tirageNumbers) |
|
|
|
console.log(gain_retour) |
|
|
|
bac -= gain_retour |
|
|
|
bacDom.innerText = bac |
|
|
@ -46,10 +78,6 @@ function jeu(){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function nbAlea(){ |
|
|
|
let multiples = [36,72,108,144,180,216,252,288,324] |
|
|
|
return multiples[Math.floor(Math.random()*9)]; |
|
|
|
} |
|
|
|
function gain(tirage){ |
|
|
|
if(tirage[0] == 9 && |
|
|
|
tirage[1] == 9 && |
|
|
@ -71,40 +99,11 @@ function regles(){ |
|
|
|
//afficher règles
|
|
|
|
} |
|
|
|
|
|
|
|
// Anime les rouleaux
|
|
|
|
function rotate(rouleau, angle){ |
|
|
|
let i = 0; |
|
|
|
let id = setInterval(() => { |
|
|
|
if (i >= angle) clearInterval(id); |
|
|
|
else { |
|
|
|
i += 9; |
|
|
|
rouleau.style.transform = 'rotate3d(1,0,0,'+i+'deg)'; |
|
|
|
} |
|
|
|
}, 5); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Anime la tirette
|
|
|
|
function tirette(){ |
|
|
|
let i = 0; |
|
|
|
let id = setInterval(() => { |
|
|
|
if (i > 360) clearInterval(id); |
|
|
|
else { |
|
|
|
if (i > 180){ |
|
|
|
document.getElementById('tirette').style.transform = 'rotate3d(1,0,0,'+(360-i)+'deg)'; |
|
|
|
} |
|
|
|
else { |
|
|
|
document.getElementById('tirette').style.transform = 'rotate3d(1,0,0,'+i+'deg)'; |
|
|
|
} |
|
|
|
i += 9; |
|
|
|
|
|
|
|
for (let i = 0; i < 10; i++) { |
|
|
|
//console.log(i);
|
|
|
|
for (var j = 0; j < 3; j++) { |
|
|
|
//console.log(j);
|
|
|
|
document.getElementsByClassName('cube__face--'+i)[j].style.transform = 'rotateX('+(i*36)+'deg) translateZ(calc(1.6vw /'+Math.tan(18* Math.PI / 180)+')'; |
|
|
|
} |
|
|
|
}, 20); |
|
|
|
} |
|
|
|
|
|
|
|
function tirage(){ |
|
|
|
rotate(document.getElementsByClassName("cube")[0], Math.floor(Math.random() * 15)*360+nbAlea()) |
|
|
|
rotate(document.getElementsByClassName("cube")[1], Math.floor(Math.random() * 15)*360+nbAlea()) |
|
|
|
rotate(document.getElementsByClassName("cube")[2], Math.floor(Math.random() * 15)*360+nbAlea()) |
|
|
|
} |
|
|
|
tirage() |
|
|
|