diff --git a/public/images/logo_fake.png b/public/images/logo_fake.png new file mode 100755 index 00000000000..9fdb8724025 Binary files /dev/null and b/public/images/logo_fake.png differ diff --git a/src/constants.ts b/src/constants.ts index f3b37563d11..6f9f4a6d2fb 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -94,3 +94,10 @@ export const AVERAGE_ENCOUNTERS_PER_RUN_TARGET = 12; * So anti-variance adds -15/256 to the spawn weight check for ME spawn. */ export const ANTI_VARIANCE_WEIGHT_MODIFIER = 15; + +/** + * The chance (out of 1) that a different title logo will show when the title screen is drawn. + * Inverted during April Fools (such that this becomes the chance for the _normal_ title logo is displayed). + * Default: `10000` (0.01%) + */ +export const FAKE_TITLE_LOGO_CHANCE = 10000; diff --git a/src/loading-scene.ts b/src/loading-scene.ts index c5b0263e785..d2b4a76ef10 100644 --- a/src/loading-scene.ts +++ b/src/loading-scene.ts @@ -29,6 +29,7 @@ export class LoadingScene extends SceneBase { this.loadImage("loading_bg", "arenas"); this.loadImage("logo", ""); + this.loadImage("logo_fake", ""); // Load menu images this.loadAtlas("bg", "ui"); diff --git a/src/timed-event-manager.ts b/src/timed-event-manager.ts index 9877f298404..136467ad826 100644 --- a/src/timed-event-manager.ts +++ b/src/timed-event-manager.ts @@ -397,6 +397,16 @@ export class TimedEventManager { return timedEvents.some((te: TimedEvent) => this.isActive(te)); } + /** + * Check whether the current event is active and for April Fools. + * @returns Whether the April Fools event is currently active. + */ + isAprilFoolsActive(): boolean { + return timedEvents.some( + te => this.isActive(te) && te.hasOwnProperty("bannerKey") && te.bannerKey!.startsWith("aprf"), + ); + } + activeEventHasBanner(): boolean { const activeEvents = timedEvents.filter(te => this.isActive(te) && te.hasOwnProperty("bannerKey")); return activeEvents.length > 0; diff --git a/src/ui/title-ui-handler.ts b/src/ui/title-ui-handler.ts index 66cb69f6a26..bd49c6dd430 100644 --- a/src/ui/title-ui-handler.ts +++ b/src/ui/title-ui-handler.ts @@ -1,4 +1,5 @@ import { pokerogueApi } from "#api/pokerogue-api"; +import { FAKE_TITLE_LOGO_CHANCE } from "#app/constants"; import { timedEventManager } from "#app/global-event-manager"; import { globalScene } from "#app/global-scene"; import { TimedEventDisplay } from "#app/timed-event-manager"; @@ -41,7 +42,7 @@ export class TitleUiHandler extends OptionSelectUiHandler { this.titleContainer.setAlpha(0); ui.add(this.titleContainer); - const logo = globalScene.add.image(globalScene.game.canvas.width / 6 / 2, 8, "logo"); + const logo = globalScene.add.image(globalScene.scaledCanvas.width / 2, 8, this.getLogo()); logo.setOrigin(0.5, 0); this.titleContainer.add(logo); @@ -186,4 +187,14 @@ export class TitleUiHandler extends OptionSelectUiHandler { ease: "Sine.easeInOut", }); } + + /** + * Get the logo file path to load, with a 0.1% chance to use the fake logo instead. + * @returns The path to the image. + */ + private getLogo(): string { + // Invert spawn chances on april fools + const aprilFools = timedEventManager.isAprilFoolsActive(); + return aprilFools === !!randInt(FAKE_TITLE_LOGO_CHANCE) ? "logo_fake" : "logo"; + } } diff --git a/src/utils/common.ts b/src/utils/common.ts index 1c75dac93b4..aac1ef359e6 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -70,12 +70,16 @@ export function padInt(value: number, length: number, padWith?: string): string } /** - * Returns a random integer between min and min + range - * @param range The amount of possible numbers - * @param min The starting number + * Returns a **completely unseeded** random integer between `min` and `min + range`. + * @param range - The amount of possible numbers to pick + * @param min - The minimum number to pick; default `0` + * @returns A psuedo-random, unseeded integer within the interval [min, min+range]. + * @remarks + * This should not be used for battles or other outwards-facing randomness; + * battles are intended to be seeded and deterministic. */ export function randInt(range: number, min = 0): number { - if (range === 1) { + if (range <= 1) { return min; } return Math.floor(Math.random() * range) + min;