[Bug] Display arena trap/shadow tag flyout at appropriate times (#3271)
* Show arena trap/shadow tag dialog immediately instead of as a message phase * remove flyout that opponent cannot switch out due to opposing arena trap * change applyAbAttrsInternal signature * fix bug (no messages appeared) due to prev commit * fix typedoc docs error * removed empty message after switching trapped pokemon * revert empty string argument to null modified files to adopt null argument * renamed variable
This commit is contained in:
parent
c5c314eb53
commit
73d60f5e6e
|
@ -4098,7 +4098,8 @@ async function applyAbAttrsInternal<TAttr extends AbAttr>(
|
|||
applyFunc: AbAttrApplyFunc<TAttr>,
|
||||
args: any[],
|
||||
showAbilityInstant: boolean = false,
|
||||
quiet: boolean = false,
|
||||
isQuiet: boolean = false,
|
||||
messages: string[] = [],
|
||||
) {
|
||||
for (const passive of [false, true]) {
|
||||
if (!pokemon?.canApplyAbility(passive)) {
|
||||
|
@ -4128,7 +4129,7 @@ async function applyAbAttrsInternal<TAttr extends AbAttr>(
|
|||
pokemon.battleData.abilitiesApplied.push(ability.id);
|
||||
}
|
||||
|
||||
if (attr.showAbility && !quiet) {
|
||||
if (attr.showAbility && !isQuiet) {
|
||||
if (showAbilityInstant) {
|
||||
pokemon.scene.abilityBar.showAbility(pokemon, passive);
|
||||
} else {
|
||||
|
@ -4136,11 +4137,12 @@ async function applyAbAttrsInternal<TAttr extends AbAttr>(
|
|||
}
|
||||
}
|
||||
|
||||
if (!quiet) {
|
||||
const message = attr.getTriggerMessage(pokemon, ability.name, args);
|
||||
if (message) {
|
||||
const message = attr.getTriggerMessage(pokemon, ability.name, args);
|
||||
if (message) {
|
||||
if (!isQuiet) {
|
||||
pokemon.scene.queueMessage(message);
|
||||
}
|
||||
messages.push(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4271,8 +4273,8 @@ export function applyPostTerrainChangeAbAttrs(attrType: Constructor<PostTerrainC
|
|||
}
|
||||
|
||||
export function applyCheckTrappedAbAttrs(attrType: Constructor<CheckTrappedAbAttr>,
|
||||
pokemon: Pokemon, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, ...args: any[]): Promise<void> {
|
||||
return applyAbAttrsInternal<CheckTrappedAbAttr>(attrType, pokemon, (attr, passive) => attr.applyCheckTrapped(pokemon, passive, trapped, otherPokemon, args), args);
|
||||
pokemon: Pokemon, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, isQuiet: boolean, messages: string[], ...args: any[]): Promise<void> {
|
||||
return applyAbAttrsInternal<CheckTrappedAbAttr>(attrType, pokemon, (attr, passive) => attr.applyCheckTrapped(pokemon, passive, trapped, otherPokemon, args), args, false, isQuiet, messages);
|
||||
}
|
||||
|
||||
export function applyPostBattleAbAttrs(attrType: Constructor<PostBattleAbAttr>,
|
||||
|
|
|
@ -2095,8 +2095,9 @@ export class CommandPhase extends FieldPhase {
|
|||
const trapTag = playerPokemon.findTag(t => t instanceof TrappedTag) as TrappedTag;
|
||||
const trapped = new Utils.BooleanHolder(false);
|
||||
const batonPass = isSwitch && args[0] as boolean;
|
||||
const trappedAbMessages: string[] = [];
|
||||
if (!batonPass) {
|
||||
enemyField.forEach(enemyPokemon => applyCheckTrappedAbAttrs(CheckTrappedAbAttr, enemyPokemon, trapped, playerPokemon));
|
||||
enemyField.forEach(enemyPokemon => applyCheckTrappedAbAttrs(CheckTrappedAbAttr, enemyPokemon, trapped, playerPokemon, true, trappedAbMessages));
|
||||
}
|
||||
if (batonPass || (!trapTag && !trapped.value)) {
|
||||
this.scene.currentBattle.turnCommands[this.fieldIndex] = isSwitch
|
||||
|
@ -2126,11 +2127,21 @@ export class CommandPhase extends FieldPhase {
|
|||
}),
|
||||
null,
|
||||
() => {
|
||||
this.scene.ui.showText("", 0);
|
||||
this.scene.ui.showText(null, 0);
|
||||
if (!isSwitch) {
|
||||
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
||||
}
|
||||
}, null, true);
|
||||
} else if (trapped.value && trappedAbMessages.length > 0) {
|
||||
if (!isSwitch) {
|
||||
this.scene.ui.setMode(Mode.MESSAGE);
|
||||
}
|
||||
this.scene.ui.showText(trappedAbMessages[0], null, () => {
|
||||
this.scene.ui.showText(null, 0);
|
||||
if (!isSwitch) {
|
||||
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
||||
}
|
||||
}, null, true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -2225,7 +2236,7 @@ export class EnemyCommandPhase extends FieldPhase {
|
|||
|
||||
const trapTag = enemyPokemon.findTag(t => t instanceof TrappedTag) as TrappedTag;
|
||||
const trapped = new Utils.BooleanHolder(false);
|
||||
opponents.forEach(playerPokemon => applyCheckTrappedAbAttrs(CheckTrappedAbAttr, playerPokemon, trapped, enemyPokemon));
|
||||
opponents.forEach(playerPokemon => applyCheckTrappedAbAttrs(CheckTrappedAbAttr, playerPokemon, trapped, enemyPokemon, true, []));
|
||||
if (!trapTag && !trapped.value) {
|
||||
const partyMemberScores = trainer.getPartyMemberMatchupScores(enemyPokemon.trainerSlot, true);
|
||||
|
||||
|
|
|
@ -732,7 +732,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||
return changed;
|
||||
}
|
||||
|
||||
showText(text: string | null, delay?: integer | null, callback?: Function | null, callbackDelay?: integer | null, prompt?: boolean, promptDelay?: integer) {
|
||||
showText(text: string | null, delay?: integer | null, callback?: Function | null, callbackDelay?: integer | null, prompt?: boolean | null, promptDelay?: integer | null) {
|
||||
if (text === null) {
|
||||
text = defaultMessage;
|
||||
}
|
||||
|
|
18
src/ui/ui.ts
18
src/ui/ui.ts
|
@ -271,8 +271,8 @@ export default class UI extends Phaser.GameObjects.Container {
|
|||
return handler.processInput(button);
|
||||
}
|
||||
|
||||
showText(text: string, delay?: integer | null, callback?: Function | null, callbackDelay?: integer | null, prompt?: boolean | null, promptDelay?: integer | null): void {
|
||||
if (prompt && text.indexOf("$") > -1) {
|
||||
showText(text: string | null, delay?: integer | null, callback?: Function | null, callbackDelay?: integer | null, prompt?: boolean | null, promptDelay?: integer | null): void {
|
||||
if (text && prompt && text.indexOf("$") > -1) {
|
||||
const messagePages = text.split(/\$/g).map(m => m.trim());
|
||||
let showMessageAndCallback = () => callback && callback();
|
||||
for (let p = messagePages.length - 1; p >= 0; p--) {
|
||||
|
@ -282,10 +282,16 @@ export default class UI extends Phaser.GameObjects.Container {
|
|||
showMessageAndCallback();
|
||||
} else {
|
||||
const handler = this.getHandler();
|
||||
if (handler instanceof MessageUiHandler) {
|
||||
(handler as MessageUiHandler).showText(text, delay, callback, callbackDelay, prompt, promptDelay);
|
||||
} else {
|
||||
this.getMessageHandler().showText(text, delay, callback, callbackDelay, prompt, promptDelay);
|
||||
if (handler instanceof PartyUiHandler) {
|
||||
(handler as PartyUiHandler).showText(text, delay, callback, callbackDelay, prompt, promptDelay);
|
||||
return;
|
||||
}
|
||||
if (text) {
|
||||
if (handler instanceof MessageUiHandler) {
|
||||
(handler as MessageUiHandler).showText(text, delay, callback, callbackDelay, prompt, promptDelay);
|
||||
} else {
|
||||
this.getMessageHandler().showText(text, delay, callback, callbackDelay, prompt, promptDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue