Added documentation for Power Split and Guard Split + linting

This commit is contained in:
Frederico Santos 2024-05-12 07:19:28 +01:00
parent 58524d40eb
commit bb1d76c736
6 changed files with 46 additions and 10 deletions

@ -0,0 +1 @@
Subproject commit 6d5e2b2c486abc63b451daf2d2f9812bbe5003b8

View File

@ -1842,7 +1842,19 @@ export class HpSplitAttr extends MoveEffectAttr {
}
}
/**
* Attribute used for moves which split the user and the target's offensive raw stats.
* This attribute is used for the move Power Split.
*/
export class PowerSplitAttr extends MoveEffectAttr {
/**
* Applying Power Split to the user and the target.
* @param {Pokemon} user The pokemon using the move.
* @param {Pokemon} target The targeted pokemon of the move.
* @param {Move} move The move used.
* @param {any} args N/A
* @returns {boolean} True if power split is applied successfully.
*/
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]) : Promise<boolean> {
return new Promise(resolve => {
@ -1868,7 +1880,19 @@ export class PowerSplitAttr extends MoveEffectAttr {
}
}
/**
* Attribute used for moves which split the user and the target's defensive raw stats.
* This attribute is used for the move Guard Split.
*/
export class GuardSplitAttr extends MoveEffectAttr {
/**
* Applying Guard Split to the user and the target.
* @param {Pokemon} user The pokemon using the move.
* @param {Pokemon} target The targeted pokemon of the move.
* @param {Move} move The move used.
* @param {any} args N/A
* @returns {boolean} True if power split is applied successfully.
*/
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
return new Promise(resolve => {
if (!super.apply(user, target, move, args))
@ -1877,15 +1901,15 @@ export class GuardSplitAttr extends MoveEffectAttr {
const infoUpdates = [];
const defenseValue = Math.floor((target.getStat(Stat.DEF) + user.getStat(Stat.DEF)) / 2);
user.changeStat(Stat.DEF, defenseValue);
user.changeSummonStat(Stat.DEF, defenseValue);
infoUpdates.push(user.updateInfo());
target.changeStat(Stat.DEF, defenseValue);
target.changeSummonStat(Stat.DEF, defenseValue);
infoUpdates.push(target.updateInfo());
const specialDefenseValue = Math.floor((target.getStat(Stat.SPDEF) + user.getStat(Stat.SPDEF)) / 2);
user.changeStat(Stat.SPDEF, specialDefenseValue);
user.changeSummonStat(Stat.SPDEF, specialDefenseValue);
infoUpdates.push(user.updateInfo());
target.changeStat(Stat.SPDEF, specialDefenseValue);
target.changeSummonStat(Stat.SPDEF, specialDefenseValue);
infoUpdates.push(target.updateInfo());

View File

@ -73,8 +73,11 @@ export const pokemonSpeciesLevelMoves: PokemonSpeciesLevelMoves = {
[ 1, Moves.SCRATCH ],
[ 1, Moves.GROWL ],
[ 4, Moves.EMBER ],
[ 8, Moves.SMOKESCREEN ],
[ 6, Moves.POWER_SPLIT ],
[ 7, Moves.GUARD_SPLIT ],
[ 12, Moves.DRAGON_BREATH ],
[ 15, Moves.TRIPLE_KICK],
[ 16, Moves.TRIPLE_AXEL],
[ 17, Moves.FIRE_FANG ],
[ 20, Moves.SLASH ],
[ 24, Moves.FLAMETHROWER ],
@ -89,6 +92,7 @@ export const pokemonSpeciesLevelMoves: PokemonSpeciesLevelMoves = {
[ 1, Moves.EMBER ],
[ 1, Moves.SMOKESCREEN ],
[ 12, Moves.DRAGON_BREATH ],
[ 17, Moves.LIFE_DEW],
[ 19, Moves.FIRE_FANG ],
[ 24, Moves.SLASH ],
[ 30, Moves.FLAMETHROWER ],
@ -15487,6 +15491,7 @@ export const pokemonSpeciesLevelMoves: PokemonSpeciesLevelMoves = {
[ 1, Moves.BABY_DOLL_EYES ],
[ 5, Moves.ECHOED_VOICE ],
[ 8, Moves.HELPING_HAND ],
[ 10, Moves.PROTECT],
[ 11, Moves.SUPER_FANG ],
[ 14, Moves.DOUBLE_HIT ],
[ 18, Moves.BULLET_SEED ],

View File

@ -5,6 +5,7 @@ import * as Utils from "../utils";
import { IncrementMovePriorityAbAttr, applyAbAttrs } from "./ability";
import { ProtectAttr } from "./move";
import { BattlerIndex } from "#app/battle.js";
import { Abilities } from "./enums/abilities";
export enum TerrainType {
NONE,
@ -52,6 +53,13 @@ export class Terrain {
isMoveTerrainCancelled(user: Pokemon, targets: BattlerIndex[], move: Move): boolean {
switch (this.terrainType) {
case TerrainType.PSYCHIC:
var enemies = user.getOpponents().filter(o => targets.includes(o.getBattlerIndex()));
if (enemies.length > 0 &&
enemies.some(e => e.species.isOfType(Type.FLYING))||
enemies.some(e => e.species.getAbility(0) === Abilities.LEVITATE || e.species.getAbility(1) === Abilities.LEVITATE || e.species.getAbility(2) === Abilities.LEVITATE))
{
return false;
}
if (!move.getAttrs(ProtectAttr).length) {
const priority = new Utils.IntegerHolder(move.priority);
applyAbAttrs(IncrementMovePriorityAbAttr, user, null, move, priority);

View File

@ -545,8 +545,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
}
getStat(stat: Stat): integer {
if (!this.summonData)
{
if (!this.summonData) {
return this.stats[stat];
}
@ -1708,8 +1707,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
return healAmount;
}
changeSummonStat(stat: Stat, value: integer) : void
{
changeSummonStat(stat: Stat, value: integer) : void {
this.summonData.stats[stat] = value;
}

View File

@ -973,7 +973,7 @@ interface ModifierPool {
const modifierPool: ModifierPool = {
[ModifierTier.COMMON]: [
new WeightedModifierType(modifierTypes.POKEBALL, 6),
new WeightedModifierType(modifierTypes.RARE_CANDY, 2),
new WeightedModifierType(modifierTypes.RARE_CANDY, 9999),
new WeightedModifierType(modifierTypes.POTION, (party: Pokemon[]) => {
const thresholdPartyMemberCount = Math.min(party.filter(p => p.getInverseHp() >= 10 || p.getHpRatio() <= 0.875).length, 3);
return thresholdPartyMemberCount * 3;