|
@ -5,9 +5,11 @@ let game = { |
|
|
mise: 0 |
|
|
mise: 0 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const bacDom = document.getElementById("banque_score") |
|
|
const bacDom = document.getElementById("banque_score") |
|
|
const joueurDom = document.getElementById("joueur_score") |
|
|
const joueurDom = document.getElementById("joueur_score") |
|
|
const tirageDom = document.getElementById("tirage") |
|
|
const input = document.getElementById("mise_input"); |
|
|
|
|
|
input.value = game.mise |
|
|
bacDom.innerText = game.bac |
|
|
bacDom.innerText = game.bac |
|
|
joueurDom.innerText = game.joueur |
|
|
joueurDom.innerText = game.joueur |
|
|
|
|
|
|
|
@ -17,6 +19,7 @@ function nbAlea(){ |
|
|
|
|
|
|
|
|
// Anime les rouleaux
|
|
|
// Anime les rouleaux
|
|
|
function rotate(rouleau, angle){ |
|
|
function rotate(rouleau, angle){ |
|
|
|
|
|
<<<<<<< HEAD |
|
|
let i = 0; |
|
|
let i = 0; |
|
|
let interval = setInterval(() => { |
|
|
let interval = setInterval(() => { |
|
|
if (i >= angle){ |
|
|
if (i >= angle){ |
|
@ -27,6 +30,22 @@ function rotate(rouleau, angle){ |
|
|
rouleau.style.transform = 'rotate3d(1,0,0,'+i+'deg)'; |
|
|
rouleau.style.transform = 'rotate3d(1,0,0,'+i+'deg)'; |
|
|
} |
|
|
} |
|
|
}, 5); |
|
|
}, 5); |
|
|
|
|
|
======= |
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
|
let i = 0; |
|
|
|
|
|
let interval = setInterval(() => { |
|
|
|
|
|
if (i >= angle){ |
|
|
|
|
|
rouleau.style.transform = 'rotate3d(1,0,0,'+angle+'deg)'; |
|
|
|
|
|
clearInterval(interval); |
|
|
|
|
|
resolve() |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
i += 9; |
|
|
|
|
|
rouleau.style.transform = 'rotate3d(1,0,0,'+i+'deg)'; |
|
|
|
|
|
} |
|
|
|
|
|
}, 5); |
|
|
|
|
|
}) |
|
|
|
|
|
>>>>>>> ed8a1808293ee88f1efde28836b84c43b34781eb |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -48,30 +67,40 @@ function tirette(){ |
|
|
}, 20); |
|
|
}, 20); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function tirage(){ |
|
|
async function tirage(){ |
|
|
let numbers = [nbAlea(), nbAlea(), nbAlea()] |
|
|
let numbers = [nbAlea(), nbAlea(), nbAlea()] |
|
|
|
|
|
<<<<<<< HEAD |
|
|
console.log(numbers); |
|
|
console.log(numbers); |
|
|
rotate(document.getElementsByClassName("cube")[0], Math.floor(Math.random()*(15-1)+1)*360 - numbers[0]*36); |
|
|
rotate(document.getElementsByClassName("cube")[0], Math.floor(Math.random()*(15-1)+1)*360 - numbers[0]*36); |
|
|
rotate(document.getElementsByClassName("cube")[1], Math.floor(Math.random()*(15-1)+1)*360 - numbers[1]*36); |
|
|
rotate(document.getElementsByClassName("cube")[1], Math.floor(Math.random()*(15-1)+1)*360 - numbers[1]*36); |
|
|
rotate(document.getElementsByClassName("cube")[2], Math.floor(Math.random()*(15-1)+1)*360 - numbers[2]*36); |
|
|
rotate(document.getElementsByClassName("cube")[2], Math.floor(Math.random()*(15-1)+1)*360 - numbers[2]*36); |
|
|
|
|
|
======= |
|
|
|
|
|
await Promise.all([ |
|
|
|
|
|
rotate(document.getElementsByClassName("cube")[0], (Math.floor(Math.random()*15)*360) - (numbers[0]*36)), |
|
|
|
|
|
rotate(document.getElementsByClassName("cube")[1], (Math.floor(Math.random()*15)*360) - (numbers[1]*36)), |
|
|
|
|
|
rotate(document.getElementsByClassName("cube")[2], (Math.floor(Math.random()*15)*360) - (numbers[2]*36)) |
|
|
|
|
|
]) |
|
|
|
|
|
>>>>>>> ed8a1808293ee88f1efde28836b84c43b34781eb |
|
|
return numbers |
|
|
return numbers |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function jeu(){ |
|
|
async function jeu(){ |
|
|
if(game.inGame) return; |
|
|
if(game.inGame) return; |
|
|
tirette() |
|
|
game.inGame = true |
|
|
|
|
|
|
|
|
game.mise = parseInt(document.getElementById("mise_input").value) |
|
|
//game.mise = parseInt(document.getElementById("mise_input").value)
|
|
|
if(game.mise > 100 || game.mise < 0 || game.mise > game.joueur){ |
|
|
if(game.mise > 100 || game.mise < 0 || game.mise > game.joueur){ |
|
|
console.log("erreur: pas possible jouer") |
|
|
console.log("erreur: pas possible jouer") |
|
|
|
|
|
game.inGame = false |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
tirette() |
|
|
game.joueur -= game.mise |
|
|
game.joueur -= game.mise |
|
|
game.bac += game.mise |
|
|
game.bac += game.mise |
|
|
|
|
|
|
|
|
let tirageNumbers = tirage() //[2,1,2]
|
|
|
let tirageNumbers = await tirage() //[2,1,2]
|
|
|
//console.log(tirageNumbers)
|
|
|
//console.log(tirageNumbers)
|
|
|
tirageDom.innerText = tirageNumbers |
|
|
document.getElementById("tirage").innerText = tirageNumbers |
|
|
|
|
|
|
|
|
let gain_retour = gain(tirageNumbers) |
|
|
let gain_retour = gain(tirageNumbers) |
|
|
console.log(gain_retour) |
|
|
console.log(gain_retour) |
|
@ -80,9 +109,10 @@ function jeu(){ |
|
|
game.joueur += gain_retour |
|
|
game.joueur += gain_retour |
|
|
joueurDom.innerText = game.joueur |
|
|
joueurDom.innerText = game.joueur |
|
|
|
|
|
|
|
|
if(game.bac < 500){ |
|
|
console.log(game.mise) |
|
|
console.log("fin de partie") |
|
|
input |
|
|
} |
|
|
if(game.bac < 500) console.log("fin de partie") |
|
|
|
|
|
if(!game.jouer <= 0) game.inGame = false |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function gain(tirage){ |
|
|
function gain(tirage){ |
|
@ -106,6 +136,15 @@ function regles(){ |
|
|
//afficher règles
|
|
|
//afficher règles
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
input.addEventListener("input", (e)=>{ |
|
|
|
|
|
let inputMise = e.target.value; |
|
|
|
|
|
if(isNaN(inputMise)) e.target.value = game.mise; //autre que 0-9 entré
|
|
|
|
|
|
else if(parseInt(e.target.value) > 100) {e.target.value = 100; game.mise = 100;} //sup à 100
|
|
|
|
|
|
else if(inputMise == "") game.mise = 0 |
|
|
|
|
|
else game.mise = parseInt(e.target.value); //nbr entre 0-9
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < 10; i++) { |
|
|
for (let i = 0; i < 10; i++) { |
|
|
//console.log(i);
|
|
|
//console.log(i);
|
|
|
for (var j = 0; j < 3; j++) { |
|
|
for (var j = 0; j < 3; j++) { |
|
|