Minor refactor to remove unused probability functions and combine functions that were only used in one spot.
This commit is contained in:
committed by
Daniël van Noord
parent
270190feae
commit
4e6c828f8b
2
dist/CookieMonster.js
vendored
2
dist/CookieMonster.js
vendored
File diff suppressed because one or more lines are too long
2
dist/CookieMonster.js.map
vendored
2
dist/CookieMonster.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/CookieMonsterDev.js
vendored
2
dist/CookieMonsterDev.js
vendored
File diff suppressed because one or more lines are too long
2
dist/CookieMonsterDev.js.map
vendored
2
dist/CookieMonsterDev.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -10,12 +10,7 @@ import {
|
|||||||
LastNumberOfTimers,
|
LastNumberOfTimers,
|
||||||
} from '../VariablesAndData.js';
|
} from '../VariablesAndData.js';
|
||||||
import { CreateTimer } from './CreateDOMElements.js';
|
import { CreateTimer } from './CreateDOMElements.js';
|
||||||
import {
|
import { updateChanceTotal, updateChanceTotalDeer } from '../../Main/CheckStates/Probability.js';
|
||||||
updateChanceTotal,
|
|
||||||
getChanceFinalDeer,
|
|
||||||
getChanceFinal,
|
|
||||||
updateChanceTotalDeer,
|
|
||||||
} from '../../Main/CheckStates/Probability.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function creates the TimerBar and appends it to l('wrapper')
|
* This function creates the TimerBar and appends it to l('wrapper')
|
||||||
@@ -130,15 +125,15 @@ export function UpdateTimerBar() {
|
|||||||
(Game.shimmerTypes.golden.time - Game.shimmerTypes.golden.minTime) /
|
(Game.shimmerTypes.golden.time - Game.shimmerTypes.golden.minTime) /
|
||||||
(Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.minTime),
|
(Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.minTime),
|
||||||
) ** 5;
|
) ** 5;
|
||||||
updateChanceTotal(chanceToSpawn);
|
const finalChance = updateChanceTotal(chanceToSpawn);
|
||||||
l('CMTimerBarGCTime').textContent = `${Math.ceil(
|
l('CMTimerBarGCTime').textContent = `${Math.ceil(
|
||||||
(Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time) / Game.fps,
|
(Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time) / Game.fps,
|
||||||
)} `;
|
)} `;
|
||||||
if (getChanceFinal() < 0.01) {
|
if (finalChance < 0.01) {
|
||||||
l('CMTimerBarGCTime').textContent +=
|
l('CMTimerBarGCTime').textContent +=
|
||||||
`<${(0.01).toLocaleString('en', { style: 'percent' })}`;
|
`<${(0.01).toLocaleString('en', { style: 'percent' })}`;
|
||||||
} else {
|
} else {
|
||||||
l('CMTimerBarGCTime').textContent += getChanceFinal().toLocaleString('en', {
|
l('CMTimerBarGCTime').textContent += finalChance.toLocaleString('en', {
|
||||||
style: 'percent',
|
style: 'percent',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -180,15 +175,15 @@ export function UpdateTimerBar() {
|
|||||||
(Game.shimmerTypes.reindeer.time - Game.shimmerTypes.reindeer.minTime) /
|
(Game.shimmerTypes.reindeer.time - Game.shimmerTypes.reindeer.minTime) /
|
||||||
(Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.minTime),
|
(Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.minTime),
|
||||||
) ** 5;
|
) ** 5;
|
||||||
updateChanceTotalDeer(chanceToSpawn);
|
const deerFinalChance = updateChanceTotalDeer(chanceToSpawn);
|
||||||
l('CMTimerBarRenTime').textContent = `${Math.ceil(
|
l('CMTimerBarRenTime').textContent = `${Math.ceil(
|
||||||
(Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.time) / Game.fps,
|
(Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.time) / Game.fps,
|
||||||
)} `;
|
)} `;
|
||||||
if (getChanceFinalDeer() < 0.01) {
|
if (deerFinalChance < 0.01) {
|
||||||
l('CMTimerBarRenTime').textContent +=
|
l('CMTimerBarRenTime').textContent +=
|
||||||
`<${(0.01).toLocaleString('en', { style: 'percent' })}`;
|
`<${(0.01).toLocaleString('en', { style: 'percent' })}`;
|
||||||
} else {
|
} else {
|
||||||
l('CMTimerBarRenTime').textContent += getChanceFinalDeer().toLocaleString('en', {
|
l('CMTimerBarRenTime').textContent += deerFinalChance.toLocaleString('en', {
|
||||||
style: 'percent',
|
style: 'percent',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,39 +12,22 @@ export function resetChanceTotalDeer() {
|
|||||||
chanceTotalDeer = 1.0;
|
chanceTotalDeer = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getChanceTotal() {
|
|
||||||
return chanceTotal;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getChanceTotalDeer() {
|
|
||||||
return chanceTotalDeer;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Update the probability that a cookie has not spawned
|
* Update the probability that a cookie has not spawned
|
||||||
* @param {number} chanceToSpawn The probablity that a GC appears
|
* @param {number} chanceToSpawn The probablity that a GC appears
|
||||||
|
* @returns the cumulative probability that a GC has appeared from beginning to now
|
||||||
*/
|
*/
|
||||||
export function updateChanceTotal(chanceToSpawn) {
|
export function updateChanceTotal(chanceToSpawn) {
|
||||||
chanceTotal *= 1 - chanceToSpawn;
|
chanceTotal *= 1 - chanceToSpawn;
|
||||||
|
return 1 - chanceTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the probability that a reindeer has not spawned
|
* Update the probability that a reindeer has not spawned
|
||||||
* @param {number} chanceToSpawn The probablity that a reindeer appears
|
* @param {number} chanceToSpawn The probablity that a reindeer appears
|
||||||
|
* @returns the cumulative probability that a reindeer has appeared from beginning to now
|
||||||
*/
|
*/
|
||||||
export function updateChanceTotalDeer(chanceToSpawn) {
|
export function updateChanceTotalDeer(chanceToSpawn) {
|
||||||
chanceTotalDeer *= 1 - 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;
|
return 1 - chanceTotalDeer;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user