Implements bad dreams (#633)

* test commit

* de modified readme

* first implementation, needs testing with healer

* fixed beahviour if 2+ opponents are on field, also added message

* further fixed

* reset of overrides.ts before merge to main

* fixed grammar

Co-authored-by: Jonas Pinson <jonas.pinson@gmail.com>

* Implemented changes suggested by @bennybroseph and @TempsRay

* Added more docs to the class

* removed old comments

* fixed ability name in comments

* added translation and made message localized

* fixed ability name

* added missing bracket

---------

Co-authored-by: Jonas Pinson <jonas.pinson@gmail.com>
This commit is contained in:
Sbug98 2024-05-21 09:26:01 +02:00 committed by GitHub
parent 6016ecfb46
commit 42e2be22bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 36 additions and 2 deletions

View File

@ -2282,6 +2282,34 @@ export class PostTurnFormChangeAbAttr extends PostTurnAbAttr {
}
}
/**
* Attribute used for abilities (Bad Dreams) that damages the opponents for being asleep
*/
export class PostTurnHurtIfSleepingAbAttr extends PostTurnAbAttr {
/**
* Deals damage to all sleeping opponents equal to 1/8 of their max hp (min 1)
* @param {Pokemon} pokemon Pokemon that has this ability
* @param {boolean} passive N/A
* @param {any[]} args N/A
* @returns {boolean} true if any opponents are sleeping
*/
applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean | Promise<boolean> {
let hadEffect: boolean = false;
for(let opp of pokemon.getOpponents()) {
if(opp.status !== undefined && opp.status.effect === StatusEffect.SLEEP) {
opp.damageAndUpdate(Math.floor(Math.max(1, opp.getMaxHp() / 8)), HitResult.OTHER);
pokemon.scene.queueMessage(i18next.t('abilityTriggers:badDreams', {pokemonName: `${getPokemonPrefix(opp)}${opp.name}`}));
hadEffect = true;
}
}
return hadEffect;
}
}
/**
* Grabs the last failed Pokeball used
* @extends PostTurnAbAttr
@ -3327,7 +3355,7 @@ export function initAbilities() {
.ignorable()
.partial(),
new Ability(Abilities.BAD_DREAMS, 4)
.unimplemented(),
.attr(PostTurnHurtIfSleepingAbAttr),
new Ability(Abilities.PICKPOCKET, 5)
.attr(PostDefendStealHeldItemAbAttr, (target, user, move) => move.hasFlag(MoveFlags.MAKES_CONTACT)),
new Ability(Abilities.SHEER_FORCE, 5)

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!`,
'badDreams': `{{pokemonName}} wird gequält!`,
} 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!`,
'badDreams': `{{pokemonName}} is tormented!`,
} 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!`,
} as const;
'badDreams': `{{pokemonName}} Está atormentado!`
} 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 !`,
'badDreams': `{{pokemonName}} est tourmenté!`
} 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!`,
'badDreams': `{{pokemonName}} è tormentato!`,
} as const;

View File

@ -2,4 +2,5 @@ import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const abilityTriggers: SimpleTranslationEntries = {
'blockRecoilDamage' : `{{pokemonName}} 的 {{abilityName}}\n抵消了反作用力`,
'badDreams': `{{pokemonName}} 被折磨着!`
} as const;