Add Move Effect Message to Power & Guard Split

This commit is contained in:
xsn34kzx 2024-08-21 00:48:56 -04:00
parent dc0f90d4d5
commit 272a3a31f2
2 changed files with 28 additions and 19 deletions

View File

@ -5912,37 +5912,46 @@ export class SwapStatAttr extends MoveEffectAttr {
/**
* Attribute used for status moves, namely Power Split and Guard Split,
* that take the average of a user's and target's corresponding
* stats and assign that average back to that stat.
* stats and assign that average back to each corresponding stat.
* @extends MoveEffectAttr
* @see {@linkcode apply}
*/
export class AverageStatAttr extends MoveEffectAttr {
/** The stat to be averaged between the user and the target */
private stat: EffectiveStat;
export class AverageStatsAttr extends MoveEffectAttr {
/** The stats to be averaged individually between the user and the target */
private stats: readonly EffectiveStat[];
private msgKey: string;
constructor(stat: EffectiveStat) {
constructor(stats: readonly EffectiveStat[], msgKey: string) {
super();
this.stat = stat;
this.stats = stats;
this.msgKey = msgKey;
}
/**
* Takes the average of the user's and target's corresponding current
* {@linkcode stat} values and sets that stat to the average for both
* Takes the average of the user's and target's corresponding {@linkcode stat}
* values and sets those stats to the corresponding average for both
* temporarily.
* @param user the {@linkcode Pokemon} that used the move
* @param target the {@linkcode Pokemon} that the move was used on
* @param _move N/A
* @param _args N/A
* @param move N/A
* @param args N/A
* @returns true if attribute application succeeds
*/
apply(user: Pokemon, target: Pokemon, _move: Move, _args: any[]): boolean {
const avg = Math.floor((user.getStat(this.stat, false) + target.getStat(this.stat, false)) / 2);
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
if (super.apply(user, target, move, args)) {
for (const s of this.stats) {
const avg = Math.floor((user.getStat(s, false) + target.getStat(s, false)) / 2);
user.setStat(this.stat, avg, false);
target.setStat(this.stat, avg, false);
user.setStat(s, avg, false);
target.setStat(s, avg, false);
}
return true;
user.scene.queueMessage(i18next.t(this.msgKey, { pokemonName: getPokemonNameWithAffix(user) }));
return true;
}
return false;
}
}
@ -7600,11 +7609,9 @@ export function initMoves() {
.target(MoveTarget.USER_SIDE)
.attr(AddArenaTagAttr, ArenaTagType.WIDE_GUARD, 1, true, true),
new StatusMove(Moves.GUARD_SPLIT, Type.PSYCHIC, -1, 10, -1, 0, 5)
.attr(AverageStatAttr, Stat.DEF)
.attr(AverageStatAttr, Stat.SPDEF),
.attr(AverageStatsAttr, [ Stat.DEF, Stat.SPDEF ], "moveTriggers:guardSplit"),
new StatusMove(Moves.POWER_SPLIT, Type.PSYCHIC, -1, 10, -1, 0, 5)
.attr(AverageStatAttr, Stat.ATK)
.attr(AverageStatAttr, Stat.SPATK),
.attr(AverageStatsAttr, [ Stat.ATK, Stat.SPATK ], "moveTriggers:powerSplit"),
new StatusMove(Moves.WONDER_ROOM, Type.PSYCHIC, -1, 10, -1, 0, 5)
.ignoresProtect()
.target(MoveTarget.BOTH_SIDES)

View File

@ -7,6 +7,8 @@ export const moveTriggers: SimpleTranslationEntries = {
"switchedStatChanges": "{{pokemonName}} switched stat changes with the target!",
"switchedTwoStatChanges": "{{pokemonName}} switched all changes to its {{firstStat}}\nand {{secondStat}} with its target!",
"swappedStat": "{{pokemonName}} switched {{stat}} with its target!",
"guardSplit": "{{pokemonName}} shared its guard with the target!",
"powerSplit": "{{pokemonName}} shared its power with the target!",
"goingAllOutForAttack": "{{pokemonName}} is going all out for this attack!",
"regainedHealth": "{{pokemonName}} regained\nhealth!",
"keptGoingAndCrashed": "{{pokemonName}} kept going\nand crashed!",