UPDATE: Stockpile has been fully implemented. Still marked as partial for testing

pull/543/head
Marek Sison 2024-05-06 13:35:05 +08:00
parent 03c88c9516
commit 531ec358e0
3 changed files with 126 additions and 5 deletions

View File

@ -53,5 +53,7 @@ export enum BattlerTagType {
CURSED = "CURSED",
CHARGED = "CHARGED",
GROUNDED = "GROUNDED",
STOCKPILE = "STOCKPILE"
STOCKPILE_ONE = "STOCKPILE_ONE",
STOCKPILE_TWO = "STOCKPILE_TWO",
STOCKPILE_THREE = "STOCKPILE_THREE"
}

View File

@ -407,6 +407,14 @@ export class SelfStatusMove extends Move {
}
}
export class StockpileMove extends SelfStatusMove {
constructor(id: Moves, type: Type, accuracy: integer, pp: integer, chance: integer, priority: integer, generation: integer) {
super(id, type, accuracy, pp, chance, priority, generation);
}
// add a function for shifting conditions
}
export abstract class MoveAttr {
public selfTarget: boolean;
@ -2582,7 +2590,9 @@ export class AddBattlerTagAttr extends MoveEffectAttr {
case BattlerTagType.INGRAIN:
case BattlerTagType.IGNORE_ACCURACY:
case BattlerTagType.AQUA_RING:
case BattlerTagType.STOCKPILE:
case BattlerTagType.STOCKPILE_ONE:
case BattlerTagType.STOCKPILE_TWO:
case BattlerTagType.STOCKPILE_THREE:
return 3;
case BattlerTagType.PROTECTED:
case BattlerTagType.FLYING:
@ -2767,9 +2777,117 @@ export class FaintCountdownAttr extends AddBattlerTagAttr {
}
}
export class StockpileAttr extends AddBattlerTagAttr {
export class StockpileOneAttr extends AddBattlerTagAttr {
constructor() {
super(BattlerTagType.STOCKPILE, true, false, 0, 10)
super(BattlerTagType.STOCKPILE_ONE, true, true, 20, 20);
}
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
if (!super.apply(user, target, move, args))
return false;
user.scene.queueMessage(getPokemonMessage(target, `\nstockpiled 1.`));
return true;
}
}
export class StockpileTwoAttr extends AddBattlerTagAttr {
constructor() {
super(BattlerTagType.STOCKPILE_TWO, true, true, 20, 20);
}
getCondition(): MoveConditionFunc {
return (user, target, move) => (!user.getTag(this.tagType) && !!user.getTag(BattlerTagType.STOCKPILE_ONE));
}
canApply(user: Pokemon, target: Pokemon, move: Move, args: any[]) {
if (!super.canApply(user, target, move, args))
return false;
const canApplyStockpileTwo = this.getCondition();
return canApplyStockpileTwo(user, target, move);
}
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
if (!super.apply(user, target, move, args))
return false;
if (!this.canApply(user, target, move, args))
return false;
user.scene.queueMessage(getPokemonMessage(target, `\nstockpiled 2.`));
return true;
}
}
export class StockpileThreeAttr extends AddBattlerTagAttr {
constructor() {
super(BattlerTagType.STOCKPILE_THREE, true, true, 20, 20);
}
getCondition(): MoveConditionFunc {
return (user, target, move) => (!user.getTag(this.tagType) && !!user.getTag(BattlerTagType.STOCKPILE_TWO));
}
canApply(user: Pokemon, target: Pokemon, move: Move, args: any[]) {
if (!super.canApply(user, target, move, args))
return false;
const canApplyStockpileThree = this.getCondition();
return canApplyStockpileThree(user, target, move);
}
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
if (!super.apply(user, target, move, args))
return false;
if (!this.canApply(user, target, move, args))
return false;
user.scene.queueMessage(getPokemonMessage(target, `\nstockpiled 3.`));
return true;
}
}
export class StockpileAttr extends AddBattlerTagAttr {
constructor() {
super(BattlerTagType.STOCKPILE_THREE, true, true, 0, 10);
}
getStockpile(stacks: integer = 1): MoveConditionFunc {
let stockpileType = BattlerTagType.STOCKPILE_ONE;
switch (stacks) {
case 2:
stockpileType = BattlerTagType.STOCKPILE_TWO;
break;
case 3:
stockpileType = BattlerTagType.STOCKPILE_THREE;
break;
default:
}
return (user, target, move) => !user.getTag(stockpileType);
};
setStockpile(user: Pokemon, target: Pokemon, move: Move){
const getStockpileOne = this.getStockpile(1);
const getStockpileTwo = this.getStockpile(2);
if (getStockpileOne(user, target, move) && !getStockpileTwo(user, target, move)) {
// if there's only 1 stockpile, give 2nd stockpile
this.tagType = BattlerTagType.STOCKPILE_TWO;
} else if (!getStockpileOne(user, target, move)) {
// if there's no stockpile, give 1st stockpile
this.tagType = BattlerTagType.STOCKPILE_ONE;
} else {
// tagType stays as STOCKPILE_THREE
// if there's 2 stockpile, then we give 3rd stockpile
// if there's 3 stockpile, then move fails
}
}
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
@ -4530,7 +4648,7 @@ export function initMoves() {
* need to find a way to remove stockpile when the relevant moves are used
*/
new SelfStatusMove(Moves.STOCKPILE, Type.NORMAL, -1, 20, -1, 0, 3)
.attr(AddBattlerTagAttr, BattlerTagType.STOCKPILE, true, false, 0, 10)
.attr(StockpileAttr)
.attr(StatChangeAttr, [ BattleStat.DEF, BattleStat.SPDEF ], 1, true)
.partial(),
new AttackMove(Moves.SPIT_UP, Type.NORMAL, MoveCategory.SPECIAL, -1, 100, 10, -1, 0, 3)

View File

@ -81,6 +81,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
public luck: integer;
public pauseEvolutions: boolean;
public pokerus: boolean;
public stockpile: integer;
public fusionSpecies: PokemonSpecies;
public fusionFormIndex: integer;