Modify legend gacha to be even split (#858)

* Modify egg gacha to be even split

* Update to a daily cycle

* Add spaces

* Removes now unused getSunday function
pull/863/head
Xavion3 2024-05-15 01:34:40 +10:00 committed by GitHub
parent 7061bb0d70
commit d1187c7174
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 9 deletions

View File

@ -95,9 +95,16 @@ export function getLegendaryGachaSpeciesForTimestamp(scene: BattleScene, timesta
let ret: Species; let ret: Species;
// 86400000 is the number of miliseconds in one day
const timeDate = new Date(timestamp);
const dayDate = new Date(Date.UTC(timeDate.getUTCFullYear(), timeDate.getUTCMonth(), timeDate.getUTCDate()));
const dayTimestamp = timeDate.getTime(); // Timestamp of current week
const offset = Math.floor(Math.floor(dayTimestamp / 86400000) / legendarySpecies.length); // Cycle number
const index = Math.floor(dayTimestamp / 86400000) % legendarySpecies.length // Index within cycle
scene.executeWithSeedOffset(() => { scene.executeWithSeedOffset(() => {
ret = Utils.randSeedItem(legendarySpecies); ret = Phaser.Math.RND.shuffle(legendarySpecies)[index];
}, Utils.getSunday(new Date(timestamp)).getTime(), EGG_SEED.toString()); }, offset, EGG_SEED.toString());
return ret; return ret;
} }

View File

@ -116,13 +116,6 @@ export function randSeedEasedWeightedItem<T>(items: T[], easingFunction: string
return items[Math.floor(easedValue * items.length)]; return items[Math.floor(easedValue * items.length)];
} }
export function getSunday(date: Date): Date {
const day = date.getUTCDay();
const diff = date.getUTCDate() - day;
const newDate = new Date(date.setUTCDate(diff));
return new Date(Date.UTC(newDate.getUTCFullYear(), newDate.getUTCMonth(), newDate.getUTCDate()));
}
export function getFrameMs(frameCount: integer): integer { export function getFrameMs(frameCount: integer): integer {
return Math.floor((1 / 60) * 1000 * frameCount); return Math.floor((1 / 60) * 1000 * frameCount);
} }