* Added cummulative probability handling * executed build-dev command * executed build-final command
This commit is contained in:
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,6 +10,12 @@ import {
|
|||||||
LastNumberOfTimers,
|
LastNumberOfTimers,
|
||||||
} from '../VariablesAndData';
|
} from '../VariablesAndData';
|
||||||
import { CreateTimer } from './CreateDOMElements';
|
import { CreateTimer } from './CreateDOMElements';
|
||||||
|
import {
|
||||||
|
updateChanceTotal,
|
||||||
|
getChanceFinalDeer,
|
||||||
|
getChanceFinal,
|
||||||
|
updateChanceTotalDeer,
|
||||||
|
} from '../../Main/CheckStates/Probability';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function creates the TimerBar and appends it to l('wrapper')
|
* This function creates the TimerBar and appends it to l('wrapper')
|
||||||
@@ -124,9 +130,10 @@ 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);
|
||||||
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,
|
||||||
)} ${chanceToSpawn < 0.01 ? '<' : ''}${chanceToSpawn.toLocaleString('en', {
|
)} ${getChanceFinal() < 0.01 ? '<' : ''}${getChanceFinal().toLocaleString('en', {
|
||||||
style: 'percent',
|
style: 'percent',
|
||||||
})}`;
|
})}`;
|
||||||
numberOfTimers += 1;
|
numberOfTimers += 1;
|
||||||
@@ -167,9 +174,10 @@ 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);
|
||||||
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,
|
||||||
)} ${chanceToSpawn < 0.01 ? '<' : ''}${chanceToSpawn.toLocaleString('en', {
|
)} ${getChanceFinalDeer() < 0.01 ? '<' : ''}${getChanceFinalDeer().toLocaleString('en', {
|
||||||
style: 'percent',
|
style: 'percent',
|
||||||
})}`;
|
})}`;
|
||||||
numberOfTimers += 1;
|
numberOfTimers += 1;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
LastGoldenCookieState,
|
LastGoldenCookieState,
|
||||||
LastSpawnedGoldenCookieState,
|
LastSpawnedGoldenCookieState,
|
||||||
} from '../VariablesAndData';
|
} from '../VariablesAndData';
|
||||||
|
import { resetChanceTotal } from './Probability';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auxilirary function that finds all currently spawned shimmers.
|
* Auxilirary function that finds all currently spawned shimmers.
|
||||||
@@ -56,6 +57,8 @@ export default function CheckGoldenCookie() {
|
|||||||
'Golden Cookie Spawned',
|
'Golden Cookie Spawned',
|
||||||
'A Golden Cookie has spawned. Click it now!',
|
'A Golden Cookie has spawned. Click it now!',
|
||||||
);
|
);
|
||||||
|
// Reset the cumulative probability when a GC has spawned
|
||||||
|
resetChanceTotal();
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.keys(Game.shimmers).forEach((i) => {
|
Object.keys(Game.shimmers).forEach((i) => {
|
||||||
|
|||||||
50
src/Main/CheckStates/Probability.js
Normal file
50
src/Main/CheckStates/Probability.js
Normal 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;
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { notificationsFunctions as nF } from '@cookiemonsterteam/cookiemonsterframework/src/index';
|
import { notificationsFunctions as nF } from '@cookiemonsterteam/cookiemonsterframework/src/index';
|
||||||
import { CacheSeasonPopShimmer } from '../../Cache/VariablesAndData'; // eslint-disable-line no-unused-vars
|
import { CacheSeasonPopShimmer } from '../../Cache/VariablesAndData'; // eslint-disable-line no-unused-vars
|
||||||
import { LastSeasonPopupState } from '../VariablesAndData';
|
import { LastSeasonPopupState } from '../VariablesAndData';
|
||||||
|
import { resetChanceTotalDeer } from './Probability';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function checks if there is reindeer that has spawned
|
* This function checks if there is reindeer that has spawned
|
||||||
@@ -28,5 +29,7 @@ export default function CheckSeasonPopup() {
|
|||||||
'Reindeer sighted!',
|
'Reindeer sighted!',
|
||||||
'A Reindeer has spawned. Click it now!',
|
'A Reindeer has spawned. Click it now!',
|
||||||
);
|
);
|
||||||
|
// Reset the cumulative probability when a deer is spawned
|
||||||
|
resetChanceTotalDeer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user