From bb7493aa8182413dc55b66268190d6bcd6bad3e7 Mon Sep 17 00:00:00 2001 From: Marek Sison Date: Thu, 16 May 2024 02:17:19 +0800 Subject: [PATCH] UPDATE: Added localisation to the trigger message --- src/data/enums/battler-tag-type.ts | 5 +- src/data/move.ts | 110 ++++++++++++++------------- src/locales/de/ability-trigger.ts | 1 + src/locales/en/ability-trigger.ts | 1 + src/locales/es/ability-trigger.ts | 1 + src/locales/fr/ability-trigger.ts | 1 + src/locales/it/ability-trigger.ts | 1 + src/locales/pt_BR/ability-trigger.ts | 6 ++ src/locales/zh_CN/ability-trigger.ts | 1 + 9 files changed, 72 insertions(+), 55 deletions(-) create mode 100644 src/locales/pt_BR/ability-trigger.ts diff --git a/src/data/enums/battler-tag-type.ts b/src/data/enums/battler-tag-type.ts index d3ab6fc48..1a0a3272f 100644 --- a/src/data/enums/battler-tag-type.ts +++ b/src/data/enums/battler-tag-type.ts @@ -56,11 +56,8 @@ export enum BattlerTagType { CHARGED = "CHARGED", GROUNDED = "GROUNDED", MAGNET_RISEN = "MAGNET_RISEN", -<<<<<<< HEAD STOCKPILE_ONE = "STOCKPILE_ONE", STOCKPILE_TWO = "STOCKPILE_TWO", - STOCKPILE_THREE = "STOCKPILE_THREE" -======= + STOCKPILE_THREE = "STOCKPILE_THREE", MINIMIZED = "MINIMIZED" ->>>>>>> 78f79653049baff0ec6514b743e5f602d43ad391 } diff --git a/src/data/move.ts b/src/data/move.ts index 915625e62..45afec61b 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -4,7 +4,7 @@ import { BattleEndPhase, MovePhase, NewBattlePhase, PartyStatusCurePhase, Pokemo import { BattleStat, getBattleStatName } from "./battle-stat"; import { EncoreTag } from "./battler-tags"; import { BattlerTagType } from "./enums/battler-tag-type"; -import { getPokemonMessage } from "../messages"; +import { getPokemonMessage, getPokemonPrefix } from "../messages"; import Pokemon, { AttackMoveResult, EnemyPokemon, HitResult, MoveResult, PlayerPokemon, PokemonMove, TurnMove } from "../field/pokemon"; import { StatusEffect, getStatusEffectHealText } from "./status-effect"; import { Type } from "./type"; @@ -949,28 +949,27 @@ export class HealAttr extends MoveEffectAttr { } } +/** Attribute used by the {@link Moves.STOCKPILE} to heal based on STOCKPILE stored*/ export class SwallowHealAttr extends HealAttr { + constructor() { + super(1, true, true); + } + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - const stock = this.getStockpiles(user); + // uses the getStockpiles function to get number of STOCKPILE's stored + const stock = getStockpiles(user); + /** + * if stock is: + * 1, then healing is 0.25 of health + * 2, then healing is 0.50 of health + * 3, then healing is 1.00 of health + */ this.getHealRatio(stock >= 3 ? 1 : (stock * 0.25)); super.apply(user, target, move, args); return true; } - - getStockpiles(user: Pokemon): integer { - let stock = 0; - const tagList = [BattlerTagType.STOCKPILE_ONE, BattlerTagType.STOCKPILE_TWO, BattlerTagType.STOCKPILE_THREE]; - - for (let x = 0 ; x < tagList.length ; x++){ - if (user.getTag(tagList[x])){ - stock++; - } - } - - return stock; - } } /** @@ -1866,8 +1865,11 @@ export class GrowthStatChangeAttr extends StatChangeAttr { } } +/** Attribute for the stat changes for {@link Move.STOCKPILE}, {@link Move.SPIT_UP}, and {@link Move.SWALLOW}*/ export class StockpileStatChangeAttr extends StatChangeAttr { private tagTypes = [BattlerTagType.STOCKPILE_ONE, BattlerTagType.STOCKPILE_TWO, BattlerTagType.STOCKPILE_THREE]; + // this will show if we will gain 1 stack of stats with Stockpile + // or lose stacks of stats with Spit Up or Swallow private gainStats:boolean; constructor(gainStats:boolean = true) { @@ -1880,12 +1882,15 @@ export class StockpileStatChangeAttr extends StatChangeAttr { const stock = getStockpiles(user); if (!this.gainStats) { - // levels become equal to the negative of stock + /** + * since the Pokemon will be losing stats in this if statement, + * {@link this.levels} become equal to the negative of stock + */ this.levels = stock * -1; - // remove the stats equal to the number of stock + // remove the stats equal to the number of stocks for (let tagType of this.tagTypes) - (this.selfTarget ? user : target).removeTag(tagType); + user.removeTag(tagType); } if (!super.apply(user, target, move, args)) @@ -2457,26 +2462,21 @@ export class WaterShurikenPowerAttr extends VariablePowerAttr { } } +/** Attribute used by the {@link Moves.SPIT_UP} based on the number of stored STOCKPILE BattlerTagTypes*/ export class SpitUpPowerAttr extends VariablePowerAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { const power = args[0] as Utils.NumberHolder; - power.value = this.getPower(user, target, move); + /** + * if stock is: + * 1, then power is 100 + * 2, then power is 100 + * 3, then power is 100 + */ + power.value = getStockpiles(user)*100; return true; } - - getPower(user: Pokemon, target: Pokemon, move: Move): number { - if (!!user.getTag(BattlerTagType.STOCKPILE_THREE)){ - return 300; - } else if (!!user.getTag(BattlerTagType.STOCKPILE_TWO)){ - return 200; - } else if (!!user.getTag(BattlerTagType.STOCKPILE_ONE)){ - return 100; - } else { - return 0; - } - } } export class VariableAtkAttr extends MoveAttr { @@ -3344,46 +3344,52 @@ export class FaintCountdownAttr extends AddBattlerTagAttr { } } -<<<<<<< HEAD +/** Attribute used by the {@link Moves.STOCKPILE} to add the STOCKPILE BattlerTagTypes*/ export class StockpileAttr extends AddBattlerTagAttr { constructor() { super(BattlerTagType.STOCKPILE_THREE, true, false, 20, 20); } + /** + * This changes {@link this.tagType} based on the {@link stock} of the user + * @param user is needed to retrieve how much stockpile the Pokemon has + * as well as its name for the message + */ apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + // uses the getStockpiles() method to see how many stock the Pokemon has right now const stock = getStockpiles(user); - let stockType = BattlerTagType.STOCKPILE_THREE; + // boolean failsafe that the tag will not apply when inappropriate let willFail = false; + // check how many stock the user has then change the tag based on that + // keep the STOCKPILE_THREE tag if the stock is 2 or more switch (stock){ case 0: - stockType = BattlerTagType.STOCKPILE_ONE; + this.tagType = BattlerTagType.STOCKPILE_ONE; break; case 1: - stockType = BattlerTagType.STOCKPILE_TWO; + this.tagType = BattlerTagType.STOCKPILE_TWO; break; - case 3: - willFail = true; - break default: - // keep it at STOCKPILE_THREE + if (stock == 3) + willFail = true; break; } - this.tagType = stockType; - if (willFail || !super.apply(user, target, move, args)) return false; - user.scene.queueMessage(getPokemonMessage(target, `\nstockpiled ${stock+1}.`)); + user.scene.queueMessage(this.getTriggerMessage(user, (stock+1))); return true; } + + getTriggerMessage(pokemon: Pokemon, stockpileNumber: integer, ...args: any[]) { + return i18next.t('abilityTriggers:stockpile', {pokemonName: `${getPokemonPrefix(pokemon)}${pokemon.name}`, stockpileNumber: stockpileNumber}); + } } -======= /** Attribute used when a move hits a {@link BattlerTagType} for double damage */ ->>>>>>> 78f79653049baff0ec6514b743e5f602d43ad391 export class HitsTagAttr extends MoveAttr { /** The {@link BattlerTagType} this move hits */ public tagType: BattlerTagType; @@ -4356,6 +4362,11 @@ export class VariableTargetAttr extends MoveAttr { } } +/** + * Used to get how many stockpiles a Pokemon has + * @param user to retrieve the BattlerTagTypes + * @returns number of stockpile BattleTagTypes on the Pokemon + */ function getStockpiles(user: Pokemon) : integer { let s = 0; const stock = [BattlerTagType.STOCKPILE_ONE, BattlerTagType.STOCKPILE_TWO, BattlerTagType.STOCKPILE_THREE]; @@ -5221,19 +5232,16 @@ export function initMoves() { new SelfStatusMove(Moves.STOCKPILE, Type.NORMAL, -1, 20, -1, 0, 3) .attr(StockpileAttr) .attr(StockpileStatChangeAttr) - .condition(failOnMaxStockCondition) - .partial(), + .condition(failOnMaxStockCondition), new AttackMove(Moves.SPIT_UP, Type.NORMAL, MoveCategory.SPECIAL, -1, 100, 10, -1, 0, 3) .attr(SpitUpPowerAttr) .attr(StockpileStatChangeAttr, false) - .condition(failOnNoStockCondition) - .partial(), + .condition(failOnNoStockCondition), new SelfStatusMove(Moves.SWALLOW, Type.NORMAL, -1, 10, -1, 0, 3) - .attr(SwallowHealAttr, 1) + .attr(SwallowHealAttr) .attr(StockpileStatChangeAttr, false) .condition(failOnNoStockCondition) - .triageMove() - .partial(), + .triageMove(), new AttackMove(Moves.HEAT_WAVE, Type.FIRE, MoveCategory.SPECIAL, 95, 90, 10, 10, 0, 3) .attr(HealStatusEffectAttr, true, StatusEffect.FREEZE) .attr(StatusEffectAttr, StatusEffect.BURN) diff --git a/src/locales/de/ability-trigger.ts b/src/locales/de/ability-trigger.ts index 27d2053b6..6c2beba4e 100644 --- a/src/locales/de/ability-trigger.ts +++ b/src/locales/de/ability-trigger.ts @@ -2,4 +2,5 @@ import { SimpleTranslationEntries } from "#app/plugins/i18n"; export const abilityTriggers: SimpleTranslationEntries = { 'blockRecoilDamage' : `{{pokemonName}} wurde durch {{abilityName}}\nvor Rückstoß geschützt!`, + 'stockpile' : `{{pokemonName}}\n hat {{stockpileNumber}} gehortet!` } as const; diff --git a/src/locales/en/ability-trigger.ts b/src/locales/en/ability-trigger.ts index 889007412..f1dddb423 100644 --- a/src/locales/en/ability-trigger.ts +++ b/src/locales/en/ability-trigger.ts @@ -2,4 +2,5 @@ import { SimpleTranslationEntries } from "#app/plugins/i18n"; export const abilityTriggers: SimpleTranslationEntries = { 'blockRecoilDamage' : `{{pokemonName}}'s {{abilityName}}\nprotected it from recoil!`, + 'stockpile' : `{{pokemonName}}\n stockpiled {{stockpileNumber}}!` } as const; \ No newline at end of file diff --git a/src/locales/es/ability-trigger.ts b/src/locales/es/ability-trigger.ts index 889007412..71a8f8f3d 100644 --- a/src/locales/es/ability-trigger.ts +++ b/src/locales/es/ability-trigger.ts @@ -2,4 +2,5 @@ import { SimpleTranslationEntries } from "#app/plugins/i18n"; export const abilityTriggers: SimpleTranslationEntries = { 'blockRecoilDamage' : `{{pokemonName}}'s {{abilityName}}\nprotected it from recoil!`, + 'stockpile' : `{{pokemonName}}\n reservo {{stockpileNumber}}!` } as const; \ No newline at end of file diff --git a/src/locales/fr/ability-trigger.ts b/src/locales/fr/ability-trigger.ts index f668ee5e8..073379caa 100644 --- a/src/locales/fr/ability-trigger.ts +++ b/src/locales/fr/ability-trigger.ts @@ -2,4 +2,5 @@ import { SimpleTranslationEntries } from "#app/plugins/i18n"; export const abilityTriggers: SimpleTranslationEntries = { 'blockRecoilDamage' : `{{abilityName}}\nde {{pokemonName}} le protège du contrecoup !`, + 'stockpile' : `{{pokemonName}}\n en a stocké {{stockpileNumber}}!` } as const; diff --git a/src/locales/it/ability-trigger.ts b/src/locales/it/ability-trigger.ts index de41e0872..bc15677b5 100644 --- a/src/locales/it/ability-trigger.ts +++ b/src/locales/it/ability-trigger.ts @@ -2,4 +2,5 @@ import { SimpleTranslationEntries } from "#app/plugins/i18n"; export const abilityTriggers: SimpleTranslationEntries = { 'blockRecoilDamage' : `{{abilityName}} di {{pokemonName}}\nl'ha protetto dal contraccolpo!`, + 'stockpile' : `{{pokemonName}}\n ne ha accumulati {{stockpileNumber}}!` } as const; \ No newline at end of file diff --git a/src/locales/pt_BR/ability-trigger.ts b/src/locales/pt_BR/ability-trigger.ts new file mode 100644 index 000000000..f1dddb423 --- /dev/null +++ b/src/locales/pt_BR/ability-trigger.ts @@ -0,0 +1,6 @@ +import { SimpleTranslationEntries } from "#app/plugins/i18n"; + +export const abilityTriggers: SimpleTranslationEntries = { + 'blockRecoilDamage' : `{{pokemonName}}'s {{abilityName}}\nprotected it from recoil!`, + 'stockpile' : `{{pokemonName}}\n stockpiled {{stockpileNumber}}!` +} as const; \ No newline at end of file diff --git a/src/locales/zh_CN/ability-trigger.ts b/src/locales/zh_CN/ability-trigger.ts index 889007412..f1dddb423 100644 --- a/src/locales/zh_CN/ability-trigger.ts +++ b/src/locales/zh_CN/ability-trigger.ts @@ -2,4 +2,5 @@ import { SimpleTranslationEntries } from "#app/plugins/i18n"; export const abilityTriggers: SimpleTranslationEntries = { 'blockRecoilDamage' : `{{pokemonName}}'s {{abilityName}}\nprotected it from recoil!`, + 'stockpile' : `{{pokemonName}}\n stockpiled {{stockpileNumber}}!` } as const; \ No newline at end of file