Temporary stopgap on maxUpgradeCount to avoid game crashing on modifier select ui handler

This commit is contained in:
Wlowscha 2025-06-07 10:26:35 +02:00
parent 9e1bbee58f
commit 064bebb205
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04

View File

@ -216,6 +216,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
: []; : [];
const optionsYOffset = const optionsYOffset =
shopTypeOptions.length > SHOP_OPTIONS_ROW_LIMIT ? -SINGLE_SHOP_ROW_YOFFSET : -DOUBLE_SHOP_ROW_YOFFSET; shopTypeOptions.length > SHOP_OPTIONS_ROW_LIMIT ? -SINGLE_SHOP_ROW_YOFFSET : -DOUBLE_SHOP_ROW_YOFFSET;
console.log("ui_shop_options", shopTypeOptions);
for (let m = 0; m < typeOptions.length; m++) { for (let m = 0; m < typeOptions.length; m++) {
const sliceWidth = globalScene.game.canvas.width / 6 / (typeOptions.length + 2); const sliceWidth = globalScene.game.canvas.width / 6 / (typeOptions.length + 2);
@ -229,6 +230,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
this.modifierContainer.add(option); this.modifierContainer.add(option);
this.options.push(option); this.options.push(option);
} }
console.log("ui_options", this.options);
// Set "Continue" button height based on number of rows in healing items shop // Set "Continue" button height based on number of rows in healing items shop
const continueButton = this.continueButtonContainer.getAt<Phaser.GameObjects.Text>(0); const continueButton = this.continueButtonContainer.getAt<Phaser.GameObjects.Text>(0);
@ -258,7 +260,10 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
this.shopOptionsRows[row].push(option); this.shopOptionsRows[row].push(option);
} }
const maxUpgradeCount = typeOptions.map(to => to.upgradeCount).reduce((max, current) => Math.max(current, max), 0); //TODO: temporary stopgap so the game does not crash, will have to fix this later
// console.log(typeOptions.map(to => to.upgradeCount))
// const maxUpgradeCount = typeOptions.map(to => to.upgradeCount).reduce((max, current) => Math.max(current, max), 0);
const maxUpgradeCount = 0;
/* Force updateModifiers without pokemonSpecificModifiers */ /* Force updateModifiers without pokemonSpecificModifiers */
globalScene.getModifierBar().updateModifiers(globalScene.modifiers, true); globalScene.getModifierBar().updateModifiers(globalScene.modifiers, true);
@ -288,14 +293,20 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
}, },
}); });
console.log("maxUpgradeCount", maxUpgradeCount);
globalScene.time.delayedCall(1000 + maxUpgradeCount * 2000, () => { globalScene.time.delayedCall(1000 + maxUpgradeCount * 2000, () => {
console.log("delayed1", partyHasHeldItem);
for (const shopOption of this.shopOptionsRows.flat()) { for (const shopOption of this.shopOptionsRows.flat()) {
console.log("uishop", shopOption);
shopOption.show(0, 0); shopOption.show(0, 0);
} }
}); });
globalScene.time.delayedCall(4000 + maxUpgradeCount * 2000, () => { globalScene.time.delayedCall(4000 + maxUpgradeCount * 2000, () => {
console.log("delayed2", partyHasHeldItem);
if (partyHasHeldItem) { if (partyHasHeldItem) {
console.log("uihelditem", partyHasHeldItem);
this.transferButtonContainer.setAlpha(0); this.transferButtonContainer.setAlpha(0);
this.transferButtonContainer.setVisible(true); this.transferButtonContainer.setVisible(true);
globalScene.tweens.add({ globalScene.tweens.add({
@ -350,6 +361,8 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
}); });
}); });
console.log("ui_end");
return true; return true;
} }
@ -798,6 +811,7 @@ class ModifierOption extends Phaser.GameObjects.Container {
} }
show(remainingDuration: number, upgradeCountOffset: number) { show(remainingDuration: number, upgradeCountOffset: number) {
console.log("mo1");
if (!this.modifierTypeOption.cost) { if (!this.modifierTypeOption.cost) {
globalScene.tweens.add({ globalScene.tweens.add({
targets: this.pb, targets: this.pb,
@ -805,6 +819,7 @@ class ModifierOption extends Phaser.GameObjects.Container {
duration: 1250, duration: 1250,
ease: "Bounce.Out", ease: "Bounce.Out",
}); });
console.log("mo2");
let lastValue = 1; let lastValue = 1;
let bounceCount = 0; let bounceCount = 0;
@ -831,6 +846,7 @@ class ModifierOption extends Phaser.GameObjects.Container {
lastValue = value; lastValue = value;
}, },
}); });
console.log("mo3");
for (let u = 0; u < this.modifierTypeOption.upgradeCount; u++) { for (let u = 0; u < this.modifierTypeOption.upgradeCount; u++) {
const upgradeIndex = u; const upgradeIndex = u;
@ -868,12 +884,14 @@ class ModifierOption extends Phaser.GameObjects.Container {
}, },
); );
} }
console.log("mo4");
} }
globalScene.time.delayedCall(remainingDuration + 2000, () => { globalScene.time.delayedCall(remainingDuration + 2000, () => {
if (!globalScene) { if (!globalScene) {
return; return;
} }
console.log("mo5");
if (!this.modifierTypeOption.cost) { if (!this.modifierTypeOption.cost) {
this.pb.setTexture("pb", `${this.getPbAtlasKey(0)}_open`); this.pb.setTexture("pb", `${this.getPbAtlasKey(0)}_open`);
@ -888,6 +906,7 @@ class ModifierOption extends Phaser.GameObjects.Container {
onComplete: () => this.pb.destroy(), onComplete: () => this.pb.destroy(),
}); });
} }
console.log("mo6");
globalScene.tweens.add({ globalScene.tweens.add({
targets: this.itemContainer, targets: this.itemContainer,
@ -922,6 +941,7 @@ class ModifierOption extends Phaser.GameObjects.Container {
}); });
} }
}); });
console.log("mo_end");
} }
getPbAtlasKey(tierOffset = 0) { getPbAtlasKey(tierOffset = 0) {