mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-14 12:22:19 +02:00
refactoring solution to individual attr
This commit is contained in:
parent
0c7c3ba218
commit
47e0890265
@ -111,7 +111,6 @@ export enum MoveFlags {
|
|||||||
|
|
||||||
type MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => boolean;
|
type MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => boolean;
|
||||||
type UserMoveConditionFunc = (user: Pokemon, move: Move) => boolean;
|
type UserMoveConditionFunc = (user: Pokemon, move: Move) => boolean;
|
||||||
type MoveApplyFunc = (user:Pokemon, target: Pokemon, move: Move, args: any[]) => boolean| Promise<Boolean>;
|
|
||||||
|
|
||||||
export default class Move implements Localizable {
|
export default class Move implements Localizable {
|
||||||
public id: Moves;
|
public id: Moves;
|
||||||
@ -5124,39 +5123,20 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class StatusForceSwitchOutAttr extends ForceSwitchOutAttr {
|
|
||||||
// inherit from ForceSwitchOutAttr
|
|
||||||
|
|
||||||
/** the extra apply function to be called */
|
export class ChillyReceptionAttr extends ForceSwitchOutAttr {
|
||||||
private statusApplyFunc: MoveApplyFunc;
|
|
||||||
/** the extra status check to be called */
|
|
||||||
private statusCondFunc: MoveConditionFunc ;
|
|
||||||
|
|
||||||
/**
|
// using inherited constructor
|
||||||
* This class extends ForceSwitchOutAttr, we can think of this class as ForceSwitchOut with "something extra" in it's apply() and getConditions() functions
|
|
||||||
* @param user boolean for if this is the user switching out
|
|
||||||
* @param batonPass boolean if the switch is baton pass
|
|
||||||
* @param statusApplyFunc {@linkcode MoveApplyFunc} the additional apply() function to run
|
|
||||||
* @param statusCondFunc {@linkcode MoveConditionFunc} the additional move condition function to run
|
|
||||||
*/
|
|
||||||
constructor(user?: boolean, batonPass?: boolean, statusApplyFunc?, statusCondFunc? ) {
|
|
||||||
super(user, batonPass);
|
|
||||||
this.statusApplyFunc = statusApplyFunc;
|
|
||||||
this.statusCondFunc = statusCondFunc;
|
|
||||||
}
|
|
||||||
|
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
|
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
|
||||||
|
user.scene.arena.trySetWeather(WeatherType.SNOW, true);
|
||||||
this.statusApplyFunc(user, target, move, args);
|
|
||||||
return super.apply(user, target, move, args);
|
return super.apply(user, target, move, args);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getCondition(): MoveConditionFunc {
|
getCondition(): MoveConditionFunc {
|
||||||
// returns True/False for if the move should fail or not: currently logic is an OR. ie: if either condition returns true, then the move should be executed
|
// chilly reception move will go through if the weather is change-able to snow, or the user can switch out, else move will fail
|
||||||
return (user, target, move) => this.statusCondFunc(user, target, move) || super.getSwitchOutCondition()(user, target, move);
|
return (user, target, move) => user.scene.arena.trySetWeather(WeatherType.SNOW, true) || super.getSwitchOutCondition()(user, target, move);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
export class RemoveTypeAttr extends MoveEffectAttr {
|
export class RemoveTypeAttr extends MoveEffectAttr {
|
||||||
|
|
||||||
@ -9194,10 +9174,7 @@ export function initMoves() {
|
|||||||
.unimplemented(),
|
.unimplemented(),
|
||||||
new SelfStatusMove(Moves.CHILLY_RECEPTION, Type.ICE, -1, 10, -1, 0, 9)
|
new SelfStatusMove(Moves.CHILLY_RECEPTION, Type.ICE, -1, 10, -1, 0, 9)
|
||||||
.attr(PreMoveMessageAttr, (user, move) => i18next.t("moveTriggers:chillyReception", {pokemonName: getPokemonNameWithAffix(user)}))
|
.attr(PreMoveMessageAttr, (user, move) => i18next.t("moveTriggers:chillyReception", {pokemonName: getPokemonNameWithAffix(user)}))
|
||||||
.attr(StatusForceSwitchOutAttr, true, false,
|
.attr(ChillyReceptionAttr, true, false),
|
||||||
(user: Pokemon, target: Pokemon, move: Move, args: any[]) => user.scene.arena.trySetWeather(WeatherType.SNOW, true),
|
|
||||||
(user, target, move) => (user.scene.arena.weather?.weatherType === WeatherType.SNOW) ? false : true
|
|
||||||
),
|
|
||||||
new SelfStatusMove(Moves.TIDY_UP, Type.NORMAL, -1, 10, -1, 0, 9)
|
new SelfStatusMove(Moves.TIDY_UP, Type.NORMAL, -1, 10, -1, 0, 9)
|
||||||
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPD ], 1, true, null, true, true)
|
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPD ], 1, true, null, true, true)
|
||||||
.attr(RemoveArenaTrapAttr, true),
|
.attr(RemoveArenaTrapAttr, true),
|
||||||
|
Loading…
Reference in New Issue
Block a user