Implement Prankster ability

This commit is contained in:
Flashfyre committed 2024-03-28 16:24:11 -04:00
1 parent 31d0d9b84e
commit 11bd7fdbca
6 files changed
+47 -17

No files matched your search

+20 -1
View File
@@ -914,6 +914,24 @@ export class BlockOneHitKOAbAttr extends AbAttr {
}
}
export class IncrementMovePriorityAbAttr extends AbAttr {
private moveIncrementFunc: (move: Move) => boolean;
constructor(moveIncrementFunc: (move: Move) => boolean) {
super(true);
this.moveIncrementFunc = moveIncrementFunc;
}
apply(pokemon: Pokemon, cancelled: Utils.BooleanHolder, args: any[]): boolean {
if (!this.moveIncrementFunc(args[0] as Move))
return false;
(args[0] as Utils.IntegerHolder).value++;
return true;
}
}
export class IgnoreContactAbAttr extends AbAttr { }
export class PreWeatherEffectAbAttr extends AbAttr {
@@ -2192,7 +2210,8 @@ export function initAbilities() {
new Ability(Abilities.SAP_SIPPER, "Sap Sipper", "Boosts the Attack stat if hit by a Grass-type move instead of taking damage.", 5)
.attr(TypeImmunityStatChangeAbAttr, Type.GRASS, BattleStat.ATK, 1)
.ignorable(),
new Ability(Abilities.PRANKSTER, "Prankster (N)", "Gives priority to a status move.", 5),
new Ability(Abilities.PRANKSTER, "Prankster", "Gives priority to a status move.", 5)
.attr(IncrementMovePriorityAbAttr, (move: Move) => move.category === MoveCategory.STATUS),
new Ability(Abilities.SAND_FORCE, "Sand Force", "Boosts the power of Rock-, Ground-, and Steel-type moves in a sandstorm.", 5)
.attr(MoveTypePowerBoostAbAttr, Type.ROCK, 1.3)
.attr(MoveTypePowerBoostAbAttr, Type.GROUND, 1.3)
+1 -2
View File
@@ -540,8 +540,7 @@ export async function printMoves() {
} else if (matchingLine)
flavorText = allMoves[move.id].effect;
const moveTarget = targetMap[move.target.name];
const moveTm = move.id < allMoves.length ? allMoves[move.id].tm : -1;
moveStr += `\n new ${move.damage_class.name !== 'status' ? 'Attack' : (moveTarget === MoveTarget.USER ? 'Self' : '') + 'Status'}Move(Moves.${moveEnumName}, "${moveName}", Type.${move.type.name.toUpperCase()}${move.damage_class.name !== 'status' ? `, MoveCategory.${move.damage_class.name.toUpperCase()}` : ''}${move.damage_class.name !== 'status' ? `, ${move.power || -1}` : ''}, ${move.accuracy || -1}, ${move.pp}, ${moveTm}, "${flavorText?.replace(/\n/g, '\\n').replace(/ /g, ' ').replace(/’/g, '\'') || ''}", ${move.effect_chance || -1}, ${move.priority}, ${generationMap[move.generation.name]})`;
moveStr += `\n new ${move.damage_class.name !== 'status' ? 'Attack' : (moveTarget === MoveTarget.USER ? 'Self' : '') + 'Status'}Move(Moves.${moveEnumName}, "${moveName}", Type.${move.type.name.toUpperCase()}${move.damage_class.name !== 'status' ? `, MoveCategory.${move.damage_class.name.toUpperCase()}` : ''}${move.damage_class.name !== 'status' ? `, ${move.power || -1}` : ''}, ${move.accuracy || -1}, ${move.pp}, "${flavorText?.replace(/\n/g, '\\n').replace(/ /g, ' ').replace(/’/g, '\'') || ''}", ${move.effect_chance || -1}, ${move.priority}, ${generationMap[move.generation.name]})`;
const expectedTarget = move.damage_class.name !== 'status' || moveTarget !== MoveTarget.USER ? MoveTarget.NEAR_OTHER : MoveTarget.USER;
if (matchingLine && matchingLine.length > 1) {
const newLineIndex = matchingLine.indexOf('\n');
+7 -2
View File
@@ -1,5 +1,8 @@
import Pokemon from "../field/pokemon";
import Move from "./move";
import { Type } from "./type";
import * as Utils from "../utils";
import { IncrementMovePriorityAbAttr, applyAbAttrs } from "./ability";
export enum TerrainType {
NONE,
@@ -44,10 +47,12 @@ export class Terrain {
return 1;
}
isMoveTerrainCancelled(move: Move): boolean {
isMoveTerrainCancelled(user: Pokemon, move: Move): boolean {
switch (this.terrainType) {
case TerrainType.PSYCHIC:
return move.priority > 0;
const priority = new Utils.IntegerHolder(move.priority);
applyAbAttrs(IncrementMovePriorityAbAttr, user, null, move, priority);
return priority.value > 0;
}
return false;