UPDATE: Added localisation to the trigger message

pull/410/head^2
Marek Sison 2024-05-16 02:17:19 +08:00
parent 38c8eb9396
commit bb7493aa81
9 changed files with 72 additions and 55 deletions

View File

@ -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
}

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;