From 690e284f4d035acd4605aa35e214fc62178b94e6 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 11 Apr 2023 11:04:39 -0400 Subject: [PATCH] Add ethers and elixirs --- src/battle-phases.ts | 21 +++--- src/battle-scene.ts | 3 +- src/modifier.ts | 131 ++++++++++++++++++++++++++++--------- src/pokemon.ts | 4 ++ src/ui/party-ui-handler.ts | 100 +++++++++++++++++++--------- 5 files changed, 189 insertions(+), 70 deletions(-) diff --git a/src/battle-phases.ts b/src/battle-phases.ts index 0cb4a62da07..6f93b7c6421 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -5,9 +5,9 @@ import { allMoves, applyMoveAttrs, MissEffectAttr, MoveCategory, MoveHitEffectAt import { Mode } from './ui/ui'; import { Command } from "./ui/command-ui-handler"; import { Stat } from "./pokemon-stat"; -import { ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, getModifierTypesForWave, ModifierType, PokemonModifierType, regenerateModifierPoolThresholds } from "./modifier"; -import PartyUiHandler, { PartyUiMode } from "./ui/party-ui-handler"; -import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor as getPokeballTintColor, PokeballType } from "./pokeball"; +import { ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, getModifierTypesForWave, ModifierType, PokemonModifierType, PokemonMoveModifierType, regenerateModifierPoolThresholds } from "./modifier"; +import PartyUiHandler, { PartyOption, PartyUiMode } from "./ui/party-ui-handler"; +import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor, PokeballType } from "./pokeball"; import { MoveAnim, initAnim, loadMoveAnimAssets } from "./battle-anims"; import { StatusEffect } from "./status-effect"; import { SummaryUiMode } from "./ui/summary-ui-handler"; @@ -803,7 +803,7 @@ export class SwitchPhase extends BattlePhase { start() { super.start(); - this.scene.ui.setMode(Mode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, (slotIndex: integer) => { + this.scene.ui.setMode(Mode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, (slotIndex: integer, _option: PartyOption) => { if (slotIndex && slotIndex < 6) this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, slotIndex, this.doReturn)); this.scene.ui.setMode(Mode.MESSAGE).then(() => super.end()); @@ -1112,7 +1112,7 @@ export class AttemptCapturePhase extends BattlePhase { const promptRelease = () => { this.scene.ui.showText(`Your party is full.\nRelease a POKéMON to make room for ${pokemon.name}?`, null, () => { this.scene.ui.setMode(Mode.CONFIRM, () => { - this.scene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, (slotIndex: integer) => { + this.scene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, (slotIndex: integer, _option: PartyOption) => { this.scene.ui.setMode(Mode.MESSAGE).then(() => { if (slotIndex < 6) addToParty(); @@ -1168,15 +1168,20 @@ export class SelectModifierPhase extends BattlePhase { const modifierType = types[cursor]; if (modifierType instanceof PokemonModifierType) { const pokemonModifierType = modifierType as PokemonModifierType; - this.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.MODIFIER, (slotIndex: integer) => { + const isMoveModifier = modifierType instanceof PokemonMoveModifierType; + this.scene.ui.setModeWithoutClear(Mode.PARTY, !isMoveModifier ? PartyUiMode.MODIFIER : PartyUiMode.MOVE_MODIFIER, (slotIndex: integer, option: PartyOption) => { if (slotIndex < 6) { this.scene.ui.setMode(Mode.MODIFIER_SELECT); - this.scene.addModifier(types[cursor].newModifier(party[slotIndex])).then(() => super.end()); + const modifierType = types[cursor]; + const modifier = !isMoveModifier + ? modifierType.newModifier(party[slotIndex]) + : modifierType.newModifier(party[slotIndex], option - PartyOption.MOVE_1); + this.scene.addModifier(modifier).then(() => super.end()); this.scene.ui.clearText(); this.scene.ui.setMode(Mode.MESSAGE); } else this.scene.ui.setMode(Mode.MODIFIER_SELECT, types, modifierSelectCallback); - }, pokemonModifierType.selectFilter); + }, pokemonModifierType.selectFilter, modifierType instanceof PokemonMoveModifierType ? (modifierType as PokemonMoveModifierType).moveSelectFilter : undefined); } else { this.scene.addModifier(types[cursor].newModifier()).then(() => super.end()); this.scene.ui.clearText(); diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 77ebbd91374..6f6a0f9b5ee 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -5,7 +5,7 @@ import { EncounterPhase, SummonPhase, CommandPhase, NextEncounterPhase, SwitchBi import { PlayerPokemon, EnemyPokemon } from './pokemon'; import PokemonSpecies, { allSpecies, getPokemonSpecies } from './pokemon-species'; import * as Utils from './utils'; -import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, PartyShareModifier, PokemonHpRestoreModifier, HealingBoosterModifier, PersistentModifier, PokemonHeldItemModifier } from './modifier'; +import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, PartyShareModifier, PokemonHpRestoreModifier, HealingBoosterModifier, PersistentModifier, PokemonHeldItemModifier, ConsumablePokemonMoveModifier } from './modifier'; import { PokeballType } from './pokeball'; import { Species } from './species'; import { initAutoPlay } from './auto-play'; @@ -520,6 +520,7 @@ export default class BattleScene extends Phaser.Scene { this.applyModifiers(HealingBoosterModifier, hpRestoreMultiplier); args.push(hpRestoreMultiplier.value); } + if (modifier.shouldApply(args)) modifier.apply(args); } diff --git a/src/modifier.ts b/src/modifier.ts index e59070c9f2a..12b59671f83 100644 --- a/src/modifier.ts +++ b/src/modifier.ts @@ -3,12 +3,12 @@ import BattleScene from "./battle-scene"; import { getLevelTotalExp } from "./exp"; import { allMoves, Moves } from "./move"; import { getPokeballName, PokeballType } from "./pokeball"; -import Pokemon, { PlayerPokemon } from "./pokemon"; +import Pokemon, { PlayerPokemon, PokemonMove } from "./pokemon"; import { Stat, getStatName } from "./pokemon-stat"; import { addTextObject, TextStyle } from "./text"; import { tmSpecies } from "./tms"; import { Type } from "./type"; -import PartyUiHandler from "./ui/party-ui-handler"; +import PartyUiHandler, { PokemonMoveSelectFilter, PokemonSelectFilter } from "./ui/party-ui-handler"; import * as Utils from "./utils"; export class ModifierBar extends Phaser.GameObjects.Container { @@ -307,7 +307,36 @@ export class PokemonHpRestoreModifier extends ConsumablePokemonModifier { } } -export class PokemonPpRestoreModifier extends ConsumablePokemonModifier { +export abstract class ConsumablePokemonMoveModifier extends ConsumablePokemonModifier { + public moveIndex: integer; + + constructor(type: ModifierType, pokemonId: integer, moveIndex: integer) { + super(type, pokemonId); + + this.moveIndex = moveIndex; + } +} + +export class PokemonPpRestoreModifier extends ConsumablePokemonMoveModifier { + private restorePoints: integer; + + constructor(type: ModifierType, pokemonId: integer, moveIndex: integer, restorePoints: integer) { + super(type, pokemonId, moveIndex); + + this.restorePoints = restorePoints; + } + + apply(args: any[]): boolean { + const pokemon = args[0] as Pokemon; + const move = pokemon.moveset[this.moveIndex]; + console.log(move.ppUsed, this.restorePoints, this.restorePoints >= -1 ? Math.max(move.ppUsed - this.restorePoints, 0) : 0); + move.ppUsed = this.restorePoints >= -1 ? Math.max(move.ppUsed - this.restorePoints, 0) : 0; + + return true; + } +} + +export class PokemonAllMovePpRestoreModifier extends ConsumablePokemonModifier { private restorePoints: integer; constructor(type: ModifierType, pokemonId: integer, restorePoints: integer) { @@ -316,15 +345,10 @@ export class PokemonPpRestoreModifier extends ConsumablePokemonModifier { this.restorePoints = restorePoints; } - shouldApply(args: any[]): boolean { - return super.shouldApply(args) && args.length > 1 && typeof(args[1]) === 'number'; - } - apply(args: any[]): boolean { const pokemon = args[0] as Pokemon; - const moveIndex = args[1] as integer; - const move = pokemon.moveset[moveIndex]; - move.ppUsed = this.restorePoints >= 0 ? Math.max(move.ppUsed - this.restorePoints, 0) : 0; + for (let move of pokemon.moveset) + move.ppUsed = this.restorePoints >= -1 ? Math.max(move.ppUsed - this.restorePoints, 0) : 0; return true; } @@ -529,14 +553,16 @@ export enum ModifierTier { LUXURY }; +type NewModifierFunc = (type: ModifierType, args: any[]) => Modifier; + export class ModifierType { public name: string; public description: string; public iconImage: string; public tier: ModifierTier; - private newModifierFunc: Function; + private newModifierFunc: NewModifierFunc; - constructor(name: string, description: string, newModifierFunc: Function, iconImage?: string) { + constructor(name: string, description: string, newModifierFunc: NewModifierFunc, iconImage?: string) { this.name = name; this.description = description; this.iconImage = iconImage || name?.replace(/[ \-]/g, '_')?.toLowerCase(); @@ -559,9 +585,9 @@ class AddPokeballModifierType extends ModifierType { } export abstract class PokemonModifierType extends ModifierType { - public selectFilter: Function; + public selectFilter: PokemonSelectFilter; - constructor(name: string, description: string, newModifierFunc: Function, selectFilter?: Function, iconImage?: string) { + constructor(name: string, description: string, newModifierFunc: NewModifierFunc, selectFilter?: PokemonSelectFilter, iconImage?: string) { super(name, description, newModifierFunc, iconImage); this.selectFilter = selectFilter; @@ -572,7 +598,7 @@ export class PokemonHpRestoreModifierType extends PokemonModifierType { protected restorePoints: integer; protected percent: boolean; - constructor(name: string, restorePoints: integer, percent?: boolean, newModifierFunc?: Function, selectFilter?: Function, iconImage?: string) { + constructor(name: string, restorePoints: integer, percent?: boolean, newModifierFunc?: NewModifierFunc, selectFilter?: PokemonSelectFilter, iconImage?: string) { super(name, `Restore ${restorePoints}${percent ? '%' : ''} HP for one POKéMON`, newModifierFunc || ((_type, args) => new PokemonHpRestoreModifier(this, (args[0] as PlayerPokemon).id, this.restorePoints, this.percent, false)), selectFilter || ((pokemon: PlayerPokemon) => { @@ -604,19 +630,26 @@ export class PokemonReviveModifierType extends PokemonHpRestoreModifierType { } } -export class PokemonLevelIncrementModifierType extends PokemonModifierType { - constructor(name: string, iconImage?: string) { - super(name, `Increase a POKéMON\'s level by 1`, (_type, args) => new PokemonLevelIncrementModifier(this, (args[0] as PlayerPokemon).id), - (_pokemon: PlayerPokemon) => null, iconImage); +export abstract class PokemonMoveModifierType extends PokemonModifierType { + public moveSelectFilter: PokemonMoveSelectFilter; + + constructor(name: string, description: string, newModifierFunc: NewModifierFunc, selectFilter?: PokemonSelectFilter, moveSelectFilter?: PokemonMoveSelectFilter, iconImage?: string) { + super(name, description, newModifierFunc, selectFilter, iconImage); + + this.moveSelectFilter = moveSelectFilter; } } -export class PokemonPpRestoreModifierType extends PokemonModifierType { +export class PokemonPpRestoreModifierType extends PokemonMoveModifierType { protected restorePoints: integer; constructor(name: string, restorePoints: integer, iconImage?: string) { - super(name, `Restore ${restorePoints} PP for one POKéMON's move`, (_type, args) => new PokemonPpRestoreModifier(this, (args[0] as PlayerPokemon).id, this.restorePoints), - (pokemon: PlayerPokemon) => { + super(name, `Restore ${restorePoints > -1 ? restorePoints : 'all'} PP for one POKéMON move`, (_type, args) => new PokemonPpRestoreModifier(this, (args[0] as PlayerPokemon).id, (args[1] as integer), this.restorePoints), + (_pokemon: PlayerPokemon) => { + return null; + }, (pokemonMove: PokemonMove) => { + if (!pokemonMove.ppUsed) + return PartyUiHandler.NoEffectMessage; return null; }, iconImage); @@ -624,6 +657,28 @@ export class PokemonPpRestoreModifierType extends PokemonModifierType { } } +export class PokemonAllMovePpRestoreModifierType extends PokemonModifierType { + protected restorePoints: integer; + + constructor(name: string, restorePoints: integer, iconImage?: string) { + super(name, `Restore ${restorePoints > -1 ? restorePoints : 'all'} PP for all of one POKéMON's moves`, (_type, args) => new PokemonAllMovePpRestoreModifier(this, (args[0] as PlayerPokemon).id, this.restorePoints), + (pokemon: PlayerPokemon) => { + if (!pokemon.moveset.filter(m => m.ppUsed).length) + return PartyUiHandler.NoEffectMessage; + return null; + }, iconImage); + + this.restorePoints = this.restorePoints; + } +} + +export class PokemonLevelIncrementModifierType extends PokemonModifierType { + constructor(name: string, iconImage?: string) { + super(name, `Increase a POKéMON\'s level by 1`, (_type, args) => new PokemonLevelIncrementModifier(this, (args[0] as PlayerPokemon).id), + (_pokemon: PlayerPokemon) => null, iconImage); + } +} + export class PokemonBaseStatBoosterModifierType extends PokemonModifierType { private stat: Stat; @@ -635,7 +690,7 @@ export class PokemonBaseStatBoosterModifierType extends PokemonModifierType { } class AllPokemonFullHpRestoreModifierType extends ModifierType { - constructor(name: string, description?: string, newModifierFunc?: Function, iconImage?: string) { + constructor(name: string, description?: string, newModifierFunc?: NewModifierFunc, iconImage?: string) { super(name, description || `Restore 100% HP for all POKéMON`, newModifierFunc || ((_type, _args) => new PokemonHpRestoreModifier(this, -1, 100, false)), iconImage); } } @@ -700,11 +755,19 @@ const modifierPool = { [ModifierTier.COMMON]: [ new WeightedModifierType(new AddPokeballModifierType(PokeballType.POKEBALL, 5, 'pb'), 2), new WeightedModifierType(new PokemonHpRestoreModifierType('POTION', 20), (party: PlayerPokemon[]) => { - const thresholdPartyMemberCount = party.filter(p => p.getHpRatio() <= 0.9).length; + const thresholdPartyMemberCount = party.filter(p => p.getInverseHp() >= 10).length; return thresholdPartyMemberCount; }), new WeightedModifierType(new PokemonHpRestoreModifierType('SUPER POTION', 50), (party: PlayerPokemon[]) => { - const thresholdPartyMemberCount = party.filter(p => p.getHpRatio() <= 0.75).length; + const thresholdPartyMemberCount = party.filter(p => p.getInverseHp() >= 25).length; + return Math.ceil(thresholdPartyMemberCount / 3); + }), + new WeightedModifierType(new PokemonPpRestoreModifierType('ETHER', 10), (party: PlayerPokemon[]) => { + const thresholdPartyMemberCount = party.filter(p => p.moveset.filter(m => m.ppUsed)).length; + return thresholdPartyMemberCount; + }), + new WeightedModifierType(new PokemonPpRestoreModifierType('MAX ETHER', 100), (party: PlayerPokemon[]) => { + const thresholdPartyMemberCount = party.filter(p => p.moveset.filter(m => m.ppUsed > 10)).length; return Math.ceil(thresholdPartyMemberCount / 3); }) ].map(m => { m.setTier(ModifierTier.COMMON); return m; }), @@ -719,9 +782,21 @@ const modifierPool = { return faintedPartyMemberCount; }), new WeightedModifierType(new PokemonHpRestoreModifierType('HYPER POTION', 200), (party: PlayerPokemon[]) => { - const thresholdPartyMemberCount = party.filter(p => p.getHpRatio() <= 0.6).length; + const thresholdPartyMemberCount = party.filter(p => p.getInverseHp() >= 100).length; return thresholdPartyMemberCount; }), + new WeightedModifierType(new PokemonHpRestoreModifierType('MAX POTION', 100, true), (party: PlayerPokemon[]) => { + const thresholdPartyMemberCount = party.filter(p => p.getInverseHp() >= 150).length; + return Math.ceil(thresholdPartyMemberCount / 3); + }), + new WeightedModifierType(new PokemonAllMovePpRestoreModifierType('ELIXIR', 10), (party: PlayerPokemon[]) => { + const thresholdPartyMemberCount = party.filter(p => p.moveset.filter(m => m.ppUsed)).length; + return thresholdPartyMemberCount; + }), + new WeightedModifierType(new PokemonAllMovePpRestoreModifierType('MAX ELIXIR', 100), (party: PlayerPokemon[]) => { + const thresholdPartyMemberCount = party.filter(p => p.moveset.filter(m => m.ppUsed > 10)).length; + return Math.ceil(thresholdPartyMemberCount / 3); + }), new WeightedModifierType(new ModifierTypeGenerator((party: PlayerPokemon[]) => { const partyMemberCompatibleTms = party.map(p => p.compatibleTms); const uniqueCompatibleTms = partyMemberCompatibleTms.flat().filter((tm, i, array) => array.indexOf(tm) === i); @@ -738,10 +813,6 @@ const modifierPool = { ].map(m => { m.setTier(ModifierTier.GREAT); return m; }), [ModifierTier.ULTRA]: [ new AddPokeballModifierType(PokeballType.ULTRA_BALL, 5, 'ub'), - new WeightedModifierType(new AllPokemonFullHpRestoreModifierType('MAX POTION'), (party: PlayerPokemon[]) => { - const thresholdPartyMemberCount = party.filter(p => p.getHpRatio() <= 0.5).length; - return Math.ceil(thresholdPartyMemberCount / 3); - }), new WeightedModifierType(new AllPokemonFullReviveModifierType('SACRED ASH'), (party: PlayerPokemon[]) => { return party.filter(p => !p.hp).length >= Math.ceil(party.length / 2) ? 1 : 0; }), diff --git a/src/pokemon.ts b/src/pokemon.ts index 1b4888f9ae5..3ccd40173d6 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -291,6 +291,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return this.stats[Stat.HP]; } + getInverseHp(): integer { + return this.getMaxHp() - this.hp; + } + getHpRatio(): number { return Math.floor((this.hp / this.getMaxHp()) * 100) / 100; } diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index 74fa5ccb8f2..3a09121ae79 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -1,6 +1,6 @@ import { CommandPhase } from "../battle-phases"; import BattleScene, { Button } from "../battle-scene"; -import { PlayerPokemon } from "../pokemon"; +import { PlayerPokemon, PokemonMove } from "../pokemon"; import { addTextObject, TextStyle } from "../text"; import { Command } from "./command-ui-handler"; import MessageUiHandler from "./message-ui-handler"; @@ -14,6 +14,7 @@ export enum PartyUiMode { FAINT_SWITCH, POST_BATTLE_SWITCH, MODIFIER, + MOVE_MODIFIER, RELEASE } @@ -23,9 +24,17 @@ export enum PartyOption { APPLY, SUMMARY, RELEASE, + MOVE_1, + MOVE_2, + MOVE_3, + MOVE_4, CANCEL } +export type PartySelectCallback = (cursor: integer, option: PartyOption) => void; +export type PokemonSelectFilter = (pokemon: PlayerPokemon) => string; +export type PokemonMoveSelectFilter = (pokemonMove: PokemonMove) => string; + export default class PartyUiHandler extends MessageUiHandler { private partyUiMode: PartyUiMode; @@ -42,8 +51,9 @@ export default class PartyUiHandler extends MessageUiHandler { private options: integer[]; private lastCursor: integer = 0; - private selectCallback: Function; - private selectFilter: Function; + private selectCallback: PartySelectCallback; + private selectFilter: PokemonSelectFilter; + private moveSelectFilter: PokemonMoveSelectFilter; private static FilterAll = (_pokemon: PlayerPokemon) => null; @@ -53,6 +63,8 @@ export default class PartyUiHandler extends MessageUiHandler { return null; }; + private static FilterAllMoves = (_pokemonMove: PokemonMove) => null; + public static NoEffectMessage = 'It won\'t have any effect.'; constructor(scene: BattleScene) { @@ -122,8 +134,11 @@ export default class PartyUiHandler extends MessageUiHandler { if (args.length > 1 && args[1] instanceof Function) this.selectCallback = args[1]; this.selectFilter = args.length > 2 && args[2] instanceof Function - ? args[2] + ? args[2] as PokemonSelectFilter : PartyUiHandler.FilterAll; + this.moveSelectFilter = args.length > 3 && args[3] instanceof Function + ? args[3] as PokemonMoveSelectFilter + : PartyUiHandler.FilterAllMoves; } processInput(button: Button) { @@ -151,9 +166,11 @@ export default class PartyUiHandler extends MessageUiHandler { if (button === Button.ACTION) { const option = this.options[this.optionsCursor]; const pokemon = this.scene.getParty()[this.cursor]; - if (option === PartyOption.SHIFT || option === PartyOption.SEND_OUT || option === PartyOption.APPLY - || (this.partyUiMode === PartyUiMode.RELEASE && option === PartyOption.RELEASE)) { + if ((option !== PartyOption.SUMMARY && option !== PartyOption.RELEASE && option !== PartyOption.CANCEL) + || (option === PartyOption.RELEASE && this.partyUiMode === PartyUiMode.RELEASE)) { let filterResult: string = this.selectFilter(pokemon); + if (filterResult === null && this.partyUiMode === PartyUiMode.MOVE_MODIFIER) + filterResult = this.moveSelectFilter(pokemon.moveset[this.optionsCursor]); if (filterResult === null) { this.clearOptions(); if (this.selectCallback) { @@ -162,11 +179,11 @@ export default class PartyUiHandler extends MessageUiHandler { else { const selectCallback = this.selectCallback; this.selectCallback = null; - selectCallback(this.cursor); + selectCallback(this.cursor, option); } } else if (this.cursor) (this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.POKEMON, this.cursor); - if (this.partyUiMode !== PartyUiMode.MODIFIER) + if (this.partyUiMode !== PartyUiMode.MODIFIER && this.partyUiMode !== PartyUiMode.MOVE_MODIFIER) ui.playSelect(); return; } else { @@ -228,7 +245,7 @@ export default class PartyUiHandler extends MessageUiHandler { if (this.selectCallback) { const selectCallback = this.selectCallback; this.selectCallback = null; - selectCallback(6); + selectCallback(6, PartyOption.CANCEL); ui.playSelect(); } else { ui.setMode(Mode.COMMAND); @@ -325,35 +342,56 @@ export default class PartyUiHandler extends MessageUiHandler { optionsBottom.setOrigin(1, 1); this.optionsContainer.add(optionsBottom); - switch (this.partyUiMode) { - case PartyUiMode.SWITCH: - if (this.cursor) - this.options.push(PartyOption.SHIFT); - break; - case PartyUiMode.FAINT_SWITCH: - case PartyUiMode.POST_BATTLE_SWITCH: - if (this.cursor) - this.options.push(PartyOption.SEND_OUT); - break; - case PartyUiMode.MODIFIER: - this.options.push(PartyOption.APPLY); - break; - case PartyUiMode.RELEASE: + const pokemon = this.scene.getParty()[this.cursor]; + + if (this.partyUiMode !== PartyUiMode.MOVE_MODIFIER) { + switch (this.partyUiMode) { + case PartyUiMode.SWITCH: + if (this.cursor) + this.options.push(PartyOption.SHIFT); + break; + case PartyUiMode.FAINT_SWITCH: + case PartyUiMode.POST_BATTLE_SWITCH: + if (this.cursor) + this.options.push(PartyOption.SEND_OUT); + break; + case PartyUiMode.MODIFIER: + this.options.push(PartyOption.APPLY); + break; + case PartyUiMode.RELEASE: + this.options.push(PartyOption.RELEASE); + break; + } + + this.options.push(PartyOption.SUMMARY); + + if (this.partyUiMode === PartyUiMode.SWITCH) this.options.push(PartyOption.RELEASE); - break; + } else { + for (let m = 0; m < pokemon.moveset.length; m++) + this.options.push(PartyOption.MOVE_1 + m); } - this.options.push(PartyOption.SUMMARY); - - if (this.partyUiMode === PartyUiMode.SWITCH) - this.options.push(PartyOption.RELEASE); - this.options.push(PartyOption.CANCEL); for (let o = 0; o < this.options.length; o++) { + const option = this.options[this.options.length - (o + 1)]; + let optionName: string; + switch (option) { + case PartyOption.MOVE_1: + case PartyOption.MOVE_2: + case PartyOption.MOVE_3: + case PartyOption.MOVE_4: + optionName = pokemon.moveset[option - PartyOption.MOVE_1].getName(); + break; + default: + optionName = PartyOption[option].replace(/\_/g, ' '); + break; + } + const yCoord = -6 - 16 * o; const optionBg = this.scene.add.image(0, yCoord, 'party_options_center'); - const optionText = addTextObject(this.scene, -79, yCoord - 16, PartyOption[this.options[this.options.length - (o + 1)]].replace(/\_/g, ' '), TextStyle.WINDOW); + const optionText = addTextObject(this.scene, -79, yCoord - 16, optionName, TextStyle.WINDOW); optionBg.setOrigin(1, 1); optionText.setOrigin(0, 0); @@ -380,7 +418,7 @@ export default class PartyUiHandler extends MessageUiHandler { if (this.partyUiMode === PartyUiMode.RELEASE) { const selectCallback = this.selectCallback; this.selectCallback = null; - selectCallback(this.cursor); + selectCallback(this.cursor, PartyOption.RELEASE); } else this.message.setText(defaultMessage); }, null, true);