mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-01 14:02:18 +02:00
Pokemon class can add held items
This commit is contained in:
parent
167c5f1635
commit
662d7d3a6a
@ -259,6 +259,7 @@ import { MoveFlags } from "#enums/MoveFlags";
|
||||
import { timedEventManager } from "#app/global-event-manager";
|
||||
import { loadMoveAnimations } from "#app/sprites/pokemon-asset-loader";
|
||||
import { ResetStatusPhase } from "#app/phases/reset-status-phase";
|
||||
import { allHeldItems, HeldItemType } from "#app/modifier/held-items";
|
||||
|
||||
export enum LearnMoveSituation {
|
||||
MISC,
|
||||
@ -341,6 +342,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
|
||||
private shinySparkle: Phaser.GameObjects.Sprite;
|
||||
|
||||
private heldItems: [HeldItemType, number][] = [];
|
||||
|
||||
constructor(
|
||||
x: number,
|
||||
y: number,
|
||||
@ -1186,6 +1189,22 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
) as PokemonHeldItemModifier[];
|
||||
}
|
||||
|
||||
getHeldItems2(): [HeldItemType, number][] {
|
||||
return this.heldItems;
|
||||
}
|
||||
|
||||
addHeldItem(itemType: HeldItemType, stack: number) {
|
||||
const maxStack = allHeldItems[itemType].getMaxStackCount();
|
||||
|
||||
const existing = this.heldItems.find(([type]) => type === itemType);
|
||||
|
||||
if (existing) {
|
||||
existing[1] = Math.min(existing[1] + stack, maxStack);
|
||||
} else {
|
||||
this.heldItems.push([itemType, Math.min(stack, maxStack)]);
|
||||
}
|
||||
}
|
||||
|
||||
updateScale(): void {
|
||||
this.setScale(this.getSpriteScale());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user