mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-14 03:19:28 +02:00
Fixed Pickup
This commit is contained in:
parent
3891ef5f85
commit
29af976c49
@ -12,7 +12,7 @@ import {
|
|||||||
} from "#app/utils/common";
|
} from "#app/utils/common";
|
||||||
import Trainer, { TrainerVariant } from "./field/trainer";
|
import Trainer, { TrainerVariant } from "./field/trainer";
|
||||||
import type { GameMode } from "./game-mode";
|
import type { GameMode } from "./game-mode";
|
||||||
import { MoneyMultiplierModifier, PokemonHeldItemModifier } from "./modifier/modifier";
|
import { MoneyMultiplierModifier } from "./modifier/modifier";
|
||||||
import type { PokeballType } from "#enums/pokeball";
|
import type { PokeballType } from "#enums/pokeball";
|
||||||
import { trainerConfigs } from "#app/data/trainers/trainer-config";
|
import { trainerConfigs } from "#app/data/trainers/trainer-config";
|
||||||
import { SpeciesFormKey } from "#enums/species-form-key";
|
import { SpeciesFormKey } from "#enums/species-form-key";
|
||||||
@ -33,6 +33,7 @@ import { ModifierTier } from "#app/modifier/modifier-tier";
|
|||||||
import type { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
import type { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||||
import { BattleType } from "#enums/battle-type";
|
import { BattleType } from "#enums/battle-type";
|
||||||
import { ClassicFixedBossWaves } from "#enums/fixed-boss-waves";
|
import { ClassicFixedBossWaves } from "#enums/fixed-boss-waves";
|
||||||
|
import type { HeldItemId } from "#enums/held-item-id";
|
||||||
|
|
||||||
export enum BattlerIndex {
|
export enum BattlerIndex {
|
||||||
ATTACKER = -1,
|
ATTACKER = -1,
|
||||||
@ -77,7 +78,7 @@ export default class Battle {
|
|||||||
public turnCommands: TurnCommands;
|
public turnCommands: TurnCommands;
|
||||||
public playerParticipantIds: Set<number> = new Set<number>();
|
public playerParticipantIds: Set<number> = new Set<number>();
|
||||||
public battleScore = 0;
|
public battleScore = 0;
|
||||||
public postBattleLoot: PokemonHeldItemModifier[] = [];
|
public postBattleLoot: HeldItemId[] = [];
|
||||||
public escapeAttempts = 0;
|
public escapeAttempts = 0;
|
||||||
public lastMove: MoveId;
|
public lastMove: MoveId;
|
||||||
public battleSeed: string = randomString(16, true);
|
public battleSeed: string = randomString(16, true);
|
||||||
@ -176,19 +177,7 @@ export default class Battle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addPostBattleLoot(enemyPokemon: EnemyPokemon): void {
|
addPostBattleLoot(enemyPokemon: EnemyPokemon): void {
|
||||||
this.postBattleLoot.push(
|
this.postBattleLoot.push(...enemyPokemon.getHeldItems());
|
||||||
...globalScene
|
|
||||||
.findModifiers(
|
|
||||||
m => m instanceof PokemonHeldItemModifier && m.pokemonId === enemyPokemon.id && m.isTransferable,
|
|
||||||
false,
|
|
||||||
)
|
|
||||||
.map(i => {
|
|
||||||
const ret = i as PokemonHeldItemModifier;
|
|
||||||
//@ts-ignore - this is awful to fix/change
|
|
||||||
ret.pokemonId = null;
|
|
||||||
return ret;
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pickUpScatteredMoney(): void {
|
pickUpScatteredMoney(): void {
|
||||||
|
@ -35,7 +35,6 @@ import {
|
|||||||
} from "#app/data/moves/move";
|
} from "#app/data/moves/move";
|
||||||
import { allMoves } from "../data-lists";
|
import { allMoves } from "../data-lists";
|
||||||
import { ArenaTagSide } from "#app/data/arena-tag";
|
import { ArenaTagSide } from "#app/data/arena-tag";
|
||||||
import { BerryModifier, type PokemonHeldItemModifier } from "#app/modifier/modifier";
|
|
||||||
import { TerrainType } from "#app/data/terrain";
|
import { TerrainType } from "#app/data/terrain";
|
||||||
import {
|
import {
|
||||||
SpeciesFormChangeAbilityTrigger,
|
SpeciesFormChangeAbilityTrigger,
|
||||||
@ -44,7 +43,6 @@ import {
|
|||||||
} from "#app/data/pokemon-forms";
|
} from "#app/data/pokemon-forms";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import { Command } from "#app/ui/command-ui-handler";
|
import { Command } from "#app/ui/command-ui-handler";
|
||||||
import { BerryModifierType } from "#app/modifier/modifier-type";
|
|
||||||
import { getPokeballName } from "#app/data/pokeball";
|
import { getPokeballName } from "#app/data/pokeball";
|
||||||
import { BattleType } from "#enums/battle-type";
|
import { BattleType } from "#enums/battle-type";
|
||||||
import type { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
|
import type { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
|
||||||
@ -6203,13 +6201,13 @@ export class PostBattleAbAttr extends AbAttr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class PostBattleLootAbAttr extends PostBattleAbAttr {
|
export class PostBattleLootAbAttr extends PostBattleAbAttr {
|
||||||
private randItem?: PokemonHeldItemModifier;
|
private randItem?: HeldItemId;
|
||||||
|
|
||||||
override canApplyPostBattle(pokemon: Pokemon, _passive: boolean, simulated: boolean, args: any[]): boolean {
|
override canApplyPostBattle(pokemon: Pokemon, _passive: boolean, simulated: boolean, args: any[]): boolean {
|
||||||
const postBattleLoot = globalScene.currentBattle.postBattleLoot;
|
const postBattleLoot = globalScene.currentBattle.postBattleLoot;
|
||||||
if (!simulated && postBattleLoot.length && args[0]) {
|
if (!simulated && postBattleLoot.length && args[0]) {
|
||||||
this.randItem = randSeedItem(postBattleLoot);
|
this.randItem = randSeedItem(postBattleLoot);
|
||||||
return globalScene.canTransferHeldItemModifier(this.randItem, pokemon, 1);
|
return pokemon.heldItemManager.getStack(this.randItem) < allHeldItems[this.randItem].maxStackCount;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -6223,12 +6221,12 @@ export class PostBattleLootAbAttr extends PostBattleAbAttr {
|
|||||||
this.randItem = randSeedItem(postBattleLoot);
|
this.randItem = randSeedItem(postBattleLoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (globalScene.tryTransferHeldItemModifier(this.randItem, pokemon, true, 1, true, undefined, false)) {
|
if (pokemon.heldItemManager.add(this.randItem)) {
|
||||||
postBattleLoot.splice(postBattleLoot.indexOf(this.randItem), 1);
|
postBattleLoot.splice(postBattleLoot.indexOf(this.randItem), 1);
|
||||||
globalScene.phaseManager.queueMessage(
|
globalScene.phaseManager.queueMessage(
|
||||||
i18next.t("abilityTriggers:postBattleLoot", {
|
i18next.t("abilityTriggers:postBattleLoot", {
|
||||||
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
||||||
itemName: this.randItem.type.name,
|
itemName: allHeldItems[this.randItem].name,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -73,16 +73,21 @@ export class PokemonItemManager {
|
|||||||
return item ? item.stack : 0;
|
return item ? item.stack : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
add(itemType: HeldItemId, addStack = 1, data?: HELD_ITEM_DATA) {
|
add(itemType: HeldItemId, addStack = 1, data?: HELD_ITEM_DATA): boolean {
|
||||||
const maxStack = allHeldItems[itemType].getMaxStackCount();
|
const maxStack = allHeldItems[itemType].getMaxStackCount();
|
||||||
const item = this.heldItems[itemType];
|
const item = this.heldItems[itemType];
|
||||||
|
|
||||||
if (item) {
|
if (item) {
|
||||||
// TODO: We may want an error message of some kind instead
|
// TODO: We may want an error message of some kind instead
|
||||||
item.stack = Math.min(item.stack + addStack, maxStack);
|
if (item.stack < maxStack) {
|
||||||
|
item.stack = Math.min(item.stack + addStack, maxStack);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.heldItems[itemType] = { stack: Math.min(addStack, maxStack), disabled: false, data: data };
|
this.heldItems[itemType] = { stack: Math.min(addStack, maxStack), disabled: false, data: data };
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(itemType: HeldItemId, removeStack = 1, all = false) {
|
remove(itemType: HeldItemId, removeStack = 1, all = false) {
|
||||||
|
Loading…
Reference in New Issue
Block a user