mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-09 14:47:12 +02:00
HeldItem .apply() methods do not really need the stack as input, just the pokemon
This commit is contained in:
parent
41a4c9ec2d
commit
da18bf6ea9
@ -55,7 +55,8 @@ export class AttackTypeBoosterHeldItem extends HeldItem {
|
||||
return `${HeldItemNames[this.type]?.toLowerCase()}`;
|
||||
}
|
||||
|
||||
apply(stackCount: number, moveType: PokemonType, movePower: NumberHolder): void {
|
||||
apply(pokemon: Pokemon, moveType: PokemonType, movePower: NumberHolder): void {
|
||||
const stackCount = pokemon.heldItemManager.getStack(this.type);
|
||||
if (moveType === this.moveType && movePower.value >= 1) {
|
||||
movePower.value = Math.floor(movePower.value * (1 + stackCount * this.powerBoost));
|
||||
}
|
||||
@ -64,9 +65,9 @@ export class AttackTypeBoosterHeldItem extends HeldItem {
|
||||
|
||||
export function applyAttackTypeBoosterHeldItem(pokemon: Pokemon, moveType: PokemonType, movePower: NumberHolder) {
|
||||
if (pokemon) {
|
||||
for (const [item, props] of Object.entries(pokemon.heldItemManager.getHeldItems())) {
|
||||
for (const item of Object.keys(pokemon.heldItemManager.getHeldItems())) {
|
||||
if (allHeldItems[item] instanceof AttackTypeBoosterHeldItem) {
|
||||
allHeldItems[item].apply(props.stack, moveType, movePower);
|
||||
allHeldItems[item].apply(pokemon, moveType, movePower);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,8 @@ export class HitHealHeldItem extends HeldItem {
|
||||
* @param pokemon The {@linkcode Pokemon} that holds the item
|
||||
* @returns `true` if the {@linkcode Pokemon} was healed
|
||||
*/
|
||||
apply(stackCount: number, pokemon: Pokemon): boolean {
|
||||
apply(pokemon: Pokemon): boolean {
|
||||
const stackCount = pokemon.heldItemManager.getStack(this.type);
|
||||
if (pokemon.turnData.totalDamageDealt && !pokemon.isFullHp()) {
|
||||
// TODO: this shouldn't be undefined AFAIK
|
||||
globalScene.unshiftPhase(
|
||||
@ -46,9 +47,9 @@ export class HitHealHeldItem extends HeldItem {
|
||||
|
||||
export function applyHitHealHeldItem(pokemon: Pokemon) {
|
||||
if (pokemon) {
|
||||
for (const [item, props] of Object.entries(pokemon.heldItemManager.getHeldItems())) {
|
||||
for (const item of Object.keys(pokemon.heldItemManager.getHeldItems())) {
|
||||
if (allHeldItems[item] instanceof HitHealHeldItem) {
|
||||
allHeldItems[item].apply(props.stack, pokemon);
|
||||
allHeldItems[item].apply(pokemon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,8 @@ export class TurnHealHeldItem extends HeldItem {
|
||||
return "leftovers";
|
||||
}
|
||||
|
||||
apply(stackCount: number, pokemon: Pokemon): boolean {
|
||||
apply(pokemon: Pokemon): boolean {
|
||||
const stackCount = pokemon.heldItemManager.getStack(this.type);
|
||||
if (pokemon.isFullHp()) {
|
||||
return false;
|
||||
}
|
||||
@ -41,9 +42,9 @@ export class TurnHealHeldItem extends HeldItem {
|
||||
|
||||
export function applyTurnHealHeldItem(pokemon: Pokemon) {
|
||||
if (pokemon) {
|
||||
for (const [item, props] of Object.entries(pokemon.heldItemManager.getHeldItems())) {
|
||||
for (const item of Object.keys(pokemon.heldItemManager.getHeldItems())) {
|
||||
if (allHeldItems[item] instanceof TurnHealHeldItem) {
|
||||
allHeldItems[item].apply(props.stack, pokemon);
|
||||
allHeldItems[item].apply(pokemon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user