mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 07:52:17 +02:00
Extracted updateOptionsWindow()
This commit is contained in:
parent
562eb1d334
commit
eba75dbfa3
@ -1075,6 +1075,35 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
this.setCursor(0);
|
this.setCursor(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allowBatonModifierSwitch(): boolean {
|
||||||
|
return !!(
|
||||||
|
this.partyUiMode !== PartyUiMode.FAINT_SWITCH &&
|
||||||
|
globalScene.findModifier(
|
||||||
|
m =>
|
||||||
|
m instanceof SwitchEffectTransferModifier &&
|
||||||
|
(m as SwitchEffectTransferModifier).pokemonId === globalScene.getPlayerField()[this.fieldIndex].id,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
isBatonPassMove(): boolean {
|
||||||
|
const moveHistory = globalScene.getPlayerField()[this.fieldIndex].getMoveHistory();
|
||||||
|
return !!(
|
||||||
|
this.partyUiMode === PartyUiMode.FAINT_SWITCH &&
|
||||||
|
moveHistory.length &&
|
||||||
|
allMoves[moveHistory[moveHistory.length - 1].move].getAttrs(ForceSwitchOutAttr)[0]?.isBatonPass() &&
|
||||||
|
moveHistory[moveHistory.length - 1].result === MoveResult.SUCCESS
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getItemModifiers(pokemon: Pokemon): PokemonHeldItemModifier[] {
|
||||||
|
return this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER
|
||||||
|
? (globalScene.findModifiers(
|
||||||
|
m => m instanceof PokemonHeldItemModifier && m.isTransferable && m.pokemonId === pokemon.id,
|
||||||
|
) as PokemonHeldItemModifier[])
|
||||||
|
: [];
|
||||||
|
}
|
||||||
|
|
||||||
updateOptions(): void {
|
updateOptions(): void {
|
||||||
const pokemon = globalScene.getPlayerParty()[this.cursor];
|
const pokemon = globalScene.getPlayerParty()[this.cursor];
|
||||||
|
|
||||||
@ -1086,12 +1115,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
this.moveInfoOverlay.show(allMoves[learnableLevelMoves[0]]);
|
this.moveInfoOverlay.show(allMoves[learnableLevelMoves[0]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const itemModifiers =
|
const itemModifiers = this.getItemModifiers(pokemon);
|
||||||
this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER
|
|
||||||
? (globalScene.findModifiers(
|
|
||||||
m => m instanceof PokemonHeldItemModifier && m.isTransferable && m.pokemonId === pokemon.id,
|
|
||||||
) as PokemonHeldItemModifier[])
|
|
||||||
: [];
|
|
||||||
|
|
||||||
if (this.options.length) {
|
if (this.options.length) {
|
||||||
this.options.splice(0, this.options.length);
|
this.options.splice(0, this.options.length);
|
||||||
@ -1111,20 +1135,8 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
case PartyUiMode.FAINT_SWITCH:
|
case PartyUiMode.FAINT_SWITCH:
|
||||||
case PartyUiMode.POST_BATTLE_SWITCH:
|
case PartyUiMode.POST_BATTLE_SWITCH:
|
||||||
if (this.cursor >= globalScene.currentBattle.getBattlerCount()) {
|
if (this.cursor >= globalScene.currentBattle.getBattlerCount()) {
|
||||||
const allowBatonModifierSwitch =
|
const allowBatonModifierSwitch = this.allowBatonModifierSwitch();
|
||||||
this.partyUiMode !== PartyUiMode.FAINT_SWITCH &&
|
const isBatonPassMove = this.isBatonPassMove();
|
||||||
globalScene.findModifier(
|
|
||||||
m =>
|
|
||||||
m instanceof SwitchEffectTransferModifier &&
|
|
||||||
(m as SwitchEffectTransferModifier).pokemonId === globalScene.getPlayerField()[this.fieldIndex].id,
|
|
||||||
);
|
|
||||||
|
|
||||||
const moveHistory = globalScene.getPlayerField()[this.fieldIndex].getMoveHistory();
|
|
||||||
const isBatonPassMove =
|
|
||||||
this.partyUiMode === PartyUiMode.FAINT_SWITCH &&
|
|
||||||
moveHistory.length &&
|
|
||||||
allMoves[moveHistory[moveHistory.length - 1].move].getAttrs(ForceSwitchOutAttr)[0]?.isBatonPass() &&
|
|
||||||
moveHistory[moveHistory.length - 1].result === MoveResult.SUCCESS;
|
|
||||||
|
|
||||||
// isBatonPassMove and allowBatonModifierSwitch shouldn't ever be true
|
// isBatonPassMove and allowBatonModifierSwitch shouldn't ever be true
|
||||||
// at the same time, because they both explicitly check for a mutually
|
// at the same time, because they both explicitly check for a mutually
|
||||||
@ -1216,8 +1228,8 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.optionsScrollTotal = this.options.length;
|
this.optionsScrollTotal = this.options.length;
|
||||||
let optionStartIndex = this.optionsScrollCursor;
|
const optionStartIndex = this.optionsScrollCursor;
|
||||||
let optionEndIndex = Math.min(
|
const optionEndIndex = Math.min(
|
||||||
this.optionsScrollTotal,
|
this.optionsScrollTotal,
|
||||||
optionStartIndex + (!optionStartIndex || this.optionsScrollCursor + 8 >= this.optionsScrollTotal ? 8 : 7),
|
optionStartIndex + (!optionStartIndex || this.optionsScrollCursor + 8 >= this.optionsScrollTotal ? 8 : 7),
|
||||||
);
|
);
|
||||||
@ -1237,13 +1249,19 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
this.options.push(PartyOption.CANCEL);
|
this.options.push(PartyOption.CANCEL);
|
||||||
|
|
||||||
|
this.updateOptionsWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateOptionsWindow(): void {
|
||||||
|
const pokemon = globalScene.getPlayerParty()[this.cursor];
|
||||||
|
|
||||||
this.optionsBg = addWindow(0, 0, 0, 16 * this.options.length + 13);
|
this.optionsBg = addWindow(0, 0, 0, 16 * this.options.length + 13);
|
||||||
this.optionsBg.setOrigin(1, 1);
|
this.optionsBg.setOrigin(1, 1);
|
||||||
|
|
||||||
this.optionsContainer.add(this.optionsBg);
|
this.optionsContainer.add(this.optionsBg);
|
||||||
|
|
||||||
optionStartIndex = 0;
|
const optionStartIndex = 0;
|
||||||
optionEndIndex = this.options.length;
|
const optionEndIndex = this.options.length;
|
||||||
|
|
||||||
let widestOptionWidth = 0;
|
let widestOptionWidth = 0;
|
||||||
const optionTexts: BBCodeText[] = [];
|
const optionTexts: BBCodeText[] = [];
|
||||||
@ -1276,6 +1294,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
const formChangeItemModifiers = this.getFormChangeItemsModifiers(pokemon);
|
||||||
if (formChangeItemModifiers && option >= PartyOption.FORM_CHANGE_ITEM) {
|
if (formChangeItemModifiers && option >= PartyOption.FORM_CHANGE_ITEM) {
|
||||||
const modifier = formChangeItemModifiers[option - PartyOption.FORM_CHANGE_ITEM];
|
const modifier = formChangeItemModifiers[option - PartyOption.FORM_CHANGE_ITEM];
|
||||||
optionName = `${modifier.active ? i18next.t("partyUiHandler:DEACTIVATE") : i18next.t("partyUiHandler:ACTIVATE")} ${modifier.type.name}`;
|
optionName = `${modifier.active ? i18next.t("partyUiHandler:DEACTIVATE") : i18next.t("partyUiHandler:ACTIVATE")} ${modifier.type.name}`;
|
||||||
@ -1291,6 +1310,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER) {
|
} else if (this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER) {
|
||||||
|
const learnableLevelMoves = pokemon.getLearnableLevelMoves();
|
||||||
const move = learnableLevelMoves[option];
|
const move = learnableLevelMoves[option];
|
||||||
optionName = allMoves[move].name;
|
optionName = allMoves[move].name;
|
||||||
altText = !pokemon
|
altText = !pokemon
|
||||||
@ -1300,6 +1320,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
} else if (option === PartyOption.ALL) {
|
} else if (option === PartyOption.ALL) {
|
||||||
optionName = i18next.t("partyUiHandler:ALL");
|
optionName = i18next.t("partyUiHandler:ALL");
|
||||||
} else {
|
} else {
|
||||||
|
const itemModifiers = this.getItemModifiers(pokemon);
|
||||||
const itemModifier = itemModifiers[option];
|
const itemModifier = itemModifiers[option];
|
||||||
optionName = itemModifier.type.name;
|
optionName = itemModifier.type.name;
|
||||||
}
|
}
|
||||||
@ -1313,6 +1334,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
optionText.setOrigin(0, 0);
|
optionText.setOrigin(0, 0);
|
||||||
|
|
||||||
/** For every item that has stack bigger than 1, display the current quantity selection */
|
/** For every item that has stack bigger than 1, display the current quantity selection */
|
||||||
|
const itemModifiers = this.getItemModifiers(pokemon);
|
||||||
const itemModifier = itemModifiers[option];
|
const itemModifier = itemModifiers[option];
|
||||||
if (
|
if (
|
||||||
this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER &&
|
this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER &&
|
||||||
|
Loading…
Reference in New Issue
Block a user