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.
103 lines
2.7 KiB
103 lines
2.7 KiB
let bac = 1000
|
|
let joueur = 100
|
|
let mise
|
|
|
|
const bacDom = document.getElementById("banque_score")
|
|
const joueurDom = document.getElementById("joueur_score")
|
|
const tirageDom = document.getElementById("tirage")
|
|
bacDom.innerText = bac
|
|
joueurDom.innerText = joueur
|
|
|
|
|
|
|
|
function jeu(){
|
|
mise = parseInt(document.getElementById("input").value)
|
|
if(mise > 100 || mise < 0 || mise > joueur){
|
|
console.log("erreur: pas possible jouer")
|
|
return
|
|
}
|
|
joueur -= mise
|
|
bac += mise
|
|
|
|
|
|
let tirage = [2,1,2]//[nbAlea(), nbAlea(), nbAlea()];
|
|
tirageDom.innerText = tirage
|
|
|
|
|
|
|
|
let gain_retour = gain(tirage)
|
|
console.log(gain_retour)
|
|
bac -= gain_retour
|
|
bacDom.innerText = bac
|
|
joueur += gain_retour
|
|
joueurDom.innerText = joueur
|
|
|
|
if(bac < 500){
|
|
console.log("fin de partie")
|
|
}
|
|
}
|
|
|
|
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 &&
|
|
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
|
|
}
|
|
|
|
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);
|
|
// let i = 1;
|
|
// let interval = setInterval(() => {
|
|
// if(i >= angle) {
|
|
// clearInterval(interval); rouleau.style.transform = "rotate3d(1, 0, 0, "+angle+"deg)"
|
|
// }
|
|
// rouleau.style.transform = "rotate3d(1, 0, 0, "+i+"deg)"
|
|
// i += 5
|
|
// }, 1)
|
|
}
|
|
|
|
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()
|
|
|
|
function vw(v) {
|
|
var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
|
|
return (v * w) / 100;
|
|
}
|
|
|
|
window.onresize = () => {
|
|
let cubes = document.getElementsByClassName('cube__face')
|
|
for (var i = 0; i < 10; i++) {
|
|
/*window.getComputedStyle(cubes[i])*/cubes[i].style.transform =
|
|
'rotateX('+i*36+'deg) translateZ('+vw(3.4)*Math.tan(18 * Math.PI / 180)+')';
|
|
console.log(window.getComputedStyle(cubes[i]).transform)
|
|
}
|
|
}
|
|
|