Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Move] Implement Fling #2200

Closed
wants to merge 10 commits into from
136 changes: 134 additions & 2 deletions src/data/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { Biome } from "#enums/biome";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";


export enum MoveCategory {
PHYSICAL,
SPECIAL,
Expand Down Expand Up @@ -2653,6 +2654,137 @@ export class LessPPMorePowerAttr extends VariablePowerAttr {
}
}

export class FlingAttr extends VariablePowerAttr {
protected randomItem;
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
DayKev marked this conversation as resolved.
Show resolved Hide resolved
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
DayKev marked this conversation as resolved.
Show resolved Hide resolved
power.value = 0;
user.scene.queueMessage("But it failed!");
return false;
}

const arr10i = [
"Sitrus Berry","Lum Berry","Enigma Berry","Liechi Berry","Ganlon Berry","Petaya Berry","Apicot Berry","Salac Berry",
"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",
"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"
];
const arr30i = [
"Flame Orb","Yellow Flute", "Amulet Coin", "Binding Band", "Black Belt", "Black Glasses", "Black Sludge", "Cell Battery",
"Charcoal", "Eject Button", "Escape Rope", "Exp. Share",
"Float Stone", "Heart Scale", "King's Rock", "Life Orb", "Light Ball", "Light Clay",
"Lucky Egg", "Luminous Moss", "Magnet", "Metal Coat", "Metronome", "Miracle Seed",
"Mystic Water", "NeverMeltIce", "Pearl", "Poké Doll", "Razor Fang", "Scope Lens", "Shell Bell",
"Smoke Ball", "Snowball", "Spell Tag", "Stardust", "Toxic Orb",
"Twisted Spoon"];
const arr40i = ["Eviolite","Icy Rock"];
const arr50i = ["Sharp Beak"];
const arr60i = ["Damp Rock", "Heat Rock", "Macho Brace", "Rocky Helmet"];
const arr70i = [ "Dragon Fang", "Poison Barb","Power Anklet", "Power Band", "Power Belt", "Power Bracer",
"Power Lens", "Power Weight"];
const arr80i = [
"Assault Vest", "Quick Claw", "Razor Claw",
"Sachet", "Safety Goggles", "Sticky Barb",
"Weakness Policy"
];
const arr90i = ["Grip Claw"];
const arr100i = ["Hard Stone"];
const arr130i = ["Iron Ball"];

//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());
const arr50 = arr50i.map(item => item.toLowerCase());
const arr60 = arr60i.map(item => item.toLowerCase());
const arr70 = arr70i.map(item => item.toLowerCase());
const arr80 = arr80i.map(item => item.toLowerCase());
const arr90 = arr90i.map(item => item.toLowerCase());
const arr100 = arr100i.map(item => item.toLowerCase());
const arr130 = arr130i.map(item => item.toLowerCase());

const allItems= [...arr10, ...arr30, ...arr40, ...arr50, ...arr60, ...arr70, ...arr80, ...arr90, ...arr100, ...arr130];

const validHeldItems = heldItems.filter(item => allItems.includes(item.type.name.toLowerCase().replace(/_/g, " ")));
if (validHeldItems.length === 0) { //user has no flingable held item
power.value = 0;
user.scene.queueMessage("No valid item found!");
return false;
}
DayKev marked this conversation as resolved.
Show resolved Hide resolved

const randomHeldItemModifier = validHeldItems[user.randSeedInt(validHeldItems.length)];
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 (arr10.includes(this.randomItem)) {
power.value = 10;
user.scene.removeModifier(randomHeldItemModifier, !user.isPlayer());
user.scene.updateModifiers(user.isPlayer());
return true;
} else if (arr30.includes(this.randomItem)) {
power.value = 30;
user.scene.removeModifier(randomHeldItemModifier, !user.isPlayer());
user.scene.updateModifiers(user.isPlayer());
return true;
} else if (arr40.includes(this.randomItem)) {
power.value = 40;
user.scene.removeModifier(randomHeldItemModifier, !user.isPlayer());
user.scene.updateModifiers(user.isPlayer());
return true;
} else if (arr50.includes(this.randomItem)) {
power.value = 50;
user.scene.removeModifier(randomHeldItemModifier, !user.isPlayer());
user.scene.updateModifiers(user.isPlayer());
return true;
} else if (arr60.includes(this.randomItem)) {
power.value = 60;
user.scene.removeModifier(randomHeldItemModifier, !user.isPlayer());
user.scene.updateModifiers(user.isPlayer());
return true;
} else if (arr70.includes(this.randomItem)) {
power.value = 70;
user.scene.removeModifier(randomHeldItemModifier, !user.isPlayer());
user.scene.updateModifiers(user.isPlayer());
return true;
} else if (arr80.includes(this.randomItem)) {
power.value = 80;
user.scene.removeModifier(randomHeldItemModifier, !user.isPlayer());
user.scene.updateModifiers(user.isPlayer());
return true;
} else if (arr90.includes(this.randomItem)) {
power.value = 90;
user.scene.removeModifier(randomHeldItemModifier, !user.isPlayer());
user.scene.updateModifiers(user.isPlayer());
return true;
} else if (arr100.includes(this.randomItem)) {
power.value = 100;
user.scene.removeModifier(randomHeldItemModifier, !user.isPlayer());
user.scene.updateModifiers(user.isPlayer());
return true;
} else if (arr130.includes(this.randomItem)) {
power.value = 130;
user.scene.removeModifier(randomHeldItemModifier, !user.isPlayer());
user.scene.updateModifiers(user.isPlayer());
return true;
}
}

AyushBarik marked this conversation as resolved.
Show resolved Hide resolved
power.value = 0;
user.scene.queueMessage("But it failed!");
return false;
}

getMyHeldItems(user: Pokemon): PokemonHeldItemModifier[] {
DayKev marked this conversation as resolved.
Show resolved Hide resolved
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;

Expand Down Expand Up @@ -6528,8 +6660,8 @@ export function initMoves() {
new StatusMove(Moves.EMBARGO, Type.DARK, 100, 15, -1, 0, 4)
.unimplemented(),
new AttackMove(Moves.FLING, Type.DARK, MoveCategory.PHYSICAL, -1, 100, 10, -1, 0, 4)
.makesContact(false)
.unimplemented(),
.attr(FlingAttr)
.makesContact(false),
new StatusMove(Moves.PSYCHO_SHIFT, Type.PSYCHIC, 100, 10, -1, 0, 4)
.attr(PsychoShiftEffectAttr)
.condition((user, target, move) => (user.status?.effect === StatusEffect.BURN
Expand Down