mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-20 16:42:45 +02:00
Compare commits
13 Commits
f2287eccf3
...
12c763ea92
Author | SHA1 | Date | |
---|---|---|---|
|
12c763ea92 | ||
|
a4e721fe2a | ||
|
4b70fab608 | ||
|
1ff2701964 | ||
|
1e306e25b5 | ||
|
43aa772603 | ||
|
2691d4e391 | ||
|
0d998a7d3a | ||
|
51930f87cc | ||
|
87c84203e7 | ||
|
a265c37a61 | ||
|
5480d8f1f1 | ||
|
9b7da35fdc |
BIN
public/images/ui/legacy/party_bg_double_manage.png
Normal file
BIN
public/images/ui/legacy/party_bg_double_manage.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
62
public/images/ui/legacy/party_discard.json
Normal file
62
public/images/ui/legacy/party_discard.json
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"textures": [
|
||||
{
|
||||
"image": "party_discard.png",
|
||||
"format": "RGBA8888",
|
||||
"size": {
|
||||
"w": 52,
|
||||
"h": 32
|
||||
},
|
||||
"scale": 1,
|
||||
"frames": [
|
||||
{
|
||||
"filename": "normal",
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"sourceSize": {
|
||||
"w": 52,
|
||||
"h": 16
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 52,
|
||||
"h": 16
|
||||
},
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 52,
|
||||
"h": 16
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "selected",
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"sourceSize": {
|
||||
"w": 52,
|
||||
"h": 16
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 52,
|
||||
"h": 16
|
||||
},
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 16,
|
||||
"w": 52,
|
||||
"h": 16
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"app": "https://www.codeandweb.com/texturepacker",
|
||||
"version": "3.0",
|
||||
"smartupdate": "$TexturePacker:SmartUpdate:17219773dfffd6b1204d988fea3f9462:1127ad21d64bc7ebb9df4fc28f3d2d39:7ad46e8fb4648c3d3d84a746ecb371ea$"
|
||||
}
|
||||
}
|
BIN
public/images/ui/legacy/party_discard.png
Normal file
BIN
public/images/ui/legacy/party_discard.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 214 B |
62
public/images/ui/legacy/party_transfer.json
Normal file
62
public/images/ui/legacy/party_transfer.json
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"textures": [
|
||||
{
|
||||
"image": "party_transfer.png",
|
||||
"format": "RGBA8888",
|
||||
"size": {
|
||||
"w": 52,
|
||||
"h": 32
|
||||
},
|
||||
"scale": 1,
|
||||
"frames": [
|
||||
{
|
||||
"filename": "normal",
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"sourceSize": {
|
||||
"w": 52,
|
||||
"h": 16
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 52,
|
||||
"h": 16
|
||||
},
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 52,
|
||||
"h": 16
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "selected",
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"sourceSize": {
|
||||
"w": 52,
|
||||
"h": 16
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 52,
|
||||
"h": 16
|
||||
},
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 16,
|
||||
"w": 52,
|
||||
"h": 16
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"app": "https://www.codeandweb.com/texturepacker",
|
||||
"version": "3.0",
|
||||
"smartupdate": "$TexturePacker:SmartUpdate:17219773dfffd6b1204d988fea3f9462:1127ad21d64bc7ebb9df4fc28f3d2d39:7ad46e8fb4648c3d3d84a746ecb371ea$"
|
||||
}
|
||||
}
|
BIN
public/images/ui/legacy/party_transfer.png
Normal file
BIN
public/images/ui/legacy/party_transfer.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 214 B |
BIN
public/images/ui/party_bg_double_manage.png
Normal file
BIN
public/images/ui/party_bg_double_manage.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
62
public/images/ui/party_discard.json
Normal file
62
public/images/ui/party_discard.json
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"textures": [
|
||||
{
|
||||
"image": "party_discard.png",
|
||||
"format": "RGBA8888",
|
||||
"size": {
|
||||
"w": 75,
|
||||
"h": 46
|
||||
},
|
||||
"scale": 1,
|
||||
"frames": [
|
||||
{
|
||||
"filename": "normal",
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"sourceSize": {
|
||||
"w": 75,
|
||||
"h": 23
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 75,
|
||||
"h": 23
|
||||
},
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 75,
|
||||
"h": 23
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "selected",
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"sourceSize": {
|
||||
"w": 75,
|
||||
"h": 23
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 75,
|
||||
"h": 23
|
||||
},
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 23,
|
||||
"w": 75,
|
||||
"h": 23
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"app": "https://www.codeandweb.com/texturepacker",
|
||||
"version": "3.0",
|
||||
"smartupdate": "$TexturePacker:SmartUpdate:17219773dfffd6b1204d988fea3f9462:1127ad21d64bc7ebb9df4fc28f3d2d39:7ad46e8fb4648c3d3d84a746ecb371ea$"
|
||||
}
|
||||
}
|
BIN
public/images/ui/party_discard.png
Normal file
BIN
public/images/ui/party_discard.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.8 KiB |
62
public/images/ui/party_transfer.json
Normal file
62
public/images/ui/party_transfer.json
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"textures": [
|
||||
{
|
||||
"image": "party_transfer.png",
|
||||
"format": "RGBA8888",
|
||||
"size": {
|
||||
"w": 75,
|
||||
"h": 46
|
||||
},
|
||||
"scale": 1,
|
||||
"frames": [
|
||||
{
|
||||
"filename": "normal",
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"sourceSize": {
|
||||
"w": 75,
|
||||
"h": 23
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 75,
|
||||
"h": 23
|
||||
},
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 75,
|
||||
"h": 23
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "selected",
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"sourceSize": {
|
||||
"w": 75,
|
||||
"h": 23
|
||||
},
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 75,
|
||||
"h": 23
|
||||
},
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 23,
|
||||
"w": 75,
|
||||
"h": 23
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"app": "https://www.codeandweb.com/texturepacker",
|
||||
"version": "3.0",
|
||||
"smartupdate": "$TexturePacker:SmartUpdate:17219773dfffd6b1204d988fea3f9462:1127ad21d64bc7ebb9df4fc28f3d2d39:7ad46e8fb4648c3d3d84a746ecb371ea$"
|
||||
}
|
||||
}
|
BIN
public/images/ui/party_transfer.png
Normal file
BIN
public/images/ui/party_transfer.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.8 KiB |
@ -2806,6 +2806,19 @@ export default class BattleScene extends SceneBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
tryDiscardHeldItemModifier(itemModifier: PokemonHeldItemModifier, discardQuantity = 1): boolean {
|
||||
const countTaken = Math.min(discardQuantity, itemModifier.stackCount);
|
||||
itemModifier.stackCount -= countTaken;
|
||||
|
||||
const removeOld = itemModifier.stackCount === 0;
|
||||
|
||||
if (removeOld) {
|
||||
return this.removeModifier(itemModifier);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
canTransferHeldItemModifier(itemModifier: PokemonHeldItemModifier, target: Pokemon, transferQuantity = 1): boolean {
|
||||
const mod = itemModifier.clone() as PokemonHeldItemModifier;
|
||||
const source = mod.pokemonId ? mod.getPokemon() : null;
|
||||
|
@ -306,13 +306,6 @@ export class BlockRecoilDamageAttr extends AbAttr {
|
||||
): void {
|
||||
cancelled.value = true;
|
||||
}
|
||||
|
||||
getTriggerMessage(pokemon: Pokemon, abilityName: string, ..._args: any[]) {
|
||||
return i18next.t("abilityTriggers:blockRecoilDamage", {
|
||||
pokemonName: getPokemonNameWithAffix(pokemon),
|
||||
abilityName: abilityName,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,6 +93,10 @@ import { ChargingMove, MoveAttrMap, MoveAttrString, MoveKindString, MoveClassMap
|
||||
import { applyMoveAttrs } from "./apply-attrs";
|
||||
import { frenzyMissFunc, getMoveTargets } from "./move-utils";
|
||||
|
||||
/**
|
||||
* A function used to conditionally determine execution of a given {@linkcode MoveAttr}.
|
||||
* Conventionally returns `true` for success and `false` for failure.
|
||||
*/
|
||||
type MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => boolean;
|
||||
export type UserMoveConditionFunc = (user: Pokemon, move: Move) => boolean;
|
||||
|
||||
@ -1390,18 +1394,31 @@ export class BeakBlastHeaderAttr extends AddBattlerTagHeaderAttr {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attribute to display a message before a move is executed.
|
||||
*/
|
||||
export class PreMoveMessageAttr extends MoveAttr {
|
||||
private message: string | ((user: Pokemon, target: Pokemon, move: Move) => string);
|
||||
/** The message to display or a function returning one */
|
||||
private message: string | ((user: Pokemon, target: Pokemon, move: Move) => string | undefined);
|
||||
|
||||
/**
|
||||
* Create a new {@linkcode PreMoveMessageAttr} to display a message before move execution.
|
||||
* @param message - The message to display before move use, either as a string or a function producing one.
|
||||
* @remarks
|
||||
* If {@linkcode message} evaluates to an empty string (`''`), no message will be displayed
|
||||
* (though the move will still succeed).
|
||||
*/
|
||||
constructor(message: string | ((user: Pokemon, target: Pokemon, move: Move) => string)) {
|
||||
super();
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
const message = typeof this.message === "string"
|
||||
? this.message as string
|
||||
: this.message(user, target, move);
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, _args: any[]): boolean {
|
||||
const message = typeof this.message === "function"
|
||||
? this.message(user, target, move)
|
||||
: this.message;
|
||||
|
||||
// TODO: Consider changing if/when MoveAttr `apply` return values become significant
|
||||
if (message) {
|
||||
globalScene.phaseManager.queueMessage(message, 500);
|
||||
return true;
|
||||
@ -11299,7 +11316,11 @@ export function initMoves() {
|
||||
.attr(ForceSwitchOutAttr, true, SwitchType.SHED_TAIL)
|
||||
.condition(failIfLastInPartyCondition),
|
||||
new SelfStatusMove(MoveId.CHILLY_RECEPTION, PokemonType.ICE, -1, 10, -1, 0, 9)
|
||||
.attr(PreMoveMessageAttr, (user, move) => i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(user) }))
|
||||
.attr(PreMoveMessageAttr, (user, _target, _move) =>
|
||||
// Don't display text if current move phase is follow up (ie move called indirectly)
|
||||
isVirtual((globalScene.phaseManager.getCurrentPhase() as MovePhase).useMode)
|
||||
? ""
|
||||
: i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(user) }))
|
||||
.attr(ChillyReceptionAttr, true),
|
||||
new SelfStatusMove(MoveId.TIDY_UP, PokemonType.NORMAL, -1, 10, -1, 0, 9)
|
||||
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPD ], 1, true)
|
||||
|
@ -751,7 +751,7 @@ export async function catchPokemon(
|
||||
UiMode.POKEDEX_PAGE,
|
||||
pokemon.species,
|
||||
pokemon.formIndex,
|
||||
attributes,
|
||||
[attributes],
|
||||
null,
|
||||
() => {
|
||||
globalScene.ui.setMode(UiMode.MESSAGE).then(() => {
|
||||
|
@ -764,7 +764,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
||||
readonly subLegendary: boolean;
|
||||
readonly legendary: boolean;
|
||||
readonly mythical: boolean;
|
||||
readonly species: string;
|
||||
public category: string;
|
||||
readonly growthRate: GrowthRate;
|
||||
/** The chance (as a decimal) for this Species to be male, or `null` for genderless species */
|
||||
readonly malePercent: number | null;
|
||||
@ -778,7 +778,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
||||
subLegendary: boolean,
|
||||
legendary: boolean,
|
||||
mythical: boolean,
|
||||
species: string,
|
||||
category: string,
|
||||
type1: PokemonType,
|
||||
type2: PokemonType | null,
|
||||
height: number,
|
||||
@ -829,7 +829,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
||||
this.subLegendary = subLegendary;
|
||||
this.legendary = legendary;
|
||||
this.mythical = mythical;
|
||||
this.species = species;
|
||||
this.category = category;
|
||||
this.growthRate = growthRate;
|
||||
this.malePercent = malePercent;
|
||||
this.genderDiffs = genderDiffs;
|
||||
@ -968,6 +968,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
||||
|
||||
localize(): void {
|
||||
this.name = i18next.t(`pokemon:${SpeciesId[this.speciesId].toLowerCase()}`);
|
||||
this.category = i18next.t(`pokemonCategory:${SpeciesId[this.speciesId].toLowerCase()}_category`);
|
||||
}
|
||||
|
||||
getWildSpeciesForLevel(level: number, allowEvolving: boolean, isBoss: boolean, gameMode: GameMode): SpeciesId {
|
||||
|
@ -131,6 +131,7 @@ export class LoadingScene extends SceneBase {
|
||||
|
||||
this.loadImage("party_bg", "ui");
|
||||
this.loadImage("party_bg_double", "ui");
|
||||
this.loadImage("party_bg_double_manage", "ui");
|
||||
this.loadAtlas("party_slot_main", "ui");
|
||||
this.loadAtlas("party_slot", "ui");
|
||||
this.loadImage("party_slot_overlay_lv", "ui");
|
||||
@ -138,6 +139,8 @@ export class LoadingScene extends SceneBase {
|
||||
this.loadAtlas("party_slot_hp_overlay", "ui");
|
||||
this.loadAtlas("party_pb", "ui");
|
||||
this.loadAtlas("party_cancel", "ui");
|
||||
this.loadAtlas("party_discard", "ui");
|
||||
this.loadAtlas("party_transfer", "ui");
|
||||
|
||||
this.loadImage("summary_bg", "ui");
|
||||
this.loadImage("summary_overlay_shiny", "ui");
|
||||
|
@ -668,6 +668,9 @@ export class MovePhase extends BattlePhase {
|
||||
}),
|
||||
500,
|
||||
);
|
||||
|
||||
// Moves with pre-use messages (Magnitude, Chilly Reception, Fickle Beam, etc.) always display their messages even on failure
|
||||
// TODO: This assumes single target for message funcs - is this sustainable?
|
||||
applyMoveAttrs("PreMoveMessageAttr", this.pokemon, this.pokemon.getOpponents(false)[0], this.move.getMove());
|
||||
}
|
||||
|
||||
|
@ -245,6 +245,7 @@ export async function initI18n(): Promise<void> {
|
||||
"pokeball",
|
||||
"pokedexUiHandler",
|
||||
"pokemon",
|
||||
"pokemonCategory",
|
||||
"pokemonEvolutions",
|
||||
"pokemonForm",
|
||||
"pokemonInfo",
|
||||
|
@ -68,7 +68,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||
|
||||
if (context) {
|
||||
context.font = styleOptions.fontSize + "px " + styleOptions.fontFamily;
|
||||
this.transferButtonWidth = context.measureText(i18next.t("modifierSelectUiHandler:transfer")).width;
|
||||
this.transferButtonWidth = context.measureText("Manage Items").width; // Missing "Manage Items" call from locales.
|
||||
this.checkButtonWidth = context.measureText(i18next.t("modifierSelectUiHandler:checkTeam")).width;
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||
this.transferButtonContainer.setVisible(false);
|
||||
ui.add(this.transferButtonContainer);
|
||||
|
||||
const transferButtonText = addTextObject(-4, -2, i18next.t("modifierSelectUiHandler:transfer"), TextStyle.PARTY);
|
||||
const transferButtonText = addTextObject(-4, -2, "Manage Items", TextStyle.PARTY); // Missing "Manage Items" call from locales.
|
||||
transferButtonText.setName("text-transfer-btn");
|
||||
transferButtonText.setOrigin(1, 0);
|
||||
this.transferButtonContainer.add(transferButtonText);
|
||||
|
@ -101,6 +101,11 @@ export enum PartyUiMode {
|
||||
* This is generally used in for Mystery Encounter or special effects that require the player to select a Pokemon
|
||||
*/
|
||||
SELECT,
|
||||
/**
|
||||
* Indicates that the party UI is open to select a party member from which to discard an item from
|
||||
* This type of selection can be cancelled.
|
||||
*/
|
||||
DISCARD,
|
||||
}
|
||||
|
||||
export enum PartyOption {
|
||||
@ -119,6 +124,7 @@ export enum PartyOption {
|
||||
RELEASE,
|
||||
RENAME,
|
||||
SELECT,
|
||||
DISCARD,
|
||||
SCROLL_UP = 1000,
|
||||
SCROLL_DOWN = 1001,
|
||||
FORM_CHANGE_ITEM = 2000,
|
||||
@ -153,6 +159,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
private partySlotsContainer: Phaser.GameObjects.Container;
|
||||
private partySlots: PartySlot[];
|
||||
private partyCancelButton: PartyCancelButton;
|
||||
private PartyDiscardModeButton: PartyDiscardModeButton;
|
||||
private partyMessageBox: Phaser.GameObjects.NineSlice;
|
||||
private moveInfoOverlay: MoveInfoOverlay;
|
||||
|
||||
@ -306,6 +313,12 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
this.iconAnimHandler = new PokemonIconAnimHandler();
|
||||
this.iconAnimHandler.setup();
|
||||
|
||||
const partyDiscardModeButton = new PartyDiscardModeButton(60, -globalScene.game.canvas.height / 15 - 1);
|
||||
|
||||
partyContainer.add(partyDiscardModeButton);
|
||||
|
||||
this.PartyDiscardModeButton = partyDiscardModeButton;
|
||||
|
||||
// prepare move overlay. in case it appears to be too big, set the overlayScale to .5
|
||||
const overlayScale = 1;
|
||||
this.moveInfoOverlay = new MoveInfoOverlay({
|
||||
@ -347,8 +360,14 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
this.showMovePp = args.length > 6 && args[6];
|
||||
|
||||
this.partyContainer.setVisible(true);
|
||||
if (this.isItemManageMode()) {
|
||||
this.partyBg.setTexture(`party_bg${globalScene.currentBattle.double ? "_double_manage" : ""}`);
|
||||
} else {
|
||||
this.partyBg.setTexture(`party_bg${globalScene.currentBattle.double ? "_double" : ""}`);
|
||||
}
|
||||
|
||||
this.populatePartySlots();
|
||||
this.PartyDiscardModeButton.toggleIcon(this.partyUiMode);
|
||||
this.setCursor(0);
|
||||
|
||||
return true;
|
||||
@ -593,7 +612,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
const option = this.options[this.optionsCursor];
|
||||
if (button === Button.LEFT) {
|
||||
/** Decrease quantity for the current item and update UI */
|
||||
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
||||
if (this.isItemManageMode()) {
|
||||
this.transferQuantities[option] =
|
||||
this.transferQuantities[option] === 1
|
||||
? this.transferQuantitiesMax[option]
|
||||
@ -607,7 +626,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
|
||||
if (button === Button.RIGHT) {
|
||||
/** Increase quantity for the current item and update UI */
|
||||
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
||||
if (this.isItemManageMode()) {
|
||||
this.transferQuantities[option] =
|
||||
this.transferQuantities[option] === this.transferQuantitiesMax[option]
|
||||
? 1
|
||||
@ -637,6 +656,34 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
return success;
|
||||
}
|
||||
|
||||
private processDiscardMenuInput(pokemon: PlayerPokemon) {
|
||||
const ui = this.getUi();
|
||||
this.clearOptions();
|
||||
|
||||
const itemModifiers = this.getTransferrableItemsFromPokemon(pokemon);
|
||||
|
||||
let success = true;
|
||||
if (this.optionsCursor === itemModifiers.length) {
|
||||
for (let i = 0; i < itemModifiers.length; i++) {
|
||||
success = globalScene.tryDiscardHeldItemModifier(itemModifiers[i], this.transferQuantities[i]);
|
||||
}
|
||||
} else {
|
||||
success = globalScene.tryDiscardHeldItemModifier(
|
||||
itemModifiers[this.optionsCursor],
|
||||
this.transferQuantities[this.optionsCursor],
|
||||
);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
this.showText("Item has been discarded.", undefined, () => this.showText("", 0), null, true); // missing confirm message call from i18next.t.
|
||||
ui.playSelect();
|
||||
} else {
|
||||
ui.playError();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
private moveOptionCursor(button: Button.UP | Button.DOWN): boolean {
|
||||
if (button === Button.UP) {
|
||||
return this.setCursor(this.optionsCursor ? this.optionsCursor - 1 : this.options.length - 1);
|
||||
@ -723,6 +770,10 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
return this.processModifierTransferModeInput(pokemon);
|
||||
}
|
||||
|
||||
if (this.partyUiMode === PartyUiMode.DISCARD) {
|
||||
return this.processDiscardMenuInput(pokemon);
|
||||
}
|
||||
|
||||
// options specific to the mode (moves)
|
||||
if (this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER) {
|
||||
return this.processRememberMoveModeInput(pokemon);
|
||||
@ -862,7 +913,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
}
|
||||
|
||||
if (button === Button.LEFT || button === Button.RIGHT) {
|
||||
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
||||
if (this.isItemManageMode()) {
|
||||
return this.processModifierTransferModeLeftRightInput(button);
|
||||
}
|
||||
}
|
||||
@ -917,10 +968,17 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
return !(this.partyUiMode === PartyUiMode.FAINT_SWITCH || this.partyUiMode === PartyUiMode.REVIVAL_BLESSING);
|
||||
}
|
||||
|
||||
private isItemManageMode(): boolean {
|
||||
return this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER || this.partyUiMode === PartyUiMode.DISCARD;
|
||||
}
|
||||
|
||||
private processPartyActionInput(): boolean {
|
||||
const ui = this.getUi();
|
||||
if (this.cursor < 6) {
|
||||
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER && !this.transferMode) {
|
||||
if (
|
||||
(this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER && !this.transferMode) ||
|
||||
this.partyUiMode === PartyUiMode.DISCARD
|
||||
) {
|
||||
/** Initialize item quantities for the selected Pokemon */
|
||||
const itemModifiers = globalScene.findModifiers(
|
||||
m =>
|
||||
@ -934,6 +992,24 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
this.showOptions();
|
||||
ui.playSelect();
|
||||
}
|
||||
|
||||
if (this.cursor === 7) {
|
||||
switch (this.partyUiMode) {
|
||||
case PartyUiMode.DISCARD:
|
||||
this.partyUiMode = PartyUiMode.MODIFIER_TRANSFER;
|
||||
ui.playSelect();
|
||||
break;
|
||||
case PartyUiMode.MODIFIER_TRANSFER:
|
||||
this.partyUiMode = PartyUiMode.DISCARD;
|
||||
ui.playSelect();
|
||||
break;
|
||||
default:
|
||||
ui.playError();
|
||||
break;
|
||||
}
|
||||
this.PartyDiscardModeButton.toggleIcon(this.partyUiMode);
|
||||
ui.playSelect();
|
||||
}
|
||||
// Pressing return button
|
||||
if (this.cursor === 6) {
|
||||
if (!this.allowCancel()) {
|
||||
@ -954,6 +1030,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
this.clearTransfer();
|
||||
ui.playSelect();
|
||||
} else if (this.allowCancel()) {
|
||||
this.PartyDiscardModeButton.clear();
|
||||
if (this.selectCallback) {
|
||||
const selectCallback = this.selectCallback;
|
||||
this.selectCallback = null;
|
||||
@ -975,9 +1052,53 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
let success = false;
|
||||
switch (button) {
|
||||
case Button.UP:
|
||||
if (this.cursor === 1) {
|
||||
if (this.isItemManageMode()) {
|
||||
success = this.setCursor(globalScene.currentBattle.double ? 0 : 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this.cursor === 2) {
|
||||
if (this.isItemManageMode()) {
|
||||
success = this.setCursor(globalScene.currentBattle.double ? 7 : 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this.cursor === 6) {
|
||||
if (this.isItemManageMode()) {
|
||||
success = this.setCursor(slotCount <= globalScene.currentBattle.getBattlerCount() ? 7 : slotCount - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this.cursor === 7) {
|
||||
if (this.isItemManageMode()) {
|
||||
success = this.setCursor(globalScene.currentBattle.double && slotCount > 1 ? 1 : 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
success = this.setCursor(this.cursor ? (this.cursor < 6 ? this.cursor - 1 : slotCount - 1) : 6);
|
||||
break;
|
||||
case Button.DOWN:
|
||||
if (this.cursor === 0) {
|
||||
if (this.isItemManageMode()) {
|
||||
success = this.setCursor(globalScene.currentBattle.double && slotCount > 1 ? 1 : 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this.cursor === 1) {
|
||||
if (this.isItemManageMode()) {
|
||||
success = this.setCursor(globalScene.currentBattle.double ? 7 : slotCount > 2 ? 2 : 6);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this.cursor === 7) {
|
||||
if (this.isItemManageMode()) {
|
||||
success = this.setCursor(
|
||||
slotCount > globalScene.currentBattle.getBattlerCount() ? globalScene.currentBattle.getBattlerCount() : 6,
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
success = this.setCursor(this.cursor < 6 ? (this.cursor < slotCount - 1 ? this.cursor + 1 : 6) : 0);
|
||||
break;
|
||||
case Button.LEFT:
|
||||
@ -986,7 +1107,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
}
|
||||
break;
|
||||
case Button.RIGHT:
|
||||
if (slotCount === battlerCount) {
|
||||
if ((this.cursor === 7 && this.isItemManageMode()) || slotCount === battlerCount) {
|
||||
success = this.setCursor(6);
|
||||
break;
|
||||
}
|
||||
@ -1042,11 +1163,15 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
this.partySlots[this.lastCursor].deselect();
|
||||
} else if (this.lastCursor === 6) {
|
||||
this.partyCancelButton.deselect();
|
||||
} else if (this.lastCursor === 7) {
|
||||
this.PartyDiscardModeButton.deselect();
|
||||
}
|
||||
if (cursor < 6) {
|
||||
this.partySlots[cursor].select();
|
||||
} else if (cursor === 6) {
|
||||
this.partyCancelButton.select();
|
||||
} else if (cursor === 7) {
|
||||
this.PartyDiscardModeButton.select();
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
@ -1141,14 +1266,16 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
optionsMessage = i18next.t("partyUiHandler:selectAnotherPokemonToSplice");
|
||||
}
|
||||
break;
|
||||
case PartyUiMode.DISCARD:
|
||||
optionsMessage = "Select a held item to discard.\nUse < and > to change quantity."; //Missing discard i18next.t call message
|
||||
}
|
||||
|
||||
this.showText(optionsMessage, 0);
|
||||
|
||||
this.updateOptions();
|
||||
|
||||
/** When an item is being selected for transfer, the message box is taller as the message occupies two lines */
|
||||
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
||||
/** When an item is being selected for transfer or discard, the message box is taller as the message occupies two lines */
|
||||
if (this.isItemManageMode()) {
|
||||
this.partyMessageBox.setSize(262 - Math.max(this.optionsBg.displayWidth - 56, 0), 42);
|
||||
} else {
|
||||
this.partyMessageBox.setSize(262 - Math.max(this.optionsBg.displayWidth - 56, 0), 30);
|
||||
@ -1274,6 +1401,9 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
this.addCommonOptions(pokemon);
|
||||
}
|
||||
break;
|
||||
case PartyUiMode.DISCARD:
|
||||
this.updateOptionsWithModifierTransferMode(pokemon);
|
||||
break;
|
||||
// TODO: This still needs to be broken up.
|
||||
// It could use a rework differentiating different kind of switches
|
||||
// to treat baton passing separately from switching on faint.
|
||||
@ -1378,7 +1508,8 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
optionName = "↓";
|
||||
} else if (
|
||||
(this.partyUiMode !== PartyUiMode.REMEMBER_MOVE_MODIFIER &&
|
||||
(this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER || this.transferMode)) ||
|
||||
(this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER || this.transferMode) &&
|
||||
this.partyUiMode !== PartyUiMode.DISCARD) ||
|
||||
option === PartyOption.CANCEL
|
||||
) {
|
||||
switch (option) {
|
||||
@ -1441,7 +1572,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
const itemModifiers = this.getItemModifiers(pokemon);
|
||||
const itemModifier = itemModifiers[option];
|
||||
if (
|
||||
this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER &&
|
||||
this.isItemManageMode() &&
|
||||
this.transferQuantitiesMax[option] > 1 &&
|
||||
!this.transferMode &&
|
||||
itemModifier !== undefined &&
|
||||
@ -1471,7 +1602,6 @@ export default class PartyUiHandler extends MessageUiHandler {
|
||||
optionText.x = 15 - this.optionsBg.width;
|
||||
}
|
||||
}
|
||||
|
||||
startTransfer(): void {
|
||||
this.transferMode = true;
|
||||
this.transferCursor = this.cursor;
|
||||
@ -1660,6 +1790,8 @@ class PartySlot extends Phaser.GameObjects.Container {
|
||||
? -184 +
|
||||
(globalScene.currentBattle.double ? -40 : 0) +
|
||||
(28 + (globalScene.currentBattle.double ? 8 : 0)) * slotIndex
|
||||
: partyUiMode === PartyUiMode.MODIFIER_TRANSFER
|
||||
? -124 + (globalScene.currentBattle.double ? -20 : 0) + slotIndex * 55
|
||||
: -124 + (globalScene.currentBattle.double ? -8 : 0) + slotIndex * 64,
|
||||
);
|
||||
|
||||
@ -1916,7 +2048,6 @@ class PartySlot extends Phaser.GameObjects.Container {
|
||||
|
||||
class PartyCancelButton extends Phaser.GameObjects.Container {
|
||||
private selected: boolean;
|
||||
|
||||
private partyCancelBg: Phaser.GameObjects.Sprite;
|
||||
private partyCancelPb: Phaser.GameObjects.Sprite;
|
||||
|
||||
@ -1925,7 +2056,6 @@ class PartyCancelButton extends Phaser.GameObjects.Container {
|
||||
|
||||
this.setup();
|
||||
}
|
||||
|
||||
setup() {
|
||||
const partyCancelBg = globalScene.add.sprite(0, 0, "party_cancel");
|
||||
this.add(partyCancelBg);
|
||||
@ -1963,3 +2093,94 @@ class PartyCancelButton extends Phaser.GameObjects.Container {
|
||||
this.partyCancelPb.setFrame("party_pb");
|
||||
}
|
||||
}
|
||||
|
||||
class PartyDiscardModeButton extends Phaser.GameObjects.Container {
|
||||
private selected: boolean;
|
||||
|
||||
private transferIcon: Phaser.GameObjects.Sprite;
|
||||
private discardIcon: Phaser.GameObjects.Sprite;
|
||||
private partyDiscardPb: Phaser.GameObjects.Sprite;
|
||||
private textBox: Phaser.GameObjects.Text;
|
||||
|
||||
constructor(x: number, y: number) {
|
||||
super(globalScene, x, y);
|
||||
|
||||
this.setup();
|
||||
}
|
||||
|
||||
setup() {
|
||||
this.transferIcon = globalScene.add.sprite(0, 0, "party_transfer");
|
||||
this.discardIcon = globalScene.add.sprite(0, 0, "party_discard");
|
||||
this.partyDiscardPb = globalScene.add.sprite(-20, 0, "party_pb");
|
||||
this.textBox = addTextObject(-8, -7, i18next.t("partyUiHandler:TRANSFER"), TextStyle.PARTY);
|
||||
|
||||
this.add(this.transferIcon);
|
||||
this.add(this.discardIcon);
|
||||
this.add(this.partyDiscardPb);
|
||||
this.add(this.textBox);
|
||||
|
||||
this.clear();
|
||||
}
|
||||
|
||||
select() {
|
||||
if (this.selected) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.selected = true;
|
||||
|
||||
this.transferIcon.setFrame("selected");
|
||||
this.discardIcon.setFrame("selected");
|
||||
this.partyDiscardPb.setFrame("party_pb_sel");
|
||||
}
|
||||
|
||||
deselect() {
|
||||
if (!this.selected) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.selected = false;
|
||||
|
||||
this.transferIcon.setFrame("normal");
|
||||
this.discardIcon.setFrame("normal");
|
||||
this.partyDiscardPb.setFrame("party_pb");
|
||||
}
|
||||
|
||||
toggleIcon(partyMode: number) {
|
||||
switch (partyMode) {
|
||||
case PartyUiMode.DISCARD:
|
||||
this.transferIcon.setVisible(true);
|
||||
this.discardIcon.setVisible(false);
|
||||
this.partyDiscardPb.setVisible(true);
|
||||
this.textBox.setVisible(true);
|
||||
this.textBox.setText(i18next.t("partyUiHandler:TRANSFER"));
|
||||
this.setPosition(
|
||||
globalScene.currentBattle.double ? 64 : 60,
|
||||
globalScene.currentBattle.double ? -48 : -globalScene.game.canvas.height / 15 - 1,
|
||||
);
|
||||
this.transferIcon.displayWidth = this.textBox.text.length * 9 + 3;
|
||||
break;
|
||||
case PartyUiMode.MODIFIER_TRANSFER:
|
||||
this.transferIcon.setVisible(false);
|
||||
this.discardIcon.setVisible(true);
|
||||
this.partyDiscardPb.setVisible(true);
|
||||
this.textBox.setVisible(true);
|
||||
this.textBox.setText("Discard");
|
||||
this.setPosition(
|
||||
globalScene.currentBattle.double ? 64 : 60,
|
||||
globalScene.currentBattle.double ? -48 : -globalScene.game.canvas.height / 15 - 1,
|
||||
);
|
||||
this.discardIcon.displayWidth = this.textBox.text.length * 9 + 3;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.transferIcon.setVisible(false);
|
||||
this.discardIcon.setVisible(false);
|
||||
this.textBox.setVisible(false);
|
||||
this.partyDiscardPb.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
@ -174,6 +174,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
||||
private pokemonCaughtHatchedContainer: Phaser.GameObjects.Container;
|
||||
private pokemonCaughtCountText: Phaser.GameObjects.Text;
|
||||
private pokemonFormText: Phaser.GameObjects.Text;
|
||||
private pokemonCategoryText: Phaser.GameObjects.Text;
|
||||
private pokemonHatchedIcon: Phaser.GameObjects.Sprite;
|
||||
private pokemonHatchedCountText: Phaser.GameObjects.Text;
|
||||
private pokemonShinyIcons: Phaser.GameObjects.Sprite[];
|
||||
@ -409,6 +410,12 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
||||
this.pokemonFormText.setOrigin(0, 0);
|
||||
this.starterSelectContainer.add(this.pokemonFormText);
|
||||
|
||||
this.pokemonCategoryText = addTextObject(100, 18, "Category", TextStyle.WINDOW_ALT, {
|
||||
fontSize: "42px",
|
||||
});
|
||||
this.pokemonCategoryText.setOrigin(1, 0);
|
||||
this.starterSelectContainer.add(this.pokemonCategoryText);
|
||||
|
||||
this.pokemonCaughtHatchedContainer = globalScene.add.container(2, 25);
|
||||
this.pokemonCaughtHatchedContainer.setScale(0.5);
|
||||
this.starterSelectContainer.add(this.pokemonCaughtHatchedContainer);
|
||||
@ -2354,6 +2361,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
||||
this.pokemonCaughtHatchedContainer.setVisible(true);
|
||||
this.pokemonCandyContainer.setVisible(false);
|
||||
this.pokemonFormText.setVisible(false);
|
||||
this.pokemonCategoryText.setVisible(false);
|
||||
|
||||
const defaultDexAttr = globalScene.gameData.getSpeciesDefaultDexAttr(species, true, true);
|
||||
const props = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
|
||||
@ -2382,6 +2390,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
||||
this.pokemonCaughtHatchedContainer.setVisible(false);
|
||||
this.pokemonCandyContainer.setVisible(false);
|
||||
this.pokemonFormText.setVisible(false);
|
||||
this.pokemonCategoryText.setVisible(false);
|
||||
|
||||
this.setSpeciesDetails(species!, {
|
||||
// TODO: is this bang correct?
|
||||
@ -2534,6 +2543,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
||||
this.pokemonNameText.setText(species ? "???" : "");
|
||||
}
|
||||
|
||||
// Setting the category
|
||||
if (isFormCaught) {
|
||||
this.pokemonCategoryText.setText(species.category);
|
||||
} else {
|
||||
this.pokemonCategoryText.setText("");
|
||||
}
|
||||
|
||||
// Setting tint of the sprite
|
||||
if (isFormCaught) {
|
||||
this.species.loadAssets(female!, formIndex, shiny, variant as Variant, true).then(() => {
|
||||
|
@ -1,11 +1,14 @@
|
||||
import { AbilityId } from "#enums/ability-id";
|
||||
import { RandomMoveAttr } from "#app/data/moves/move";
|
||||
import { MoveResult } from "#enums/move-result";
|
||||
import { getPokemonNameWithAffix } from "#app/messages";
|
||||
import { MoveId } from "#enums/move-id";
|
||||
import { SpeciesId } from "#enums/species-id";
|
||||
import { AbilityId } from "#app/enums/ability-id";
|
||||
import { WeatherType } from "#enums/weather-type";
|
||||
import GameManager from "#test/testUtils/gameManager";
|
||||
import i18next from "i18next";
|
||||
import Phaser from "phaser";
|
||||
//import { TurnInitPhase } from "#app/phases/turn-init-phase";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
describe("Moves - Chilly Reception", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
@ -25,95 +28,121 @@ describe("Moves - Chilly Reception", () => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.battleStyle("single")
|
||||
.moveset([MoveId.CHILLY_RECEPTION, MoveId.SNOWSCAPE])
|
||||
.moveset([MoveId.CHILLY_RECEPTION, MoveId.SNOWSCAPE, MoveId.SPLASH, MoveId.METRONOME])
|
||||
.enemyMoveset(MoveId.SPLASH)
|
||||
.enemyAbility(AbilityId.BALL_FETCH)
|
||||
.ability(AbilityId.BALL_FETCH);
|
||||
});
|
||||
|
||||
it("should still change the weather if user can't switch out", async () => {
|
||||
it("should display message before use, switch the user out and change the weather to snow", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
||||
|
||||
const [slowking, meowth] = game.scene.getPlayerParty();
|
||||
|
||||
game.move.select(MoveId.CHILLY_RECEPTION);
|
||||
game.doSelectPartyPokemon(1);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
expect(game.scene.getPlayerPokemon()).toBe(meowth);
|
||||
expect(slowking.isOnField()).toBe(false);
|
||||
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
||||
expect(game.textInterceptor.logs).toContain(
|
||||
i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(slowking) }),
|
||||
);
|
||||
});
|
||||
|
||||
it("should still change weather if user can't switch out", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.SLOWKING]);
|
||||
|
||||
game.move.select(MoveId.CHILLY_RECEPTION);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
||||
expect(game.scene.getPlayerPokemon()?.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||
});
|
||||
|
||||
it("should switch out even if it's snowing", async () => {
|
||||
it("should still switch out even if weather cannot be changed", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
||||
// first turn set up snow with snowscape, try chilly reception on second turn
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.SNOW);
|
||||
|
||||
const [slowking, meowth] = game.scene.getPlayerParty();
|
||||
|
||||
game.move.select(MoveId.SNOWSCAPE);
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
|
||||
await game.phaseInterceptor.to("TurnInitPhase", false);
|
||||
game.move.select(MoveId.CHILLY_RECEPTION);
|
||||
game.doSelectPartyPokemon(1);
|
||||
// TODO: Uncomment lines once wimp out PR fixes force switches to not reset summon data immediately
|
||||
// await game.phaseInterceptor.to("SwitchSummonPhase", false);
|
||||
// expect(slowking.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||
|
||||
await game.toEndOfTurn();
|
||||
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MEOWTH);
|
||||
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
||||
expect(game.scene.getPlayerPokemon()).toBe(meowth);
|
||||
expect(slowking.isOnField()).toBe(false);
|
||||
});
|
||||
|
||||
it("happy case - switch out and weather changes", async () => {
|
||||
// Source: https://replay.pokemonshowdown.com/gen9ou-2367532550
|
||||
it("should fail (while still displaying message) if neither weather change nor switch out succeeds", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.SLOWKING]);
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.SNOW);
|
||||
|
||||
const slowking = game.scene.getPlayerPokemon()!;
|
||||
|
||||
game.move.select(MoveId.SNOWSCAPE);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
|
||||
game.move.select(MoveId.CHILLY_RECEPTION);
|
||||
game.doSelectPartyPokemon(1);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
||||
expect(game.scene.getPlayerPokemon()).toBe(slowking);
|
||||
expect(slowking.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||
expect(game.textInterceptor.logs).toContain(
|
||||
i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(slowking) }),
|
||||
);
|
||||
});
|
||||
|
||||
it("should succeed without message if called indirectly", async () => {
|
||||
vi.spyOn(RandomMoveAttr.prototype, "getMoveOverride").mockReturnValue(MoveId.CHILLY_RECEPTION);
|
||||
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
||||
|
||||
game.move.select(MoveId.CHILLY_RECEPTION);
|
||||
game.doSelectPartyPokemon(1);
|
||||
const [slowking, meowth] = game.scene.getPlayerParty();
|
||||
|
||||
game.move.select(MoveId.METRONOME);
|
||||
game.doSelectPartyPokemon(1);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MEOWTH);
|
||||
expect(game.scene.getPlayerPokemon()).toBe(meowth);
|
||||
expect(slowking.isOnField()).toBe(false);
|
||||
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
||||
expect(game.textInterceptor.logs).not.toContain(
|
||||
i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(slowking) }),
|
||||
);
|
||||
});
|
||||
|
||||
// enemy uses another move and weather doesn't change
|
||||
it("check case - enemy not selecting chilly reception doesn't change weather ", async () => {
|
||||
game.override.battleStyle("single").enemyMoveset([MoveId.CHILLY_RECEPTION, MoveId.TACKLE]).moveset(MoveId.SPLASH);
|
||||
|
||||
// Bugcheck test for enemy AI bug
|
||||
it("check case - enemy not selecting chilly reception doesn't change weather", async () => {
|
||||
game.override.enemyMoveset([MoveId.CHILLY_RECEPTION, MoveId.TACKLE]);
|
||||
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
||||
|
||||
game.move.select(MoveId.SPLASH);
|
||||
await game.move.selectEnemyMove(MoveId.TACKLE);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(undefined);
|
||||
});
|
||||
|
||||
it("enemy trainer - expected behavior ", async () => {
|
||||
game.override
|
||||
.battleStyle("single")
|
||||
.startingWave(8)
|
||||
.enemyMoveset(MoveId.CHILLY_RECEPTION)
|
||||
.enemySpecies(SpeciesId.MAGIKARP)
|
||||
.moveset([MoveId.SPLASH, MoveId.THUNDERBOLT]);
|
||||
|
||||
await game.classicMode.startBattle([SpeciesId.JOLTEON]);
|
||||
const RIVAL_MAGIKARP1 = game.scene.getEnemyPokemon()?.id;
|
||||
|
||||
game.move.select(MoveId.SPLASH);
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
expect(game.scene.getEnemyPokemon()?.id !== RIVAL_MAGIKARP1);
|
||||
|
||||
await game.phaseInterceptor.to("TurnInitPhase", false);
|
||||
game.move.select(MoveId.SPLASH);
|
||||
|
||||
// second chilly reception should still switch out
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
await game.phaseInterceptor.to("TurnInitPhase", false);
|
||||
expect(game.scene.getEnemyPokemon()?.id === RIVAL_MAGIKARP1);
|
||||
game.move.select(MoveId.THUNDERBOLT);
|
||||
|
||||
// enemy chilly recep move should fail: it's snowing and no option to switch out
|
||||
// no crashing
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
await game.phaseInterceptor.to("TurnInitPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
game.move.select(MoveId.SPLASH);
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
expect(game.scene.arena.weather?.weatherType).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
98
test/ui/item-manage-button.test.ts
Normal file
98
test/ui/item-manage-button.test.ts
Normal file
@ -0,0 +1,98 @@
|
||||
import { BerryType } from "#app/enums/berry-type";
|
||||
import { Button } from "#app/enums/buttons";
|
||||
import { MoveId } from "#enums/move-id";
|
||||
import { SpeciesId } from "#enums/species-id";
|
||||
import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler";
|
||||
import PartyUiHandler, { PartyUiMode } from "#app/ui/party-ui-handler";
|
||||
import { UiMode } from "#enums/ui-mode";
|
||||
import GameManager from "#test/testUtils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
|
||||
describe("UI - Transfer Items", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({
|
||||
type: Phaser.HEADLESS,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override.battleStyle("single");
|
||||
game.override.startingLevel(100);
|
||||
game.override.startingWave(1);
|
||||
game.override.startingHeldItems([
|
||||
{ name: "BERRY", count: 1, type: BerryType.SITRUS },
|
||||
{ name: "BERRY", count: 2, type: BerryType.APICOT },
|
||||
{ name: "BERRY", count: 2, type: BerryType.LUM },
|
||||
]);
|
||||
game.override.moveset([MoveId.DRAGON_CLAW]);
|
||||
game.override.enemySpecies(SpeciesId.MAGIKARP);
|
||||
game.override.enemyMoveset([MoveId.SPLASH]);
|
||||
|
||||
await game.classicMode.startBattle([SpeciesId.RAYQUAZA, SpeciesId.RAYQUAZA, SpeciesId.RAYQUAZA]);
|
||||
|
||||
game.move.select(MoveId.DRAGON_CLAW);
|
||||
});
|
||||
|
||||
it("manage button exists in the proper screen", async () => {
|
||||
game.onNextPrompt("SelectModifierPhase", UiMode.MODIFIER_SELECT, () => {
|
||||
expect(game.scene.ui.getHandler()).toBeInstanceOf(ModifierSelectUiHandler);
|
||||
|
||||
const handler = game.scene.ui.getHandler() as ModifierSelectUiHandler;
|
||||
handler.setCursor(1); //manage items menu, manage button should exist
|
||||
handler.processInput(Button.ACTION);
|
||||
|
||||
void game.scene.ui.setModeWithoutClear(UiMode.PARTY, PartyUiMode.MODIFIER_TRANSFER);
|
||||
});
|
||||
|
||||
await game.phaseInterceptor.to("BattleEndPhase");
|
||||
|
||||
game.phaseInterceptor.addToNextPrompt("SelectModifierPhase", UiMode.PARTY, () => {
|
||||
expect(game.scene.ui.getHandler()).toBeInstanceOf(PartyUiHandler);
|
||||
const handler = game.scene.ui.getHandler() as PartyUiHandler;
|
||||
|
||||
handler.processInput(Button.DOWN);
|
||||
handler.processInput(Button.ACTION);
|
||||
expect(handler.optionsContainer.list.length).toBe(0); //should select manage button,which has no menu
|
||||
|
||||
game.phaseInterceptor.unlock();
|
||||
});
|
||||
|
||||
await game.phaseInterceptor.to("SelectModifierPhase");
|
||||
}, 20000);
|
||||
|
||||
it("manage button doesn't exist in the other screens", async () => {
|
||||
game.onNextPrompt("SelectModifierPhase", UiMode.MODIFIER_SELECT, () => {
|
||||
expect(game.scene.ui.getHandler()).toBeInstanceOf(ModifierSelectUiHandler);
|
||||
|
||||
const handler = game.scene.ui.getHandler() as ModifierSelectUiHandler;
|
||||
handler.setCursor(2); //check team menu,manage button shouldn't exist
|
||||
handler.processInput(Button.ACTION);
|
||||
|
||||
void game.scene.ui.setModeWithoutClear(UiMode.PARTY, PartyUiMode.MODIFIER_TRANSFER);
|
||||
});
|
||||
|
||||
await game.phaseInterceptor.to("BattleEndPhase");
|
||||
|
||||
game.phaseInterceptor.addToNextPrompt("SelectModifierPhase", UiMode.PARTY, () => {
|
||||
expect(game.scene.ui.getHandler()).toBeInstanceOf(PartyUiHandler);
|
||||
const handler = game.scene.ui.getHandler() as PartyUiHandler;
|
||||
|
||||
handler.processInput(Button.DOWN);
|
||||
handler.processInput(Button.ACTION);
|
||||
expect(handler.optionsContainer.list.length).toBeGreaterThan(0); //should select a pokemon, which has at least the cancel option
|
||||
|
||||
game.phaseInterceptor.unlock();
|
||||
});
|
||||
|
||||
await game.phaseInterceptor.to("SelectModifierPhase");
|
||||
}, 20000);
|
||||
});
|
Loading…
Reference in New Issue
Block a user