diff --git a/src/data/move.ts b/src/data/move.ts index 7c4383d24..29af0e7ea 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -842,25 +842,25 @@ export class HealAttr extends MoveEffectAttr { export class SwallowHealAttr extends HealAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - const s = this.getStockpiles(user); + const stock = this.getStockpiles(user); - this.getHealRatio(s > 2 ? 1 : (s * 0.25)); + this.getHealRatio(stock >= 3 ? 1 : (stock * 0.25)); super.apply(user, target, move, args); return true; } getStockpiles(user: Pokemon): integer { - let s = 0; - const stock = [BattlerTagType.STOCKPILE_ONE, BattlerTagType.STOCKPILE_TWO, BattlerTagType.STOCKPILE_THREE]; + let stock = 0; + const tagList = [BattlerTagType.STOCKPILE_ONE, BattlerTagType.STOCKPILE_TWO, BattlerTagType.STOCKPILE_THREE]; - for (let x = 0 ; x < stock.length ; x++){ - if (user.getTag(stock[x])){ - s++; + for (let x = 0 ; x < tagList.length ; x++){ + if (user.getTag(tagList[x])){ + stock++; } } - return s; + return stock; } } @@ -1704,35 +1704,31 @@ export class GrowthStatChangeAttr extends StatChangeAttr { } export class StockpileStatChangeAttr extends StatChangeAttr { - constructor(move: string = "Stockpile") { - let l = 1; + private tagTypes = [BattlerTagType.STOCKPILE_ONE, BattlerTagType.STOCKPILE_TWO, BattlerTagType.STOCKPILE_THREE]; + private gainStats:boolean; - if (move === "Spit-Up" || move === "Swallow"){ - l = -1; - } + constructor(gainStats:boolean = true) { + super([ BattleStat.DEF, BattleStat.SPDEF ], 1, true); - super([ BattleStat.ATK, BattleStat.SPATK ], l, true); + this.gainStats = gainStats; } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean | Promise { - if (!super.apply(user, target, move, args)) - return false; + const stock = getStockpiles(user); - this.levels = this.levels < 0 ? (this.getStockpiles(user) * -1) : 1; - return true; - } + if (!this.gainStats) { + // levels become equal to the negative of stock + this.levels = stock * -1; - 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++; - } + // remove the stats equal to the number of stock + for (let tagType of this.tagTypes) + (this.selfTarget ? user : target).removeTag(tagType); } - return s; + if (!super.apply(user, target, move, args)) + return false; + + return true; } } @@ -3086,12 +3082,13 @@ export class FaintCountdownAttr extends AddBattlerTagAttr { export class StockpileAttr extends AddBattlerTagAttr { 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 { - const stock = this.getStockpiles(user); + const stock = getStockpiles(user); let stockType = BattlerTagType.STOCKPILE_THREE; + let willFail = false; switch (stock){ case 0: @@ -3099,28 +3096,24 @@ export class StockpileAttr extends AddBattlerTagAttr { break; case 1: 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 (willFail || !super.apply(user, target, move, args)) return false; user.scene.queueMessage(getPokemonMessage(target, `\nstockpiled ${stock+1}.`)); 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 { @@ -4093,12 +4086,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 failOnBossCondition: MoveConditionFunc = (user, target, move) => !target.isBossImmune(); 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 cancelled = new Utils.BooleanHolder(false); user.scene.getField(true).map(p=>applyAbAttrs(FieldPreventExplosiveMovesAbAttr, p, cancelled)); @@ -4935,25 +4945,18 @@ export function initMoves() { .partial(), new SelfStatusMove(Moves.STOCKPILE, Type.NORMAL, -1, 20, -1, 0, 3) .attr(StockpileAttr) - .attr(StockpileStatChangeAttr, 'Stockpile') + .attr(StockpileStatChangeAttr) + .condition(failOnMaxStockCondition) .partial(), new AttackMove(Moves.SPIT_UP, Type.NORMAL, MoveCategory.SPECIAL, -1, 100, 10, -1, 0, 3) .attr(SpitUpPowerAttr) - .attr(StockpileStatChangeAttr, 'Spit-Up') - .attr(RemoveBattlerTagAttr, [ - BattlerTagType.STOCKPILE_ONE, - BattlerTagType.STOCKPILE_TWO, - BattlerTagType.STOCKPILE_THREE, - ], true) + .attr(StockpileStatChangeAttr, false) + .condition(failOnNoStockCondition) .partial(), new SelfStatusMove(Moves.SWALLOW, Type.NORMAL, -1, 10, -1, 0, 3) .attr(SwallowHealAttr, 1) - .attr(StockpileStatChangeAttr, 'Swallow') - .attr(RemoveBattlerTagAttr, [ - BattlerTagType.STOCKPILE_ONE, - BattlerTagType.STOCKPILE_TWO, - BattlerTagType.STOCKPILE_THREE, - ], true) + .attr(StockpileStatChangeAttr, false) + .condition(failOnNoStockCondition) .triageMove() .partial(), new AttackMove(Moves.HEAT_WAVE, Type.FIRE, MoveCategory.SPECIAL, 95, 90, 10, 10, 0, 3)