Addressed most of the review comments: Got rid of evolutionary items, heldItems check moved to the beginning, dealt with berries without importing berry-type.ts

This commit is contained in:
AyushBarik 2024-06-16 22:31:53 +05:30
parent cb3da4cc4a
commit df8caa75c3

View File

@ -26,7 +26,7 @@ import { BattlerTagType } from "#enums/battler-tag-type";
import { Biome } from "#enums/biome"; import { Biome } from "#enums/biome";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { BerryType } from "#enums/berry-type";
export enum MoveCategory { export enum MoveCategory {
PHYSICAL, PHYSICAL,
@ -2657,33 +2657,37 @@ export class LessPPMorePowerAttr extends VariablePowerAttr {
export class FlingAttr extends VariablePowerAttr { export class FlingAttr extends VariablePowerAttr {
protected randomItem; protected randomItem;
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
const berryNames = Object.keys(BerryType)
.map((key) => `${key.toLowerCase()} berry`);
const power = args[0] as Utils.NumberHolder; //to be changed based on held item const power = args[0] as Utils.NumberHolder; //to be changed based on held item
//list of flingable items sorted by how they change power const heldItems = this.getMyHeldItems(user); //gets all held items carried by user's pokemon
if (heldItems.length === 0) { //user has no held item
power.value = 0;
user.scene.queueMessage("But it failed!");
return false;
}
const arr10i = [ const arr10i = [
...berryNames, "Sitrus Berry","Lum Berry","Enigma Berry","Liechi Berry","Ganlon Berry","Petaya Berry","Apicot Berry","Salac Berry",
"Choice Band", "Choice Scarf", "Choice Specs", "Air Balloon", "Absorb Bulb", "Amulet Coin", "Big Root", "Lansat Berry","Starf Berry","Leppa Berry","Choice Band", "Choice Scarf", "Choice Specs", "Air Balloon", "Absorb Bulb", "Amulet Coin", "Big Root",
"Destiny Knot", "Expert Belt", "Focus Band", "Focus Sash", "Lagging Tail", "Leftovers", "Mental Herb", "Destiny Knot", "Expert Belt", "Focus Band", "Focus Sash", "Lagging Tail", "Leftovers", "Mental Herb",
"Muscle Band", "Power Herb", "Red Card", "Shed Shell", "Silk Scarf", "Silver Powder", "Smooth Rock", "Soft Sand", "Muscle Band", "Power Herb", "Red Card", "Shed Shell", "Silk Scarf", "Silver Powder", "Smooth Rock", "Soft Sand",
"Soothe Bell", "White Herb","Wide Lens", "Wise Glasses", "Zoom Lens" "Soothe Bell", "White Herb","Wide Lens", "Wise Glasses", "Zoom Lens"
]; ];
const arr30i = [ const arr30i = [
"Flame Orb","Yellow Flute", "Amulet Coin", "Binding Band", "Black Belt", "Black Glasses", "Black Sludge", "Cell Battery", "Flame Orb","Yellow Flute", "Amulet Coin", "Binding Band", "Black Belt", "Black Glasses", "Black Sludge", "Cell Battery",
"Charcoal", "Eject Button", "Escape Rope", "Everstone", "Exp. Share", "Fire Stone", "Charcoal", "Eject Button", "Escape Rope", "Exp. Share",
"Float Stone", "Heart Scale", "King's Rock", "Leaf Stone", "Life Orb", "Light Ball", "Light Clay", "Float Stone", "Heart Scale", "King's Rock", "Life Orb", "Light Ball", "Light Clay",
"Lucky Egg", "Luminous Moss", "Magnet", "Metal Coat", "Metronome", "Miracle Seed", "Moon Stone", "Lucky Egg", "Luminous Moss", "Magnet", "Metal Coat", "Metronome", "Miracle Seed",
"Mystic Water", "NeverMeltIce", "Pearl", "Poké Doll", "Razor Fang", "Scope Lens", "Shell Bell", "Mystic Water", "NeverMeltIce", "Pearl", "Poké Doll", "Razor Fang", "Scope Lens", "Shell Bell",
"Smoke Ball", "Snowball", "Spell Tag", "Stardust", "Sun Stone", "Thunder Stone", "Toxic Orb", "Smoke Ball", "Snowball", "Spell Tag", "Stardust", "Toxic Orb",
"Twisted Spoon", "Water Stone"]; "Twisted Spoon"];
const arr40i = ["Eviolite","Icy Rock"]; const arr40i = ["Eviolite","Icy Rock"];
const arr50i = ["Sharp Beak"]; const arr50i = ["Sharp Beak"];
const arr60i = ["Damp Rock", "Heat Rock", "Macho Brace", "Rocky Helmet"]; const arr60i = ["Damp Rock", "Heat Rock", "Macho Brace", "Rocky Helmet"];
const arr70i = [ "Dragon Fang", "Poison Barb","Power Anklet", "Power Band", "Power Belt", "Power Bracer", const arr70i = [ "Dragon Fang", "Poison Barb","Power Anklet", "Power Band", "Power Belt", "Power Bracer",
"Power Lens", "Power Weight"]; "Power Lens", "Power Weight"];
const arr80i = [ const arr80i = [
"Assault Vest", "Dawn Stone", "Quick Claw", "Razor Claw", "Assault Vest", "Quick Claw", "Razor Claw",
"Sachet", "Safety Goggles", "Shiny Stone", "Sticky Barb", "Sachet", "Safety Goggles", "Sticky Barb",
"Weakness Policy" "Weakness Policy"
]; ];
const arr90i = ["Grip Claw"]; const arr90i = ["Grip Claw"];
@ -2704,12 +2708,6 @@ export class FlingAttr extends VariablePowerAttr {
const allItems= [...arr10, ...arr30, ...arr40, ...arr50, ...arr60, ...arr70, ...arr80, ...arr90, ...arr100, ...arr130]; const allItems= [...arr10, ...arr30, ...arr40, ...arr50, ...arr60, ...arr70, ...arr80, ...arr90, ...arr100, ...arr130];
const heldItems = this.getMyHeldItems(user); //gets all held items carried by user's pokemon
if (heldItems.length === 0) { //user has no held item
power.value = 0;
user.scene.queueMessage("But it failed!");
return false;
}
const validHeldItems = heldItems.filter(item => allItems.includes(item.type.name.toLowerCase().replace(/_/g, " "))); const validHeldItems = heldItems.filter(item => allItems.includes(item.type.name.toLowerCase().replace(/_/g, " ")));
if (validHeldItems.length === 0) { //user has no flingable held item if (validHeldItems.length === 0) { //user has no flingable held item
power.value = 0; power.value = 0;
@ -6666,7 +6664,6 @@ export function initMoves() {
new AttackMove(Moves.FLING, Type.DARK, MoveCategory.PHYSICAL, -1, 100, 10, -1, 0, 4) new AttackMove(Moves.FLING, Type.DARK, MoveCategory.PHYSICAL, -1, 100, 10, -1, 0, 4)
.attr(FlingAttr) .attr(FlingAttr)
.makesContact(false), .makesContact(false),
//.unimplemented(),
new StatusMove(Moves.PSYCHO_SHIFT, Type.PSYCHIC, 100, 10, -1, 0, 4) new StatusMove(Moves.PSYCHO_SHIFT, Type.PSYCHIC, 100, 10, -1, 0, 4)
.attr(PsychoShiftEffectAttr) .attr(PsychoShiftEffectAttr)
.condition((user, target, move) => (user.status?.effect === StatusEffect.BURN .condition((user, target, move) => (user.status?.effect === StatusEffect.BURN