Fixed Golden Cookie percentage calculation to cdf #921 (#1190)

* Added cummulative probability handling

* executed build-dev command

* executed build-final command
This commit is contained in:
Numbernaut
2024-09-08 11:17:00 +02:00
committed by GitHub
parent ca1c28d1fc
commit 9e98208c19
8 changed files with 70 additions and 6 deletions

View File

@@ -0,0 +1,50 @@
/**
* The probability that a GC or reindeer has NOT spawned
*/
let chanceTotal = 1.0;
let chanceTotalDeer = 1.0;
export function resetChanceTotal() {
chanceTotal = 1.0;
}
export function resetChanceTotalDeer() {
chanceTotalDeer = 1.0;
}
export function getChanceTotal() {
return chanceTotal;
}
export function getChanceTotalDeer() {
return chanceTotalDeer;
}
/**
* Update the probability that a cookie has not spawned
* @param {number} chanceToSpawn The probablity that a GC appears
*/
export function updateChanceTotal(chanceToSpawn) {
chanceTotal *= 1 - chanceToSpawn;
}
/**
* Update the probability that a reindeer has not spawned
* @param {number} chanceToSpawn The probablity that a reindeer appears
*/
export function updateChanceTotalDeer(chanceToSpawn) {
chanceTotalDeer *= 1 - chanceToSpawn;
}
/**
*
* @returns the cummulative probability that a GC has appeared from beginning to now
*/
export function getChanceFinal() {
return 1 - chanceTotal;
}
/**
*
* @returns the cummulative probability that a reindeer has appeared from beginning to now
*/
export function getChanceFinalDeer() {
return 1 - chanceTotalDeer;
}