mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-16 21:32:18 +02:00
Handle null bannerFilename
This commit is contained in:
parent
f50a9e4c4f
commit
3ec7c7f3d0
@ -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');
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user