mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-07 00:42:16 +02:00
Implemented all feedback from Tempo-anon. Tsdoc created for class and apply, Unnessesary comments removed, getMyHeldItems removed as a function and made inline.
This commit is contained in:
parent
18b8394cb3
commit
37d642890e
@ -2654,12 +2654,34 @@ export class LessPPMorePowerAttr extends VariablePowerAttr {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the Fling attribute which extends VariablePowerAttr.
|
||||
* This class handles the logic for the Fling move in the game.
|
||||
*/
|
||||
export class FlingAttr extends VariablePowerAttr {
|
||||
protected randomItem;
|
||||
protected randomItem: string;
|
||||
|
||||
/**
|
||||
* Applies the Fling move logic to the given user and target Pokémon.
|
||||
* Determines the random item to be used, calculates power, and removes the item.
|
||||
*
|
||||
* @param user - The Pokémon using the move.
|
||||
* @param target - The target Pokémon.
|
||||
* @param move - The move being used.
|
||||
* @param args - Additional arguments for the move. The first element is expected to be a Utils.NumberHolder which holds the power of the move.
|
||||
* This power value is dynamically calculated based on the item being flung.
|
||||
* @returns A boolean indicating whether the move was successfully applied.
|
||||
*/
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
const power = args[0] as Utils.NumberHolder; //to be changed based on held item
|
||||
const heldItems = this.getMyHeldItems(user); //gets all held items carried by user's pokemon
|
||||
if (heldItems.length === 0) { //user has no held item
|
||||
const power = args[0] as Utils.NumberHolder;
|
||||
|
||||
// Inline logic to retrieve the held items for the given Pokémon
|
||||
const heldItems = user.scene.findModifiers(
|
||||
(m) => m instanceof PokemonHeldItemModifier && (m as PokemonHeldItemModifier).pokemonId === user.id,
|
||||
user.isPlayer()
|
||||
) as PokemonHeldItemModifier[];
|
||||
|
||||
if (heldItems.length === 0) {
|
||||
power.value = 0;
|
||||
user.scene.queueMessage("But it failed!");
|
||||
return false;
|
||||
@ -2694,7 +2716,7 @@ export class FlingAttr extends VariablePowerAttr {
|
||||
const arr100i = ["Hard Stone"];
|
||||
const arr130i = ["Iron Ball"];
|
||||
|
||||
//all items turned to lower case to match item name as in game code
|
||||
// All items turned to lower case to match item name as in game code
|
||||
const arr10 = arr10i.map(item => item.toLowerCase());
|
||||
const arr30 = arr30i.map(item => item.toLowerCase());
|
||||
const arr40 = arr40i.map(item => item.toLowerCase());
|
||||
@ -2719,7 +2741,7 @@ export class FlingAttr extends VariablePowerAttr {
|
||||
this.randomItem = randomHeldItemModifier.type.name;
|
||||
this.randomItem = this.randomItem.toLowerCase().replace(/_/g, " ");
|
||||
|
||||
if (this.randomItem) { //assigns value to power and removes item in possesion
|
||||
if (this.randomItem) { // assigns value to power and removes item in possession
|
||||
if (arr10.includes(this.randomItem)) {
|
||||
power.value = 10;
|
||||
user.scene.removeModifier(randomHeldItemModifier, !user.isPlayer());
|
||||
@ -2777,13 +2799,8 @@ export class FlingAttr extends VariablePowerAttr {
|
||||
user.scene.queueMessage("But it failed!");
|
||||
return false;
|
||||
}
|
||||
|
||||
getMyHeldItems(user: Pokemon): PokemonHeldItemModifier[] {
|
||||
return user.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
||||
&& (m as PokemonHeldItemModifier).pokemonId === user.id, user.isPlayer()) as PokemonHeldItemModifier[];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class MovePowerMultiplierAttr extends VariablePowerAttr {
|
||||
private powerMultiplierFunc: (user: Pokemon, target: Pokemon, move: Move) => number;
|
||||
|
Loading…
Reference in New Issue
Block a user