Mystery Chest

Each person will have a mysterious chest on their map, in a random place:
Cofre misterioso
If you have some coins left over
you could try your luck and open the chest. For each failed attempt to open the chest, the odds will increase and so will the loot contained in the chest.
Once the chest is opened, it will return to its original state with an initial chance and 10 Coins
We want to be as transparent as possible and for this reason we will publish the code that we use to calculate the probability of opening the chest.
EThe code has been modified in such a way, so that when the chest reaches a certain amount of Coins
it almost certainly starts playing even with a low probability.
function openChest(probability) {
let arr = Array(400).fill(0);
for (let i = 0; i < probability*4; i++) {
let randomIndex = Math.floor(Math.random() * 400);
arr[randomIndex] = 1;
let randomIndex = Math.floor(Math.random() * arr.length);
return arr[randomIndex] === 1;
If you think that we are miscalculating the result or you want to include some improvement in the code, do not hesitate to contact us.
Última actualización 1mo ago