mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-29 18:26:09 +00:00
[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>,
|
applyFunc: AbAttrApplyFunc<TAttr>,
|
||||||
args: any[],
|
args: any[],
|
||||||
showAbilityInstant: boolean = false,
|
showAbilityInstant: boolean = false,
|
||||||
quiet: boolean = false,
|
isQuiet: boolean = false,
|
||||||
|
messages: string[] = [],
|
||||||
) {
|
) {
|
||||||
for (const passive of [false, true]) {
|
for (const passive of [false, true]) {
|
||||||
if (!pokemon?.canApplyAbility(passive)) {
|
if (!pokemon?.canApplyAbility(passive)) {
|
||||||
@ -4128,7 +4129,7 @@ async function applyAbAttrsInternal<TAttr extends AbAttr>(
|
|||||||
pokemon.battleData.abilitiesApplied.push(ability.id);
|
pokemon.battleData.abilitiesApplied.push(ability.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attr.showAbility && !quiet) {
|
if (attr.showAbility && !isQuiet) {
|
||||||
if (showAbilityInstant) {
|
if (showAbilityInstant) {
|
||||||
pokemon.scene.abilityBar.showAbility(pokemon, passive);
|
pokemon.scene.abilityBar.showAbility(pokemon, passive);
|
||||||
} else {
|
} else {
|
||||||
@ -4136,11 +4137,12 @@ async function applyAbAttrsInternal<TAttr extends AbAttr>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!quiet) {
|
|
||||||
const message = attr.getTriggerMessage(pokemon, ability.name, args);
|
const message = attr.getTriggerMessage(pokemon, ability.name, args);
|
||||||
if (message) {
|
if (message) {
|
||||||
|
if (!isQuiet) {
|
||||||
pokemon.scene.queueMessage(message);
|
pokemon.scene.queueMessage(message);
|
||||||
}
|
}
|
||||||
|
messages.push(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4271,8 +4273,8 @@ export function applyPostTerrainChangeAbAttrs(attrType: Constructor<PostTerrainC
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function applyCheckTrappedAbAttrs(attrType: Constructor<CheckTrappedAbAttr>,
|
export function applyCheckTrappedAbAttrs(attrType: Constructor<CheckTrappedAbAttr>,
|
||||||
pokemon: Pokemon, trapped: Utils.BooleanHolder, otherPokemon: Pokemon, ...args: any[]): Promise<void> {
|
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);
|
return applyAbAttrsInternal<CheckTrappedAbAttr>(attrType, pokemon, (attr, passive) => attr.applyCheckTrapped(pokemon, passive, trapped, otherPokemon, args), args, false, isQuiet, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function applyPostBattleAbAttrs(attrType: Constructor<PostBattleAbAttr>,
|
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 trapTag = playerPokemon.findTag(t => t instanceof TrappedTag) as TrappedTag;
|
||||||
const trapped = new Utils.BooleanHolder(false);
|
const trapped = new Utils.BooleanHolder(false);
|
||||||
const batonPass = isSwitch && args[0] as boolean;
|
const batonPass = isSwitch && args[0] as boolean;
|
||||||
|
const trappedAbMessages: string[] = [];
|
||||||
if (!batonPass) {
|
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)) {
|
if (batonPass || (!trapTag && !trapped.value)) {
|
||||||
this.scene.currentBattle.turnCommands[this.fieldIndex] = isSwitch
|
this.scene.currentBattle.turnCommands[this.fieldIndex] = isSwitch
|
||||||
@ -2126,7 +2127,17 @@ export class CommandPhase extends FieldPhase {
|
|||||||
}),
|
}),
|
||||||
null,
|
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) {
|
if (!isSwitch) {
|
||||||
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
|
||||||
}
|
}
|
||||||
@ -2225,7 +2236,7 @@ export class EnemyCommandPhase extends FieldPhase {
|
|||||||
|
|
||||||
const trapTag = enemyPokemon.findTag(t => t instanceof TrappedTag) as TrappedTag;
|
const trapTag = enemyPokemon.findTag(t => t instanceof TrappedTag) as TrappedTag;
|
||||||
const trapped = new Utils.BooleanHolder(false);
|
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) {
|
if (!trapTag && !trapped.value) {
|
||||||
const partyMemberScores = trainer.getPartyMemberMatchupScores(enemyPokemon.trainerSlot, true);
|
const partyMemberScores = trainer.getPartyMemberMatchupScores(enemyPokemon.trainerSlot, true);
|
||||||
|
|
||||||
|
@ -732,7 +732,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
return changed;
|
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) {
|
if (text === null) {
|
||||||
text = defaultMessage;
|
text = defaultMessage;
|
||||||
}
|
}
|
||||||
|
10
src/ui/ui.ts
10
src/ui/ui.ts
@ -271,8 +271,8 @@ export default class UI extends Phaser.GameObjects.Container {
|
|||||||
return handler.processInput(button);
|
return handler.processInput(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
showText(text: string, delay?: integer | null, callback?: Function | null, callbackDelay?: integer | null, prompt?: boolean | null, promptDelay?: integer | null): void {
|
showText(text: string | null, delay?: integer | null, callback?: Function | null, callbackDelay?: integer | null, prompt?: boolean | null, promptDelay?: integer | null): void {
|
||||||
if (prompt && text.indexOf("$") > -1) {
|
if (text && prompt && text.indexOf("$") > -1) {
|
||||||
const messagePages = text.split(/\$/g).map(m => m.trim());
|
const messagePages = text.split(/\$/g).map(m => m.trim());
|
||||||
let showMessageAndCallback = () => callback && callback();
|
let showMessageAndCallback = () => callback && callback();
|
||||||
for (let p = messagePages.length - 1; p >= 0; p--) {
|
for (let p = messagePages.length - 1; p >= 0; p--) {
|
||||||
@ -282,6 +282,11 @@ export default class UI extends Phaser.GameObjects.Container {
|
|||||||
showMessageAndCallback();
|
showMessageAndCallback();
|
||||||
} else {
|
} else {
|
||||||
const handler = this.getHandler();
|
const handler = this.getHandler();
|
||||||
|
if (handler instanceof PartyUiHandler) {
|
||||||
|
(handler as PartyUiHandler).showText(text, delay, callback, callbackDelay, prompt, promptDelay);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (text) {
|
||||||
if (handler instanceof MessageUiHandler) {
|
if (handler instanceof MessageUiHandler) {
|
||||||
(handler as MessageUiHandler).showText(text, delay, callback, callbackDelay, prompt, promptDelay);
|
(handler as MessageUiHandler).showText(text, delay, callback, callbackDelay, prompt, promptDelay);
|
||||||
} else {
|
} else {
|
||||||
@ -289,6 +294,7 @@ export default class UI extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
showDialogue(text: string, name: string | undefined, delay: integer | null = 0, callback: Function, callbackDelay?: integer, promptDelay?: integer): void {
|
showDialogue(text: string, name: string | undefined, delay: integer | null = 0, callback: Function, callbackDelay?: integer, promptDelay?: integer): void {
|
||||||
// First get the gender of the player (default male) (also used if UNSET)
|
// First get the gender of the player (default male) (also used if UNSET)
|
||||||
|
Loading…
Reference in New Issue
Block a user