[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:
schmidtc1 2024-07-02 10:28:38 -04:00 committed by GitHub
parent 0bc4f26b9d
commit df18dd885d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 57 additions and 53 deletions

View File

@ -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 {
protected chosenBerry: BerryModifier;
@ -1930,30 +1930,17 @@ export class EatBerryAttr extends MoveEffectAttr {
return false;
}
if (this.chosenBerry === undefined) { // if no berry has been provided, pick a random berry from their inventory
const heldBerries = this.getTargetHeldBerries(target);
if (heldBerries.length <= 0) {
return false;
}
this.chosenBerry = heldBerries[user.randSeedInt(heldBerries.length)];
}
getBerryEffectFunc(this.chosenBerry.berryType)(target); // target eats the berry
const preserve = new Utils.BooleanHolder(false);
target.scene.applyModifiers(PreserveBerryModifier, target.isPlayer(), target, preserve);
if (!preserve.value) { // remove the eaten berry if not preserved
if (!--this.chosenBerry.stackCount) {
target.scene.removeModifier(this.chosenBerry, !target.isPlayer());
target.scene.applyModifiers(PreserveBerryModifier, target.isPlayer(), target, preserve); // check for berry pouch preservation
if (!preserve.value) {
this.reduceBerryModifier(target);
}
target.scene.updateModifiers(target.isPlayer());
}
this.chosenBerry = undefined;
applyAbAttrs(HealFromBerryUseAbAttr, target, new Utils.BooleanHolder(false));
this.eatBerry(target);
return true;
}
@ -1962,7 +1949,21 @@ export class EatBerryAttr extends MoveEffectAttr {
&& (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.
* Used for Pluck & Bug Bite.
@ -1980,29 +1981,23 @@ export class StealEatBerryAttr extends EatBerryAttr {
* @returns {boolean} true if the function succeeds
*/
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
const cancelled = new Utils.BooleanHolder(false);
applyAbAttrs(BlockItemTheftAbAttr, target, cancelled); // check for abilities that block item theft
if (cancelled.value === true) {
return false;
}
const heldBerries = this.getTargetHeldBerries(target).filter(i => i.getTransferrable(false));
if (heldBerries.length) { // if the target has berries, pick a random berry and steal it
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 (heldBerries.length <= 0) {
return false;
}
// if the target has berries, pick a random berry and steal it
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;
}
}
/**

View File

@ -65,6 +65,7 @@ export const battle: SimpleTranslationEntries = {
"useMove": "{{pokemonNameWithAffix}} setzt {{moveName}} ein!",
"drainMessage": "{{pokemonName}} wurde Energie abgesaugt",
"regainHealth": "KP von {{pokemonName}} wurden wieder aufgefrischt!",
"stealEatBerry": "{{pokemonName}} stole and ate\n{{targetName}}'s {{berryName}}!",
"fainted": "{{pokemonNameWithAffix}} wurde besiegt!",
"statRose": "{{stats}} von {{pokemonNameWithAffix}} steigt!",
"statSharplyRose": "{{stats}} von {{pokemonNameWithAffix}} steigt stark!",

View File

@ -65,6 +65,7 @@ export const battle: SimpleTranslationEntries = {
"useMove": "{{pokemonNameWithAffix}} used {{moveName}}!",
"drainMessage": "{{pokemonName}} had its\nenergy drained!",
"regainHealth": "{{pokemonName}} regained\nhealth!",
"stealEatBerry": "{{pokemonName}} stole and ate\n{{targetName}}'s {{berryName}}!",
"fainted": "{{pokemonNameWithAffix}} fainted!",
"statRose": "{{pokemonNameWithAffix}}'s {{stats}} rose!",
"statSharplyRose": "{{pokemonNameWithAffix}}'s {{stats}} sharply rose!",

View File

@ -65,6 +65,7 @@ export const battle: SimpleTranslationEntries = {
"useMove": "¡{{pokemonNameWithAffix}} usó {{moveName}}!",
"drainMessage": "¡{{pokemonName}} tuvo su\nenergía absorbida!",
"regainHealth": "¡{{pokemonName}} recuperó\nPS!",
"stealEatBerry": "¡{{pokemonName}} robó la {{berryName}}\nde {{targetName}} y se la comió!",
"fainted": "¡{{pokemonNameWithAffix}} se debilitó!",
"statRose": "¡El {{stats}} de {{pokemonNameWithAffix}} ha subido!",
"statSharplyRose": "¡El {{stats}} de {{pokemonNameWithAffix}} ha subido mucho!",

View File

@ -63,6 +63,7 @@ export const battle: SimpleTranslationEntries = {
"wildPokemonWithAffix": "{{pokemonName}} sauvage",
"foePokemonWithAffix": "{{pokemonName}} ennemi",
"useMove": "{{pokemonNameWithAffix}} utilise\n{{moveName}} !",
"stealEatBerry": "{{pokemonName}} vole et mange\nla {{berryName}} de {{targetName}} !",
"drainMessage": "Lénergie de {{pokemonName}}\nest drainée !",
"regainHealth": "{{pokemonName}} récupère\ndes PV !",
"fainted": "{{pokemonNameWithAffix}}\nest K.O. !",

View File

@ -60,6 +60,7 @@ export const battle: SimpleTranslationEntries = {
"skipItemQuestion": "Sei sicuro di non voler prendere nessun oggetto?",
"eggHatching": "Oh!",
"ivScannerUseQuestion": "Vuoi usare lo scanner di IV su {{pokemonName}}?",
"stealEatBerry": "{{pokemonName}} stole and ate\n{{targetName}}'s {{berryName}}!",
"wildPokemonWithAffix": "{{pokemonName}} selvatico",
"foePokemonWithAffix": "{{pokemonName}} avversario",
"useMove": "{{pokemonNameWithAffix}} usa {{moveName}}!",

View File

@ -64,6 +64,7 @@ export const battle: SimpleTranslationEntries = {
"foePokemonWithAffix": "상대 {{pokemonName}}",
"useMove": "{{pokemonNameWithAffix}}의 {{moveName}}!",
"drainMessage": "{{pokemonName}}[[로]]부터\n체력을 흡수했다!",
"stealEatBerry": "{{pokemonName}}[[가]]\n{{targetName}}의 {{berryName}}[[를]] 빼앗아 먹었다!",
"regainHealth": "{{pokemonName}}[[는]]\n체력을 회복했다!",
"fainted": "{{pokemonNameWithAffix}}[[는]] 쓰러졌다!",
"statRose": "{{pokemonNameWithAffix}}의\n{{stats}}[[가]] 올라갔다!",
@ -131,5 +132,5 @@ export const battle: SimpleTranslationEntries = {
"battlerTagsSaltCuredOnAdd": "{{pokemonNameWithAffix}}[[는]]\n소금에 절여졌다!",
"battlerTagsSaltCuredLapse": "{{pokemonNameWithAffix}}[[는]] 소금절이의\n데미지를 입고 있다.",
"battlerTagsCursedOnAdd": "{{pokemonNameWithAffix}}[[는]]\n자신의 체력을 깎아서\n{{pokemonName}}에게 저주를 걸었다!",
"battlerTagsCursedLapse": "{{pokemonNameWithAffix}}[[는]]\n저주받고 있다!"
"battlerTagsCursedLapse": "{{pokemonNameWithAffix}}[[는]]\n저주받고 있다!",
} as const;

View File

@ -65,6 +65,7 @@ export const battle: SimpleTranslationEntries = {
"useMove": "{{pokemonNameWithAffix}} usou {{moveName}}!",
"drainMessage": "{{pokemonName}} teve sua\nenergia drenada!",
"regainHealth": "{{pokemonName}} recuperou\npontos de saúde!",
"stealEatBerry": "{{pokemonName}} stole and ate\n{{targetName}}'s {{berryName}}!",
"fainted": "{{pokemonNameWithAffix}} desmaiou!",
"statRose": "{{stats}} de {{pokemonNameWithAffix}} aumentou!",
"statSharplyRose": "{{stats}} de {{pokemonNameWithAffix}} aumentou bruscamente!",

View File

@ -59,6 +59,7 @@ export const battle: SimpleTranslationEntries = {
"hpIsFull": "{{pokemonName}}的体力已满!",
"skipItemQuestion": "你确定要跳过拾取道具吗?",
"eggHatching": "咦?",
"stealEatBerry": "{{pokemonName}} stole and ate\n{{targetName}}'s {{berryName}}!",
"ivScannerUseQuestion": "对{{pokemonName}}使用个体值扫描仪?",
"wildPokemonWithAffix": "野生的{{pokemonName}}",
"foePokemonWithAffix": "对手 {{pokemonName}}",

View File

@ -51,6 +51,7 @@ export const battle: SimpleTranslationEntries = {
"runAwayCannotEscape": "你無法逃脫!",
"escapeVerbSwitch": "切換",
"escapeVerbFlee": "逃跑",
"stealEatBerry": "{{pokemonName}} stole and ate\n{{targetName}}'s {{berryName}}!",
"notDisabled": "{{moveName}} 不再被禁用!",
"turnEndHpRestore": "{{pokemonName}}'s HP was restored.",
"hpIsFull": "{{pokemonName}}'s\nHP is full!",
@ -128,5 +129,5 @@ export const battle: SimpleTranslationEntries = {
"battlerTagsSaltCuredOnAdd": "{{pokemonNameWithAffix}} 陷入了鹽腌狀態!",
"battlerTagsSaltCuredLapse": "{{pokemonNameWithAffix}} 受到了{{moveName}}的傷害!",
"battlerTagsCursedOnAdd": "{{pokemonNameWithAffix}}削減了自己的體力,並詛咒了{{pokemonName}}",
"battlerTagsCursedLapse": "{{pokemonNameWithAffix}}正受到詛咒!"
"battlerTagsCursedLapse": "{{pokemonNameWithAffix}}正受到詛咒!",
} as const;