Le meilleur casino du web
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.

131 lines
2.9 KiB

3 years ago
//let machine_sous = new Object();
let argent = 100
let nombres = []
let bank = 1000
let mise
let gains = 0
function saisie(){
if (argent>0){
mise = document.getElementById("mise").value;
bank+=Number(mise);
argent-=Number(mise);
gain(nombres);
}
else{
console.log("PLUS DE SOUS")
}
}
function gain(nb){
if (nb[1]==nb[2] && nb[2]==nb[3] && nb[3]==9) {
argent+=bank;
bank-=bank;
gains+=bank;
console.log("Bingo");
}
else if(nb[1]==nb[2] && nb[2]==nb[3]){
argent+=6*Number(mise);
bank-=6*Number(mise);
gains+=6*Number(mise);
console.log("trois égaux");
}
else if(nb[1]==nb[2]||nb[2]==nb[3]||nb[3]==nb[1]){
argent+=3*Number(mise);
bank-=3*Number(mise);
gains+=3*Number(mise);
console.log("deux égaux");
}
else{
console.log("aucun égaux");
}
affiche();
}
function affiche(){
console.log('Vous avez gagné %d jetons', gains);
console.log('\nIl vous reste %d jetons, et il reste %d jetons dans le bac de la machine.\n', argent, bank);
gains=0;
3 years ago
}
const items = [
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
];
const doors = document.querySelectorAll(".door");
document.querySelector("#spinner").addEventListener("click", spin);
//document.querySelector("#reseter").addEventListener("click", init);
async function spin() {
init(false, 1, 2);
if(argent>0){
for (const door of doors) {
const boxes = door.querySelector(".boxes");
const duration = parseInt(boxes.style.transitionDuration);
boxes.style.transform = "translateY(0)";
await new Promise((resolve) => setTimeout(resolve, duration * 100));
}
3 years ago
}
}
function init(firstInit, groups, duration) {
for (const door of doors) {
const boxes = door.querySelector(".boxes");
const boxesClone = boxes.cloneNode(false);
const pool = ["?"];
3 years ago
if (!firstInit) {
const arr = [];
for (let n = 0; n < (groups > 0 ? groups : 1); n++) {
arr.push(...items);
}
pool.push(...shuffle(arr));
boxesClone.addEventListener(
"transitionend",
function () {
this.querySelectorAll(".box").forEach((box, index) => {
box.style.filter = "blur(0)";
if (index > 0) this.removeChild(box);
});
},
);
}
for (let i = pool.length - 1; i >= 0; i--) {
const box = document.createElement("div");
box.classList.add("box");
box.style.height = door.clientHeight + "px";
box.textContent = pool[i];
boxesClone.appendChild(box);
}
boxesClone.style.transitionDuration = `${duration > 0 ? duration : 1}s`;
boxesClone.style.transform = `translateY(-${door.clientHeight * (pool.length - 1)}px)`;
door.replaceChild(boxesClone, boxes);
nombres.push(pool[9]);
}
console.log(nombres);
saisie()
nombres = [];
document.getElementById("bank_val").innerHTML=bank;
document.getElementById("argent_val").innerHTML=argent;
3 years ago
}
function shuffle([...arr]) {
let m = arr.length;
while (m) {
const i = Math.floor(Math.random() * m--);
[arr[m], arr[i]] = [arr[i], arr[m]];
}
return arr;
}