You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
3.0 KiB
115 lines
3.0 KiB
let game = {
|
|
bac: 1000,
|
|
joueur: 100,
|
|
inGame: false,
|
|
mise: 0
|
|
}
|
|
|
|
const bacDom = document.getElementById("banque_score")
|
|
const joueurDom = document.getElementById("joueur_score")
|
|
const tirageDom = document.getElementById("tirage")
|
|
bacDom.innerText = game.bac
|
|
joueurDom.innerText = game.joueur
|
|
|
|
function nbAlea(){
|
|
return Math.floor(Math.random()*10);
|
|
}
|
|
|
|
// Anime les rouleaux
|
|
function rotate(rouleau, angle){
|
|
let i = 0;
|
|
let interval = setInterval(() => {
|
|
if (i >= angle){
|
|
rouleau.style.transform = 'rotate3d(1,0,0,'+angle+'deg)';
|
|
clearInterval(interval);
|
|
}
|
|
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(), nbAlea(), nbAlea()]
|
|
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));
|
|
return numbers
|
|
}
|
|
|
|
function jeu(){
|
|
if(game.inGame) return;
|
|
tirette()
|
|
|
|
game.mise = parseInt(document.getElementById("mise_input").value)
|
|
if(game.mise > 100 || game.mise < 0 || game.mise > game.joueur){
|
|
console.log("erreur: pas possible jouer")
|
|
return
|
|
}
|
|
game.joueur -= game.mise
|
|
game.bac += game.mise
|
|
|
|
let tirageNumbers = tirage() //[2,1,2]
|
|
//console.log(tirageNumbers)
|
|
tirageDom.innerText = tirageNumbers
|
|
|
|
let gain_retour = gain(tirageNumbers)
|
|
console.log(gain_retour)
|
|
game.bac -= gain_retour
|
|
bacDom.innerText = game.bac
|
|
game.joueur += gain_retour
|
|
joueurDom.innerText = game.joueur
|
|
|
|
if(game.bac < 500){
|
|
console.log("fin de partie")
|
|
}
|
|
}
|
|
|
|
function gain(tirage){
|
|
if(tirage[0] == 9 &&
|
|
tirage[1] == 9 &&
|
|
tirage[2] == 9){
|
|
return bac
|
|
}
|
|
else if(tirage[0] == tirage[1] &&
|
|
tirage[1] == tirage[2]){
|
|
return mise*6
|
|
}
|
|
else if(tirage[0] == tirage[1] ||
|
|
tirage[0] == tirage[2] ||
|
|
tirage[1] == tirage[2]){
|
|
return mise*3
|
|
}
|
|
return 0
|
|
}
|
|
function regles(){
|
|
//afficher règles
|
|
}
|
|
|
|
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)+')';
|
|
}
|
|
|
|
}
|
|
|