HOTFIX: squashed bugs with stockpiles not properly being detected

pull/410/head^2
Marek Sison 2024-05-08 23:00:58 +08:00
parent 2a356f64a4
commit 81628e634f
3 changed files with 54 additions and 47 deletions

View File

@ -1608,36 +1608,33 @@ export class GrowthStatChangeAttr extends StatChangeAttr {
} }
export class StockpileStatChangeAttr extends StatChangeAttr { export class StockpileStatChangeAttr extends StatChangeAttr {
constructor(move: string = "Stockpile") { tagTypes = [BattlerTagType.STOCKPILE_ONE, BattlerTagType.STOCKPILE_TWO, BattlerTagType.STOCKPILE_THREE];
constructor(move: Moves = Moves.STOCKPILE) {
let l = 1; let l = 1;
if (move === "Spit-Up" || move === "Swallow"){ if (move === Moves.SPIT_UP || move === Moves.SWALLOW){
l = -1; l = -1;
} }
super([ BattleStat.ATK, BattleStat.SPATK ], l, true); super([ BattleStat.DEF, BattleStat.SPDEF ], l, true);
} }
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean | Promise<boolean> { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean | Promise<boolean> {
const stock = getStockpiles(user);
if (this.levels < 0) {
this.levels = stock * -1;
for (let tagType of this.tagTypes)
(this.selfTarget ? user : target).removeTag(tagType);
}
if (!super.apply(user, target, move, args)) if (!super.apply(user, target, move, args))
return false; return false;
this.levels = this.levels < 0 ? (this.getStockpiles(user) * -1) : 1;
return true; return true;
} }
getStockpiles(user: Pokemon): integer {
let s = 0;
const stock = [BattlerTagType.STOCKPILE_ONE, BattlerTagType.STOCKPILE_TWO, BattlerTagType.STOCKPILE_THREE];
for (let x = 0 ; x < stock.length ; x++){
if (user.getTag(stock[x])){
s++;
}
}
return s;
}
} }
export class HalfHpStatMaxAttr extends StatChangeAttr { export class HalfHpStatMaxAttr extends StatChangeAttr {
@ -2990,12 +2987,13 @@ export class FaintCountdownAttr extends AddBattlerTagAttr {
export class StockpileAttr extends AddBattlerTagAttr { export class StockpileAttr extends AddBattlerTagAttr {
constructor() { constructor() {
super(BattlerTagType.STOCKPILE_THREE, true, true, 20, 20); super(BattlerTagType.STOCKPILE_THREE, true, false, 20, 20);
} }
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
const stock = this.getStockpiles(user); const stock = getStockpiles(user);
let stockType = BattlerTagType.STOCKPILE_THREE; let stockType = BattlerTagType.STOCKPILE_THREE;
let willFail = false;
switch (stock){ switch (stock){
case 0: case 0:
@ -3003,28 +3001,24 @@ export class StockpileAttr extends AddBattlerTagAttr {
break; break;
case 1: case 1:
stockType = BattlerTagType.STOCKPILE_TWO; stockType = BattlerTagType.STOCKPILE_TWO;
break;
case 3:
willFail = true;
break
default:
// keep it at STOCKPILE_THREE
break;
} }
if (!super.apply(user, target, move, args)) this.tagType = stockType;
if (!super.apply(user, target, move, args) || willFail)
return false; return false;
user.scene.queueMessage(getPokemonMessage(target, `\nstockpiled ${stock+1}.`)); user.scene.queueMessage(getPokemonMessage(target, `\nstockpiled ${stock+1}.`));
return true; return true;
} }
getStockpiles(user: Pokemon): integer {
let s = 0;
const stock = [BattlerTagType.STOCKPILE_ONE, BattlerTagType.STOCKPILE_TWO, BattlerTagType.STOCKPILE_THREE];
for (let x = 0 ; x < stock.length ; x++){
if (user.getTag(stock[x])){
s++;
}
}
return s;
}
} }
export class HitsTagAttr extends MoveAttr { export class HitsTagAttr extends MoveAttr {
@ -3961,12 +3955,29 @@ export class VariableTargetAttr extends MoveAttr {
} }
} }
function getStockpiles(user: Pokemon) : integer {
let s = 0;
const stock = [BattlerTagType.STOCKPILE_ONE, BattlerTagType.STOCKPILE_TWO, BattlerTagType.STOCKPILE_THREE];
for (let x = 0 ; x < stock.length ; x++){
if (user.getTag(stock[x])){
s++;
}
}
return s;
}
const failOnGravityCondition: MoveConditionFunc = (user, target, move) => !user.scene.arena.getTag(ArenaTagType.GRAVITY); const failOnGravityCondition: MoveConditionFunc = (user, target, move) => !user.scene.arena.getTag(ArenaTagType.GRAVITY);
const failOnBossCondition: MoveConditionFunc = (user, target, move) => !target.isBossImmune(); const failOnBossCondition: MoveConditionFunc = (user, target, move) => !target.isBossImmune();
const failOnMaxCondition: MoveConditionFunc = (user, target, move) => !target.isMax(); const failOnMaxCondition: MoveConditionFunc = (user, target, move) => !target.isMax();
const failOnMaxStockCondition: MoveConditionFunc = (user, target, move) => getStockpiles(user) != 3;
const failOnNoStockCondition: MoveConditionFunc = (user, target, move) => getStockpiles(user) != 0;
const failIfDampCondition: MoveConditionFunc = (user, target, move) => { const failIfDampCondition: MoveConditionFunc = (user, target, move) => {
const cancelled = new Utils.BooleanHolder(false); const cancelled = new Utils.BooleanHolder(false);
user.scene.getField(true).map(p=>applyAbAttrs(FieldPreventExplosiveMovesAbAttr, p, cancelled)); user.scene.getField(true).map(p=>applyAbAttrs(FieldPreventExplosiveMovesAbAttr, p, cancelled));
@ -4797,25 +4808,18 @@ export function initMoves() {
.partial(), .partial(),
new SelfStatusMove(Moves.STOCKPILE, Type.NORMAL, -1, 20, -1, 0, 3) new SelfStatusMove(Moves.STOCKPILE, Type.NORMAL, -1, 20, -1, 0, 3)
.attr(StockpileAttr) .attr(StockpileAttr)
.attr(StockpileStatChangeAttr, 'Stockpile') .attr(StockpileStatChangeAttr, Moves.STOCKPILE)
.condition(failOnMaxStockCondition)
.partial(), .partial(),
new AttackMove(Moves.SPIT_UP, Type.NORMAL, MoveCategory.SPECIAL, -1, 100, 10, -1, 0, 3) new AttackMove(Moves.SPIT_UP, Type.NORMAL, MoveCategory.SPECIAL, -1, 100, 10, -1, 0, 3)
.attr(SpitUpPowerAttr) .attr(SpitUpPowerAttr)
.attr(StockpileStatChangeAttr, 'Spit-Up') .attr(StockpileStatChangeAttr, Moves.SPIT_UP)
.attr(RemoveBattlerTagAttr, [ .condition(failOnNoStockCondition)
BattlerTagType.STOCKPILE_ONE,
BattlerTagType.STOCKPILE_TWO,
BattlerTagType.STOCKPILE_THREE,
], true)
.partial(), .partial(),
new SelfStatusMove(Moves.SWALLOW, Type.NORMAL, -1, 10, -1, 0, 3) new SelfStatusMove(Moves.SWALLOW, Type.NORMAL, -1, 10, -1, 0, 3)
.attr(SwallowHealAttr, 1) .attr(SwallowHealAttr, 1)
.attr(StockpileStatChangeAttr, 'Swallow') .attr(StockpileStatChangeAttr, Moves.SWALLOW)
.attr(RemoveBattlerTagAttr, [ .condition(failOnNoStockCondition)
BattlerTagType.STOCKPILE_ONE,
BattlerTagType.STOCKPILE_TWO,
BattlerTagType.STOCKPILE_THREE,
], true)
.triageMove() .triageMove()
.partial(), .partial(),
new AttackMove(Moves.HEAT_WAVE, Type.FIRE, MoveCategory.SPECIAL, 95, 90, 10, 10, 0, 3) new AttackMove(Moves.HEAT_WAVE, Type.FIRE, MoveCategory.SPECIAL, 95, 90, 10, 10, 0, 3)

View File

@ -43,7 +43,7 @@ import { Nature, getNatureStatMultiplier } from '../data/nature';
import { SpeciesFormChange, SpeciesFormChangeActiveTrigger, SpeciesFormChangeMoveLearnedTrigger, SpeciesFormChangePostMoveTrigger, SpeciesFormChangeStatusEffectTrigger } from '../data/pokemon-forms'; import { SpeciesFormChange, SpeciesFormChangeActiveTrigger, SpeciesFormChangeMoveLearnedTrigger, SpeciesFormChangePostMoveTrigger, SpeciesFormChangeStatusEffectTrigger } from '../data/pokemon-forms';
import { TerrainType } from '../data/terrain'; import { TerrainType } from '../data/terrain';
import { TrainerSlot } from '../data/trainer-config'; import { TrainerSlot } from '../data/trainer-config';
import { ABILITY_OVERRIDE, MOVE_OVERRIDE, MOVE_OVERRIDE_2, OPP_ABILITY_OVERRIDE, OPP_MOVE_OVERRIDE, OPP_MOVE_OVERRIDE_2, OPP_SHINY_OVERRIDE, OPP_VARIANT_OVERRIDE } from '../overrides'; import { ABILITY_OVERRIDE, MOVE_OVERRIDE, MOVE_OVERRIDE_2, MOVE_OVERRIDE_3, OPP_ABILITY_OVERRIDE, OPP_MOVE_OVERRIDE, OPP_MOVE_OVERRIDE_2, OPP_SHINY_OVERRIDE, OPP_VARIANT_OVERRIDE } from '../overrides';
import { BerryType } from '../data/berry'; import { BerryType } from '../data/berry';
import i18next from '../plugins/i18n'; import i18next from '../plugins/i18n';
@ -733,6 +733,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.moveset[1] = new PokemonMove(MOVE_OVERRIDE_2, Math.min(this.moveset[1].ppUsed, allMoves[MOVE_OVERRIDE_2].pp)); this.moveset[1] = new PokemonMove(MOVE_OVERRIDE_2, Math.min(this.moveset[1].ppUsed, allMoves[MOVE_OVERRIDE_2].pp));
else if (OPP_MOVE_OVERRIDE_2 && !this.isPlayer()) else if (OPP_MOVE_OVERRIDE_2 && !this.isPlayer())
this.moveset[1] = new PokemonMove(OPP_MOVE_OVERRIDE_2, Math.min(this.moveset[1].ppUsed, allMoves[OPP_MOVE_OVERRIDE_2].pp)); this.moveset[1] = new PokemonMove(OPP_MOVE_OVERRIDE_2, Math.min(this.moveset[1].ppUsed, allMoves[OPP_MOVE_OVERRIDE_2].pp));
if (MOVE_OVERRIDE_3 && this.isPlayer())
this.moveset[2] = new PokemonMove(MOVE_OVERRIDE_3, Math.min(this.moveset[2].ppUsed, allMoves[MOVE_OVERRIDE_3].pp));
return ret; return ret;

View File

@ -16,6 +16,7 @@ export const WEATHER_OVERRIDE = WeatherType.NONE;
export const ABILITY_OVERRIDE = Abilities.NONE; export const ABILITY_OVERRIDE = Abilities.NONE;
export const MOVE_OVERRIDE = Moves.NONE; export const MOVE_OVERRIDE = Moves.NONE;
export const MOVE_OVERRIDE_2 = Moves.NONE; export const MOVE_OVERRIDE_2 = Moves.NONE;
export const MOVE_OVERRIDE_3 = Moves.NONE;
export const OPP_SPECIES_OVERRIDE = 0; export const OPP_SPECIES_OVERRIDE = 0;
export const OPP_ABILITY_OVERRIDE = Abilities.NONE; export const OPP_ABILITY_OVERRIDE = Abilities.NONE;
export const OPP_MOVE_OVERRIDE = Moves.NONE; export const OPP_MOVE_OVERRIDE = Moves.NONE;