Handle null bannerFilename

This commit is contained in:
Ice 2024-05-17 19:10:33 -05:00
parent f50a9e4c4f
commit 3ec7c7f3d0
3 changed files with 17 additions and 4 deletions

View File

@ -30,7 +30,7 @@ export class LoadingScene extends SceneBase {
// Load menu images // Load menu images
this.loadAtlas('bg', 'ui'); this.loadAtlas('bg', 'ui');
if (new TimedEventManager().isEventActive()) { if (new TimedEventManager().isEventActive() && new TimedEventManager().activeEventHasBanner()) {
this.loadImage(new TimedEventManager().getEventBannerFilename(), 'events') this.loadImage(new TimedEventManager().getEventBannerFilename(), 'events')
} }
this.loadImage('command_fight_labels', 'ui'); this.loadImage('command_fight_labels', 'ui');

View File

@ -33,6 +33,19 @@ export class TimedEventManager {
return false; return false;
} }
activeEventHasBanner(): boolean {
for (const timedEvent of timedEvents) {
const eventStart = new Date(timedEvent.startDate);
const now = new Date();
const eventEnd = new Date(timedEvent.endDate);
if (eventStart < now && now < eventEnd && timedEvent.bannerFilename) {
return true;
}
}
return false;
}
getShinyMultiplier(): number { getShinyMultiplier(): number {
let multiplier = 1; let multiplier = 1;
for (const timedEvent of timedEvents) { for (const timedEvent of timedEvents) {
@ -51,7 +64,7 @@ export class TimedEventManager {
const now = new Date(); const now = new Date();
const eventEnd = new Date(timedEvent.endDate); const eventEnd = new Date(timedEvent.endDate);
if (eventStart < now && now < eventEnd) { if (eventStart < now && now < eventEnd && timedEvent.bannerFilename) {
return timedEvent.bannerFilename; return timedEvent.bannerFilename;
} }
} }

View File

@ -16,6 +16,7 @@ export default class TitleUiHandler extends OptionSelectUiHandler {
private splashMessageText: Phaser.GameObjects.Text; private splashMessageText: Phaser.GameObjects.Text;
private titleStatsTimer: number; private titleStatsTimer: number;
private timedEventManager: TimedEventManager = new TimedEventManager();
constructor(scene: BattleScene, mode: Mode = Mode.TITLE) { constructor(scene: BattleScene, mode: Mode = Mode.TITLE) {
super(scene, mode); super(scene, mode);
@ -35,13 +36,12 @@ export default class TitleUiHandler extends OptionSelectUiHandler {
this.titleContainer.add(logo); this.titleContainer.add(logo);
if (new TimedEventManager().isEventActive()) { if (this.timedEventManager.isEventActive() && this.timedEventManager.activeEventHasBanner()) {
const banner = this.scene.add.image((this.scene.game.canvas.width / 6.5) / 2, (this.scene.game.canvas.height / 4.65) / 2, new TimedEventManager().getEventBannerFilename()); const banner = this.scene.add.image((this.scene.game.canvas.width / 6.5) / 2, (this.scene.game.canvas.height / 4.65) / 2, new TimedEventManager().getEventBannerFilename());
banner.displayWidth = this.scene.game.canvas.width / 18.33 banner.displayWidth = this.scene.game.canvas.width / 18.33
banner.displayHeight = banner.displayWidth / 3 banner.displayHeight = banner.displayWidth / 3
banner.setOrigin(0.315, -0.8); banner.setOrigin(0.315, -0.8);
this.titleContainer.add(banner); this.titleContainer.add(banner);
} }