Skip to content

Commit

Permalink
Programmatically compute phazing moves
Browse files Browse the repository at this point in the history
  • Loading branch information
shrianshChari committed Aug 29, 2024
1 parent d481468 commit f0709c5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
16 changes: 13 additions & 3 deletions stats/src/classifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ export const Classifier = new class {
gravity: GRAVITY_MOVES,
recovery: RECOVERY_MOVES,
protection: PROTECT_MOVES,
phazing: PHAZING_MOVES,
} : this.caches[gen.num] || (this.caches[gen.num] = {
greaterSetup: computeGreaterSetupMoves(gen),
lesserSetup: computeLesserSetupMoves(gen),
batonPass: computeBatonPassMoves(gen),
gravity: computeGravityMoves(gen),
recovery: computeRecoveryMoves(gen),
protection: computeProtectionMoves(gen),
phazing: computePhazingMoves(gen),
});

let teamBias = 0;
Expand Down Expand Up @@ -461,8 +463,6 @@ function itemStallinessModifier(pokemon: PokemonSet<ID>) {
return 0;
}

const PHAZING_MOVES = new Set(['whirlwind', 'roar', 'circlethrow', 'dragontail']);

const PARALYSIS_MOVES = new Set(['thunderwave', 'stunspore', 'glare', 'nuzzle']);

const CONFUSION_MOVES = new Set([
Expand Down Expand Up @@ -504,7 +504,7 @@ function movesStallinessModifier(pokemon: PokemonSet<ID>, tables: {[name: string

if (pokemon.moves.some((m: ID) => tables.recovery.has(m))) mod += 1.0;
if (pokemon.moves.some((m: ID) => tables.protection.has(m))) mod += 1.0;
if (pokemon.moves.some((m: ID) => PHAZING_MOVES.has(m))) mod += 0.5;
if (pokemon.moves.some((m: ID) => tables.phazing.has(m))) mod += 0.5;
if (pokemon.moves.some((m: ID) => PARALYSIS_MOVES.has(m))) mod += 0.5;
if (pokemon.moves.some((m: ID) => CONFUSION_MOVES.has(m))) mod += 0.5;
if (pokemon.moves.some((m: ID) => SLEEP_MOVES.has(m))) mod -= 0.5;
Expand Down Expand Up @@ -669,6 +669,16 @@ export function computeProtectionMoves(gen: Generation) {
);
}

export const PHAZING_MOVES = new Set(['whirlwind', 'roar', 'circlethrow', 'dragontail'] as ID[]);

export function computePhazingMoves(gen: Generation) {
const moves = Array.from(gen.moves);

return new Set(
moves.filter(m => m.forceSwitch).map(m => m.id)
);
}

function targetsFoes(move: Move) {
return ['normal', 'adjacentFoe', 'allAdjacentFoes', 'foeSide'].includes(move.target);
}
5 changes: 5 additions & 0 deletions stats/src/test/classifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@ describe('Classifier', () => {

expect(COMPUTED_PROTECT_MOVES).toEqual(classifier.PROTECT_MOVES);
});
test('PHAZING_MOVES', () => {
const COMPUTED_PHAZING_MOVES = classifier.computePhazingMoves(GEN);

expect(COMPUTED_PHAZING_MOVES).toEqual(classifier.PHAZING_MOVES);
});
});

0 comments on commit f0709c5

Please sign in to comment.