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 functionpull/863/head
parent
7061bb0d70
commit
d1187c7174
|
@ -95,9 +95,16 @@ export function getLegendaryGachaSpeciesForTimestamp(scene: BattleScene, timesta
|
|||
|
||||
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(() => {
|
||||
ret = Utils.randSeedItem(legendarySpecies);
|
||||
}, Utils.getSunday(new Date(timestamp)).getTime(), EGG_SEED.toString());
|
||||
ret = Phaser.Math.RND.shuffle(legendarySpecies)[index];
|
||||
}, offset, EGG_SEED.toString());
|
||||
|
||||
return ret;
|
||||
}
|
|
@ -116,13 +116,6 @@ export function randSeedEasedWeightedItem<T>(items: T[], easingFunction: string
|
|||
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 {
|
||||
return Math.floor((1 / 60) * 1000 * frameCount);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue