mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-01-17 22:40:59 +00:00
[Bug] Adjusts bug bite/pluck to remove berry pouch preservation on opponent berries (#2047)
* Adjusts bug bite functionality when stealing from opponent with three berry pouches * Adjusts bug bite functionality when stealing from opponent with three berry pouches * Adjusts bug bite to remove berry pouch preservation on opponent berries * Remove Promise<Boolean> where unnecessary Leftover code removed from previous testing of the EatBerryAttr class. * Remove undefined check on chosenBerry Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Update StealEatBerryAttr if-clause readability Decrementing inside of an if-clause removed for readability. Changed to check: if count is 1, then remove modifier. * Localization of StealEatBerryAttr battle message * Fixes berry incrementing after improper adjustment to readability * Fixes berry decrementing after improper adjustment to readability * Update battle.ts * Update src/locales/fr/battle.ts Co-authored-by: Lugiad' <adrien.grivel@hotmail.fr> * Update battle.ts properly Incorrectly added localization in previous commit * Remove unnecessary space * Update src/locales/ko/battle.ts I do not have experience with Korean, so this may need other review. Co-authored-by: Enoch <enoch.jwsong@gmail.com> * Rewrites EatBerryAttr to combine with StealEatBerryAttr * Removes excess lines * Revert and refactor StealEatBerry and EatBerryAttr * Refactor for early returns instead of nesting --------- Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: Lugiad' <adrien.grivel@hotmail.fr> Co-authored-by: Enoch <enoch.jwsong@gmail.com>
This commit is contained in:
parent
0bc4f26b9d
commit
df18dd885d
@ -1909,7 +1909,7 @@ export class RemoveHeldItemAttr extends MoveEffectAttr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute that causes targets of the move to eat a berry. If chosenBerry is not overridden, a random berry will be picked from the target's inventory.
|
* Attribute that causes targets of the move to eat a berry. Used for Teatime, Stuff Cheeks
|
||||||
*/
|
*/
|
||||||
export class EatBerryAttr extends MoveEffectAttr {
|
export class EatBerryAttr extends MoveEffectAttr {
|
||||||
protected chosenBerry: BerryModifier;
|
protected chosenBerry: BerryModifier;
|
||||||
@ -1918,42 +1918,29 @@ export class EatBerryAttr extends MoveEffectAttr {
|
|||||||
this.chosenBerry = undefined;
|
this.chosenBerry = undefined;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Causes the target to eat a berry.
|
* Causes the target to eat a berry.
|
||||||
* @param user {@linkcode Pokemon} Pokemon that used the move
|
* @param user {@linkcode Pokemon} Pokemon that used the move
|
||||||
* @param target {@linkcode Pokemon} Pokemon that will eat a berry
|
* @param target {@linkcode Pokemon} Pokemon that will eat a berry
|
||||||
* @param move {@linkcode Move} The move being used
|
* @param move {@linkcode Move} The move being used
|
||||||
* @param args Unused
|
* @param args Unused
|
||||||
* @returns {boolean} true if the function succeeds
|
* @returns {boolean} true if the function succeeds
|
||||||
*/
|
*/
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||||
if (!super.apply(user, target, move, args)) {
|
if (!super.apply(user, target, move, args)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.chosenBerry === undefined) { // if no berry has been provided, pick a random berry from their inventory
|
const heldBerries = this.getTargetHeldBerries(target);
|
||||||
const heldBerries = this.getTargetHeldBerries(target);
|
if (heldBerries.length <= 0) {
|
||||||
if (heldBerries.length <= 0) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this.chosenBerry = heldBerries[user.randSeedInt(heldBerries.length)];
|
|
||||||
}
|
}
|
||||||
|
this.chosenBerry = heldBerries[user.randSeedInt(heldBerries.length)];
|
||||||
getBerryEffectFunc(this.chosenBerry.berryType)(target); // target eats the berry
|
|
||||||
|
|
||||||
const preserve = new Utils.BooleanHolder(false);
|
const preserve = new Utils.BooleanHolder(false);
|
||||||
target.scene.applyModifiers(PreserveBerryModifier, target.isPlayer(), target, preserve);
|
target.scene.applyModifiers(PreserveBerryModifier, target.isPlayer(), target, preserve); // check for berry pouch preservation
|
||||||
|
if (!preserve.value) {
|
||||||
if (!preserve.value) { // remove the eaten berry if not preserved
|
this.reduceBerryModifier(target);
|
||||||
if (!--this.chosenBerry.stackCount) {
|
|
||||||
target.scene.removeModifier(this.chosenBerry, !target.isPlayer());
|
|
||||||
}
|
|
||||||
target.scene.updateModifiers(target.isPlayer());
|
|
||||||
}
|
}
|
||||||
|
this.eatBerry(target);
|
||||||
this.chosenBerry = undefined;
|
|
||||||
|
|
||||||
applyAbAttrs(HealFromBerryUseAbAttr, target, new Utils.BooleanHolder(false));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1962,7 +1949,21 @@ export class EatBerryAttr extends MoveEffectAttr {
|
|||||||
&& (m as BerryModifier).pokemonId === target.id, target.isPlayer()) as BerryModifier[];
|
&& (m as BerryModifier).pokemonId === target.id, target.isPlayer()) as BerryModifier[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reduceBerryModifier(target: Pokemon) {
|
||||||
|
if (this.chosenBerry.stackCount === 1) {
|
||||||
|
target.scene.removeModifier(this.chosenBerry, !target.isPlayer());
|
||||||
|
} else {
|
||||||
|
this.chosenBerry.stackCount--;
|
||||||
|
}
|
||||||
|
target.scene.updateModifiers(target.isPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
eatBerry(consumer: Pokemon) {
|
||||||
|
getBerryEffectFunc(this.chosenBerry.berryType)(consumer); // consumer eats the berry
|
||||||
|
applyAbAttrs(HealFromBerryUseAbAttr, consumer, new Utils.BooleanHolder(false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute used for moves that steal a random berry from the target. The user then eats the stolen berry.
|
* Attribute used for moves that steal a random berry from the target. The user then eats the stolen berry.
|
||||||
* Used for Pluck & Bug Bite.
|
* Used for Pluck & Bug Bite.
|
||||||
@ -1972,36 +1973,30 @@ export class StealEatBerryAttr extends EatBerryAttr {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* User steals a random berry from the target and then eats it.
|
* User steals a random berry from the target and then eats it.
|
||||||
* @param {Pokemon} user Pokemon that used the move and will eat the stolen berry
|
* @param {Pokemon} user Pokemon that used the move and will eat the stolen berry
|
||||||
* @param {Pokemon} target Pokemon that will have its berry stolen
|
* @param {Pokemon} target Pokemon that will have its berry stolen
|
||||||
* @param {Move} move Move being used
|
* @param {Move} move Move being used
|
||||||
* @param {any[]} args Unused
|
* @param {any[]} args Unused
|
||||||
* @returns {boolean} true if the function succeeds
|
* @returns {boolean} true if the function succeeds
|
||||||
*/
|
*/
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||||
|
|
||||||
const cancelled = new Utils.BooleanHolder(false);
|
const cancelled = new Utils.BooleanHolder(false);
|
||||||
applyAbAttrs(BlockItemTheftAbAttr, target, cancelled); // check for abilities that block item theft
|
applyAbAttrs(BlockItemTheftAbAttr, target, cancelled); // check for abilities that block item theft
|
||||||
if (cancelled.value === true) {
|
if (cancelled.value === true) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const heldBerries = this.getTargetHeldBerries(target).filter(i => i.getTransferrable(false));
|
const heldBerries = this.getTargetHeldBerries(target).filter(i => i.getTransferrable(false));
|
||||||
|
if (heldBerries.length <= 0) {
|
||||||
if (heldBerries.length) { // if the target has berries, pick a random berry and steal it
|
return false;
|
||||||
this.chosenBerry = heldBerries[user.randSeedInt(heldBerries.length)];
|
|
||||||
|
|
||||||
if (this.chosenBerry.stackCount === 1) { // remove modifier if its the last berry
|
|
||||||
target.scene.removeModifier(this.chosenBerry, !target.isPlayer());
|
|
||||||
}
|
|
||||||
target.scene.updateModifiers(target.isPlayer());
|
|
||||||
|
|
||||||
user.scene.queueMessage(getPokemonMessage(user, ` stole and ate\n${target.name}'s ${this.chosenBerry.type.name}!`));
|
|
||||||
return super.apply(user, user, move, args);
|
|
||||||
}
|
}
|
||||||
|
// if the target has berries, pick a random berry and steal it
|
||||||
return false;
|
this.chosenBerry = heldBerries[user.randSeedInt(heldBerries.length)];
|
||||||
|
const message = i18next.t("battle:stealEatBerry", {pokemonName: user.name, targetName: target.name, berryName: this.chosenBerry.type.name});
|
||||||
|
user.scene.queueMessage(message);
|
||||||
|
this.reduceBerryModifier(target);
|
||||||
|
this.eatBerry(user);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@ export const battle: SimpleTranslationEntries = {
|
|||||||
"useMove": "{{pokemonNameWithAffix}} setzt {{moveName}} ein!",
|
"useMove": "{{pokemonNameWithAffix}} setzt {{moveName}} ein!",
|
||||||
"drainMessage": "{{pokemonName}} wurde Energie abgesaugt",
|
"drainMessage": "{{pokemonName}} wurde Energie abgesaugt",
|
||||||
"regainHealth": "KP von {{pokemonName}} wurden wieder aufgefrischt!",
|
"regainHealth": "KP von {{pokemonName}} wurden wieder aufgefrischt!",
|
||||||
|
"stealEatBerry": "{{pokemonName}} stole and ate\n{{targetName}}'s {{berryName}}!",
|
||||||
"fainted": "{{pokemonNameWithAffix}} wurde besiegt!",
|
"fainted": "{{pokemonNameWithAffix}} wurde besiegt!",
|
||||||
"statRose": "{{stats}} von {{pokemonNameWithAffix}} steigt!",
|
"statRose": "{{stats}} von {{pokemonNameWithAffix}} steigt!",
|
||||||
"statSharplyRose": "{{stats}} von {{pokemonNameWithAffix}} steigt stark!",
|
"statSharplyRose": "{{stats}} von {{pokemonNameWithAffix}} steigt stark!",
|
||||||
|
@ -65,6 +65,7 @@ export const battle: SimpleTranslationEntries = {
|
|||||||
"useMove": "{{pokemonNameWithAffix}} used {{moveName}}!",
|
"useMove": "{{pokemonNameWithAffix}} used {{moveName}}!",
|
||||||
"drainMessage": "{{pokemonName}} had its\nenergy drained!",
|
"drainMessage": "{{pokemonName}} had its\nenergy drained!",
|
||||||
"regainHealth": "{{pokemonName}} regained\nhealth!",
|
"regainHealth": "{{pokemonName}} regained\nhealth!",
|
||||||
|
"stealEatBerry": "{{pokemonName}} stole and ate\n{{targetName}}'s {{berryName}}!",
|
||||||
"fainted": "{{pokemonNameWithAffix}} fainted!",
|
"fainted": "{{pokemonNameWithAffix}} fainted!",
|
||||||
"statRose": "{{pokemonNameWithAffix}}'s {{stats}} rose!",
|
"statRose": "{{pokemonNameWithAffix}}'s {{stats}} rose!",
|
||||||
"statSharplyRose": "{{pokemonNameWithAffix}}'s {{stats}} sharply rose!",
|
"statSharplyRose": "{{pokemonNameWithAffix}}'s {{stats}} sharply rose!",
|
||||||
|
@ -65,6 +65,7 @@ export const battle: SimpleTranslationEntries = {
|
|||||||
"useMove": "¡{{pokemonNameWithAffix}} usó {{moveName}}!",
|
"useMove": "¡{{pokemonNameWithAffix}} usó {{moveName}}!",
|
||||||
"drainMessage": "¡{{pokemonName}} tuvo su\nenergía absorbida!",
|
"drainMessage": "¡{{pokemonName}} tuvo su\nenergía absorbida!",
|
||||||
"regainHealth": "¡{{pokemonName}} recuperó\nPS!",
|
"regainHealth": "¡{{pokemonName}} recuperó\nPS!",
|
||||||
|
"stealEatBerry": "¡{{pokemonName}} robó la {{berryName}}\nde {{targetName}} y se la comió!",
|
||||||
"fainted": "¡{{pokemonNameWithAffix}} se debilitó!",
|
"fainted": "¡{{pokemonNameWithAffix}} se debilitó!",
|
||||||
"statRose": "¡El {{stats}} de {{pokemonNameWithAffix}} ha subido!",
|
"statRose": "¡El {{stats}} de {{pokemonNameWithAffix}} ha subido!",
|
||||||
"statSharplyRose": "¡El {{stats}} de {{pokemonNameWithAffix}} ha subido mucho!",
|
"statSharplyRose": "¡El {{stats}} de {{pokemonNameWithAffix}} ha subido mucho!",
|
||||||
|
@ -63,6 +63,7 @@ export const battle: SimpleTranslationEntries = {
|
|||||||
"wildPokemonWithAffix": "{{pokemonName}} sauvage",
|
"wildPokemonWithAffix": "{{pokemonName}} sauvage",
|
||||||
"foePokemonWithAffix": "{{pokemonName}} ennemi",
|
"foePokemonWithAffix": "{{pokemonName}} ennemi",
|
||||||
"useMove": "{{pokemonNameWithAffix}} utilise\n{{moveName}} !",
|
"useMove": "{{pokemonNameWithAffix}} utilise\n{{moveName}} !",
|
||||||
|
"stealEatBerry": "{{pokemonName}} vole et mange\nla {{berryName}} de {{targetName}} !",
|
||||||
"drainMessage": "L’énergie de {{pokemonName}}\nest drainée !",
|
"drainMessage": "L’énergie de {{pokemonName}}\nest drainée !",
|
||||||
"regainHealth": "{{pokemonName}} récupère\ndes PV !",
|
"regainHealth": "{{pokemonName}} récupère\ndes PV !",
|
||||||
"fainted": "{{pokemonNameWithAffix}}\nest K.O. !",
|
"fainted": "{{pokemonNameWithAffix}}\nest K.O. !",
|
||||||
|
@ -60,6 +60,7 @@ export const battle: SimpleTranslationEntries = {
|
|||||||
"skipItemQuestion": "Sei sicuro di non voler prendere nessun oggetto?",
|
"skipItemQuestion": "Sei sicuro di non voler prendere nessun oggetto?",
|
||||||
"eggHatching": "Oh!",
|
"eggHatching": "Oh!",
|
||||||
"ivScannerUseQuestion": "Vuoi usare lo scanner di IV su {{pokemonName}}?",
|
"ivScannerUseQuestion": "Vuoi usare lo scanner di IV su {{pokemonName}}?",
|
||||||
|
"stealEatBerry": "{{pokemonName}} stole and ate\n{{targetName}}'s {{berryName}}!",
|
||||||
"wildPokemonWithAffix": "{{pokemonName}} selvatico",
|
"wildPokemonWithAffix": "{{pokemonName}} selvatico",
|
||||||
"foePokemonWithAffix": "{{pokemonName}} avversario",
|
"foePokemonWithAffix": "{{pokemonName}} avversario",
|
||||||
"useMove": "{{pokemonNameWithAffix}} usa {{moveName}}!",
|
"useMove": "{{pokemonNameWithAffix}} usa {{moveName}}!",
|
||||||
|
@ -64,6 +64,7 @@ export const battle: SimpleTranslationEntries = {
|
|||||||
"foePokemonWithAffix": "상대 {{pokemonName}}",
|
"foePokemonWithAffix": "상대 {{pokemonName}}",
|
||||||
"useMove": "{{pokemonNameWithAffix}}의 {{moveName}}!",
|
"useMove": "{{pokemonNameWithAffix}}의 {{moveName}}!",
|
||||||
"drainMessage": "{{pokemonName}}[[로]]부터\n체력을 흡수했다!",
|
"drainMessage": "{{pokemonName}}[[로]]부터\n체력을 흡수했다!",
|
||||||
|
"stealEatBerry": "{{pokemonName}}[[가]]\n{{targetName}}의 {{berryName}}[[를]] 빼앗아 먹었다!",
|
||||||
"regainHealth": "{{pokemonName}}[[는]]\n체력을 회복했다!",
|
"regainHealth": "{{pokemonName}}[[는]]\n체력을 회복했다!",
|
||||||
"fainted": "{{pokemonNameWithAffix}}[[는]] 쓰러졌다!",
|
"fainted": "{{pokemonNameWithAffix}}[[는]] 쓰러졌다!",
|
||||||
"statRose": "{{pokemonNameWithAffix}}의\n{{stats}}[[가]] 올라갔다!",
|
"statRose": "{{pokemonNameWithAffix}}의\n{{stats}}[[가]] 올라갔다!",
|
||||||
@ -131,5 +132,5 @@ export const battle: SimpleTranslationEntries = {
|
|||||||
"battlerTagsSaltCuredOnAdd": "{{pokemonNameWithAffix}}[[는]]\n소금에 절여졌다!",
|
"battlerTagsSaltCuredOnAdd": "{{pokemonNameWithAffix}}[[는]]\n소금에 절여졌다!",
|
||||||
"battlerTagsSaltCuredLapse": "{{pokemonNameWithAffix}}[[는]] 소금절이의\n데미지를 입고 있다.",
|
"battlerTagsSaltCuredLapse": "{{pokemonNameWithAffix}}[[는]] 소금절이의\n데미지를 입고 있다.",
|
||||||
"battlerTagsCursedOnAdd": "{{pokemonNameWithAffix}}[[는]]\n자신의 체력을 깎아서\n{{pokemonName}}에게 저주를 걸었다!",
|
"battlerTagsCursedOnAdd": "{{pokemonNameWithAffix}}[[는]]\n자신의 체력을 깎아서\n{{pokemonName}}에게 저주를 걸었다!",
|
||||||
"battlerTagsCursedLapse": "{{pokemonNameWithAffix}}[[는]]\n저주받고 있다!"
|
"battlerTagsCursedLapse": "{{pokemonNameWithAffix}}[[는]]\n저주받고 있다!",
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -65,6 +65,7 @@ export const battle: SimpleTranslationEntries = {
|
|||||||
"useMove": "{{pokemonNameWithAffix}} usou {{moveName}}!",
|
"useMove": "{{pokemonNameWithAffix}} usou {{moveName}}!",
|
||||||
"drainMessage": "{{pokemonName}} teve sua\nenergia drenada!",
|
"drainMessage": "{{pokemonName}} teve sua\nenergia drenada!",
|
||||||
"regainHealth": "{{pokemonName}} recuperou\npontos de saúde!",
|
"regainHealth": "{{pokemonName}} recuperou\npontos de saúde!",
|
||||||
|
"stealEatBerry": "{{pokemonName}} stole and ate\n{{targetName}}'s {{berryName}}!",
|
||||||
"fainted": "{{pokemonNameWithAffix}} desmaiou!",
|
"fainted": "{{pokemonNameWithAffix}} desmaiou!",
|
||||||
"statRose": "{{stats}} de {{pokemonNameWithAffix}} aumentou!",
|
"statRose": "{{stats}} de {{pokemonNameWithAffix}} aumentou!",
|
||||||
"statSharplyRose": "{{stats}} de {{pokemonNameWithAffix}} aumentou bruscamente!",
|
"statSharplyRose": "{{stats}} de {{pokemonNameWithAffix}} aumentou bruscamente!",
|
||||||
|
@ -59,6 +59,7 @@ export const battle: SimpleTranslationEntries = {
|
|||||||
"hpIsFull": "{{pokemonName}}的体力已满!",
|
"hpIsFull": "{{pokemonName}}的体力已满!",
|
||||||
"skipItemQuestion": "你确定要跳过拾取道具吗?",
|
"skipItemQuestion": "你确定要跳过拾取道具吗?",
|
||||||
"eggHatching": "咦?",
|
"eggHatching": "咦?",
|
||||||
|
"stealEatBerry": "{{pokemonName}} stole and ate\n{{targetName}}'s {{berryName}}!",
|
||||||
"ivScannerUseQuestion": "对{{pokemonName}}使用个体值扫描仪?",
|
"ivScannerUseQuestion": "对{{pokemonName}}使用个体值扫描仪?",
|
||||||
"wildPokemonWithAffix": "野生的{{pokemonName}}",
|
"wildPokemonWithAffix": "野生的{{pokemonName}}",
|
||||||
"foePokemonWithAffix": "对手 {{pokemonName}}",
|
"foePokemonWithAffix": "对手 {{pokemonName}}",
|
||||||
|
@ -51,6 +51,7 @@ export const battle: SimpleTranslationEntries = {
|
|||||||
"runAwayCannotEscape": "你無法逃脫!",
|
"runAwayCannotEscape": "你無法逃脫!",
|
||||||
"escapeVerbSwitch": "切換",
|
"escapeVerbSwitch": "切換",
|
||||||
"escapeVerbFlee": "逃跑",
|
"escapeVerbFlee": "逃跑",
|
||||||
|
"stealEatBerry": "{{pokemonName}} stole and ate\n{{targetName}}'s {{berryName}}!",
|
||||||
"notDisabled": "{{moveName}} 不再被禁用!",
|
"notDisabled": "{{moveName}} 不再被禁用!",
|
||||||
"turnEndHpRestore": "{{pokemonName}}'s HP was restored.",
|
"turnEndHpRestore": "{{pokemonName}}'s HP was restored.",
|
||||||
"hpIsFull": "{{pokemonName}}'s\nHP is full!",
|
"hpIsFull": "{{pokemonName}}'s\nHP is full!",
|
||||||
@ -128,5 +129,5 @@ export const battle: SimpleTranslationEntries = {
|
|||||||
"battlerTagsSaltCuredOnAdd": "{{pokemonNameWithAffix}} 陷入了鹽腌狀態!",
|
"battlerTagsSaltCuredOnAdd": "{{pokemonNameWithAffix}} 陷入了鹽腌狀態!",
|
||||||
"battlerTagsSaltCuredLapse": "{{pokemonNameWithAffix}} 受到了{{moveName}}的傷害!",
|
"battlerTagsSaltCuredLapse": "{{pokemonNameWithAffix}} 受到了{{moveName}}的傷害!",
|
||||||
"battlerTagsCursedOnAdd": "{{pokemonNameWithAffix}}削減了自己的體力,並詛咒了{{pokemonName}}!",
|
"battlerTagsCursedOnAdd": "{{pokemonNameWithAffix}}削減了自己的體力,並詛咒了{{pokemonName}}!",
|
||||||
"battlerTagsCursedLapse": "{{pokemonNameWithAffix}}正受到詛咒!"
|
"battlerTagsCursedLapse": "{{pokemonNameWithAffix}}正受到詛咒!",
|
||||||
} as const;
|
} as const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user