mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-14 19:39:29 +02:00
Merge branch 'beta' into flip_stats_challange
This commit is contained in:
commit
a9e0dd5d80
@ -1191,6 +1191,9 @@ export default class BattleScene extends SceneBase {
|
||||
onComplete: () => {
|
||||
this.clearPhaseQueue();
|
||||
|
||||
this.ui.freeUIData();
|
||||
this.uiContainer.remove(this.ui, true);
|
||||
this.uiContainer.destroy();
|
||||
this.children.removeAll(true);
|
||||
this.game.domContainer.innerHTML = "";
|
||||
this.launchBattle();
|
||||
|
@ -7878,31 +7878,6 @@ export class LastResortAttr extends MoveAttr {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The move only works if the target has a transferable held item
|
||||
* @extends MoveAttr
|
||||
* @see {@linkcode getCondition}
|
||||
*/
|
||||
export class AttackedByItemAttr extends MoveAttr {
|
||||
/**
|
||||
* @returns the {@linkcode MoveConditionFunc} for this {@linkcode Move}
|
||||
*/
|
||||
getCondition(): MoveConditionFunc {
|
||||
return (user: Pokemon, target: Pokemon, move: Move) => {
|
||||
const heldItems = target.getHeldItems().filter(i => i.isTransferable);
|
||||
if (heldItems.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const itemName = heldItems[0]?.type?.name ?? "item";
|
||||
globalScene.queueMessage(i18next.t("moveTriggers:attackedByItem", { pokemonName: getPokemonNameWithAffix(target), itemName: itemName }));
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class VariableTargetAttr extends MoveAttr {
|
||||
private targetChangeFunc: (user: Pokemon, target: Pokemon, move: Move) => number;
|
||||
|
||||
@ -7976,6 +7951,18 @@ const failIfLastInPartyCondition: MoveConditionFunc = (user: Pokemon, target: Po
|
||||
|
||||
const failIfGhostTypeCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => !target.isOfType(Type.GHOST);
|
||||
|
||||
const failIfNoTargetHeldItemsCondition: MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => target.getHeldItems().filter(i => i.isTransferable)?.length > 0;
|
||||
|
||||
const attackedByItemMessageFunc = (user: Pokemon, target: Pokemon, move: Move) => {
|
||||
const heldItems = target.getHeldItems().filter(i => i.isTransferable);
|
||||
if (heldItems.length === 0) {
|
||||
return "";
|
||||
}
|
||||
const itemName = heldItems[0]?.type?.name ?? "item";
|
||||
const message: string = i18next.t("moveTriggers:attackedByItem", { pokemonName: getPokemonNameWithAffix(target), itemName: itemName });
|
||||
return message;
|
||||
};
|
||||
|
||||
export type MoveAttrFilter = (attr: MoveAttr) => boolean;
|
||||
|
||||
function applyMoveAttrsInternal(attrFilter: MoveAttrFilter, user: Pokemon | null, target: Pokemon | null, move: Move, args: any[]): Promise<void> {
|
||||
@ -10641,7 +10628,8 @@ export function initMoves() {
|
||||
new AttackMove(Moves.LASH_OUT, Type.DARK, MoveCategory.PHYSICAL, 75, 100, 5, -1, 0, 8)
|
||||
.attr(MovePowerMultiplierAttr, (user, _target, _move) => user.turnData.statStagesDecreased ? 2 : 1),
|
||||
new AttackMove(Moves.POLTERGEIST, Type.GHOST, MoveCategory.PHYSICAL, 110, 90, 5, -1, 0, 8)
|
||||
.attr(AttackedByItemAttr)
|
||||
.condition(failIfNoTargetHeldItemsCondition)
|
||||
.attr(PreMoveMessageAttr, attackedByItemMessageFunc)
|
||||
.makesContact(false),
|
||||
new StatusMove(Moves.CORROSIVE_GAS, Type.POISON, 100, 40, -1, 0, 8)
|
||||
.target(MoveTarget.ALL_NEAR_OTHERS)
|
||||
|
@ -948,19 +948,6 @@ export class PokemonForm extends PokemonSpeciesForm {
|
||||
}
|
||||
}
|
||||
|
||||
export const noStarterFormKeys: string[] = [
|
||||
SpeciesFormKey.MEGA,
|
||||
SpeciesFormKey.MEGA_X,
|
||||
SpeciesFormKey.MEGA_Y,
|
||||
SpeciesFormKey.PRIMAL,
|
||||
SpeciesFormKey.ORIGIN,
|
||||
SpeciesFormKey.THERIAN,
|
||||
SpeciesFormKey.GIGANTAMAX,
|
||||
SpeciesFormKey.GIGANTAMAX_RAPID,
|
||||
SpeciesFormKey.GIGANTAMAX_SINGLE,
|
||||
SpeciesFormKey.ETERNAMAX
|
||||
].map(k => k.toString());
|
||||
|
||||
/**
|
||||
* Method to get the daily list of starters with Pokerus.
|
||||
* @returns A list of starters with Pokerus
|
||||
|
@ -6,7 +6,7 @@ import type { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
|
||||
import type Pokemon from "#app/field/pokemon";
|
||||
import { pokemonPrevolutions } from "#app/data/balance/pokemon-evolutions";
|
||||
import type PokemonSpecies from "#app/data/pokemon-species";
|
||||
import { allSpecies, getPokemonSpecies, noStarterFormKeys } from "#app/data/pokemon-species";
|
||||
import { allSpecies, getPokemonSpecies } from "#app/data/pokemon-species";
|
||||
import { speciesStarterCosts } from "#app/data/balance/starters";
|
||||
import * as Utils from "#app/utils";
|
||||
import Overrides from "#app/overrides";
|
||||
@ -1619,9 +1619,6 @@ export class GameData {
|
||||
const dexEntry = this.dexData[species.speciesId];
|
||||
const caughtAttr = dexEntry.caughtAttr;
|
||||
const formIndex = pokemon.formIndex;
|
||||
if (noStarterFormKeys.includes(pokemon.getFormKey())) {
|
||||
pokemon.formIndex = 0;
|
||||
}
|
||||
const dexAttr = pokemon.getDexAttr();
|
||||
pokemon.formIndex = formIndex;
|
||||
|
||||
|
@ -364,6 +364,8 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||
success = this.setCursor(0);
|
||||
} else if (this.rowCursor < this.shopOptionsRows.length + 1) {
|
||||
success = this.setRowCursor(this.rowCursor + 1);
|
||||
} else {
|
||||
success = this.setRowCursor(0);
|
||||
}
|
||||
break;
|
||||
case Button.DOWN:
|
||||
@ -371,13 +373,15 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||
success = this.setRowCursor(this.rowCursor - 1);
|
||||
} else if (this.lockRarityButtonContainer.visible && this.cursor === 0) {
|
||||
success = this.setCursor(3);
|
||||
} else {
|
||||
success = this.setRowCursor(this.shopOptionsRows.length + 1);
|
||||
}
|
||||
break;
|
||||
case Button.LEFT:
|
||||
if (!this.rowCursor) {
|
||||
switch (this.cursor) {
|
||||
case 0:
|
||||
success = false;
|
||||
success = this.setCursor(2);
|
||||
break;
|
||||
case 1:
|
||||
if (this.lockRarityButtonContainer.visible) {
|
||||
@ -395,11 +399,21 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||
success = false;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (this.lockRarityButtonContainer.visible) {
|
||||
success = this.setCursor(2);
|
||||
} else {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
} else if (this.cursor) {
|
||||
success = this.setCursor(this.cursor - 1);
|
||||
} else if (this.rowCursor === 1 && this.rerollButtonContainer.visible) {
|
||||
success = this.setRowCursor(0);
|
||||
} else {
|
||||
if (this.rowCursor === 1 && this.options.length === 0) {
|
||||
success = false;
|
||||
} else {
|
||||
success = this.setCursor(this.getRowItems(this.rowCursor) - 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Button.RIGHT:
|
||||
@ -416,7 +430,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||
success = this.setCursor(2);
|
||||
break;
|
||||
case 2:
|
||||
success = false;
|
||||
success = this.setCursor(0);
|
||||
break;
|
||||
case 3:
|
||||
if (this.transferButtonContainer.visible) {
|
||||
@ -428,8 +442,12 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||
}
|
||||
} else if (this.cursor < this.getRowItems(this.rowCursor) - 1) {
|
||||
success = this.setCursor(this.cursor + 1);
|
||||
} else if (this.rowCursor === 1 && this.transferButtonContainer.visible) {
|
||||
success = this.setRowCursor(0);
|
||||
} else {
|
||||
if (this.rowCursor === 1 && this.options.length === 0) {
|
||||
success = this.setRowCursor(0);
|
||||
} else {
|
||||
success = this.setCursor(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -519,6 +537,14 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
||||
newCursor = 2;
|
||||
}
|
||||
}
|
||||
// Allows to find lock rarity button when looping from the top
|
||||
if (rowCursor === 0 && lastRowCursor > 1 && newCursor === 0 && this.lockRarityButtonContainer.visible) {
|
||||
newCursor = 3;
|
||||
}
|
||||
// Allows to loop to top when lock rarity button is shown
|
||||
if (rowCursor === this.shopOptionsRows.length + 1 && lastRowCursor === 0 && this.cursor === 3) {
|
||||
newCursor = 0;
|
||||
}
|
||||
this.cursor = -1;
|
||||
this.setCursor(newCursor);
|
||||
return true;
|
||||
|
@ -157,6 +157,12 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler {
|
||||
success = (this.cursor === 0) ? this.setCursor(this.cursor) : this.setCursor(this.cursor - 1, cursorPosition);
|
||||
} else if (this.scrollCursor) {
|
||||
success = this.setScrollCursor(this.scrollCursor - 1, cursorPosition);
|
||||
} else if ((this.cursor === 0) && (this.scrollCursor === 0)) {
|
||||
this.setScrollCursor(SESSION_SLOTS_COUNT - SLOTS_ON_SCREEN);
|
||||
// Revert to avoid an extra session slot sticking out
|
||||
this.revertSessionSlot(SESSION_SLOTS_COUNT - SLOTS_ON_SCREEN);
|
||||
this.setCursor(SLOTS_ON_SCREEN - 1);
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
case Button.DOWN:
|
||||
@ -164,6 +170,11 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler {
|
||||
success = this.setCursor(this.cursor + 1, cursorPosition);
|
||||
} else if (this.scrollCursor < SESSION_SLOTS_COUNT - SLOTS_ON_SCREEN) {
|
||||
success = this.setScrollCursor(this.scrollCursor + 1, cursorPosition);
|
||||
} else if ((this.cursor === SLOTS_ON_SCREEN - 1) && (this.scrollCursor === SESSION_SLOTS_COUNT - SLOTS_ON_SCREEN)) {
|
||||
this.setScrollCursor(0);
|
||||
this.revertSessionSlot(SLOTS_ON_SCREEN - 1);
|
||||
this.setCursor(0);
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
case Button.RIGHT:
|
||||
|
@ -89,6 +89,13 @@ export class NavigationManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes menus from the manager in preparation for reset
|
||||
*/
|
||||
public clearNavigationMenus() {
|
||||
this.navigationMenus.length = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default class NavigationMenu extends Phaser.GameObjects.Container {
|
||||
|
@ -2698,6 +2698,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||
this.updateScroll();
|
||||
};
|
||||
|
||||
override destroy(): void {
|
||||
// Without this the reference gets hung up and no startercontainers get GCd
|
||||
this.starterContainers = [];
|
||||
}
|
||||
|
||||
updateScroll = () => {
|
||||
const maxColumns = 9;
|
||||
const maxRows = 9;
|
||||
|
@ -62,4 +62,9 @@ export default abstract class UiHandler {
|
||||
clear() {
|
||||
this.active = false;
|
||||
}
|
||||
/**
|
||||
* To be implemented by individual handlers when necessary to free memory
|
||||
* Called when {@linkcode BattleScene} is reset
|
||||
*/
|
||||
destroy(): void {}
|
||||
}
|
||||
|
11
src/ui/ui.ts
11
src/ui/ui.ts
@ -53,6 +53,7 @@ import TestDialogueUiHandler from "#app/ui/test-dialogue-ui-handler";
|
||||
import AutoCompleteUiHandler from "./autocomplete-ui-handler";
|
||||
import { Device } from "#enums/devices";
|
||||
import MysteryEncounterUiHandler from "./mystery-encounter-ui-handler";
|
||||
import { NavigationManager } from "./settings/navigationMenu";
|
||||
|
||||
export enum Mode {
|
||||
MESSAGE,
|
||||
@ -614,4 +615,14 @@ export default class UI extends Phaser.GameObjects.Container {
|
||||
return globalScene.inputMethod;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to free memory held by UI handlers
|
||||
* and clears menus from {@linkcode NavigationManager} to prepare for reset
|
||||
*/
|
||||
public freeUIData(): void {
|
||||
this.handlers.forEach(h => h.destroy());
|
||||
this.handlers = [];
|
||||
NavigationManager.getInstance().clearNavigationMenus();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user