UPDATE: cleaned StockpileStatChangeAttr

pull/410/head^2
Marek Sison 2024-05-10 12:17:59 +08:00
parent 79e33dcc6e
commit a317d2fb7e
1 changed files with 13 additions and 14 deletions

View File

@ -1648,24 +1648,23 @@ export class GrowthStatChangeAttr extends StatChangeAttr {
} }
export class StockpileStatChangeAttr extends StatChangeAttr { export class StockpileStatChangeAttr extends StatChangeAttr {
tagTypes = [BattlerTagType.STOCKPILE_ONE, BattlerTagType.STOCKPILE_TWO, BattlerTagType.STOCKPILE_THREE]; private tagTypes = [BattlerTagType.STOCKPILE_ONE, BattlerTagType.STOCKPILE_TWO, BattlerTagType.STOCKPILE_THREE];
private gainStats:boolean;
constructor(move: Moves = Moves.STOCKPILE) { constructor(gainStats:boolean = true) {
let l = 1; super([ BattleStat.DEF, BattleStat.SPDEF ], 1, true);
if (move === Moves.SPIT_UP || move === Moves.SWALLOW){ this.gainStats = gainStats;
l = -1;
}
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); const stock = getStockpiles(user);
if (this.levels < 0) { if (!this.gainStats) {
// levels become equal to the negative of stock
this.levels = stock * -1; this.levels = stock * -1;
// remove the stats equal to the number of stock
for (let tagType of this.tagTypes) for (let tagType of this.tagTypes)
(this.selfTarget ? user : target).removeTag(tagType); (this.selfTarget ? user : target).removeTag(tagType);
} }
@ -3052,7 +3051,7 @@ export class StockpileAttr extends AddBattlerTagAttr {
this.tagType = stockType; this.tagType = stockType;
if (!super.apply(user, target, move, args) || willFail) if (willFail || !super.apply(user, target, move, args))
return false; return false;
user.scene.queueMessage(getPokemonMessage(target, `\nstockpiled ${stock+1}.`)); user.scene.queueMessage(getPokemonMessage(target, `\nstockpiled ${stock+1}.`));
@ -4889,17 +4888,17 @@ 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, Moves.STOCKPILE) .attr(StockpileStatChangeAttr)
.condition(failOnMaxStockCondition) .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, Moves.SPIT_UP) .attr(StockpileStatChangeAttr, false)
.condition(failOnNoStockCondition) .condition(failOnNoStockCondition)
.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, Moves.SWALLOW) .attr(StockpileStatChangeAttr, false)
.condition(failOnNoStockCondition) .condition(failOnNoStockCondition)
.triageMove() .triageMove()
.partial(), .partial(),