From 94da7838f81b2da2d852fd0e5ea870fc73af7b4b Mon Sep 17 00:00:00 2001 From: William Burleson <72857839+Admiral-Billy@users.noreply.github.com> Date: Wed, 8 May 2024 19:14:09 -0400 Subject: [PATCH 1/4] fix offline imports (#659) --- src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index ef277630d..191b8f55b 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -220,7 +220,7 @@ export function executeIf(condition: boolean, promiseFunc: () => Promise): } export const sessionIdKey = 'pokerogue_sessionId'; -export const isLocal = window.location.hostname === 'localhost'; +export const isLocal = window.location.hostname === 'localhost' || window.location.hostname === ''; export const serverUrl = isLocal ? 'http://localhost:8001' : ''; export const apiUrl = isLocal ? serverUrl : 'https://api.pokerogue.net'; export const fallbackApiUrl = isLocal ? serverUrl : 'api'; From aeab9d78ec2a713fe94861c4bf43bd9876557459 Mon Sep 17 00:00:00 2001 From: alpaca Date: Wed, 8 May 2024 20:25:16 -0400 Subject: [PATCH 2/4] Implements cursed body (#227) * implements cursed body * 30 percent chance to proc * check if max * removes unimplemented tag * bypasses faint * un-disable message specifies pokemon name * adds prefix to un-disable message * space issue --- src/data/ability.ts | 33 ++++++++++++++++++++++++++++++++- src/locales/de/battle.ts | 2 +- src/locales/en/battle.ts | 2 +- src/locales/es/battle.ts | 2 +- src/locales/fr/battle.ts | 2 +- src/locales/it/battle.ts | 2 +- src/phases.ts | 4 ++-- 7 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index cddb726d0..715c3f7d4 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -860,6 +860,36 @@ export class PostDefendAbilityGiveAbAttr extends PostDefendAbAttr { } } +export class PostDefendMoveDisableAbAttr extends PostDefendAbAttr { + private chance: integer; + private attacker: Pokemon; + private move: PokemonMove; + + constructor(chance: integer) { + super(); + + this.chance = chance; + } + + applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean { + if (!attacker.summonData.disabledMove) { + if (move.getMove().checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon) && (this.chance === -1 || pokemon.randSeedInt(100) < this.chance) && !attacker.isMax()) { + this.attacker = attacker; + this.move = move; + + attacker.summonData.disabledMove = move.moveId; + attacker.summonData.disabledTurns = 4; + return true; + } + } + return false; + } + + getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { + return getPokemonMessage(this.attacker, `'s ${this.move.getName()}\nwas disabled!`); + } +} + export class PostStatChangeStatChangeAbAttr extends PostStatChangeAbAttr { private condition: PokemonStatChangeCondition; private statsToChange: BattleStat[]; @@ -3076,7 +3106,8 @@ export function initAbilities() { .attr(BattleStatMultiplierAbAttr, BattleStat.SPATK, 0.5) .condition((pokemon) => pokemon.getHpRatio() <= 0.5), new Ability(Abilities.CURSED_BODY, 5) - .unimplemented(), + .attr(PostDefendMoveDisableAbAttr, 30) + .bypassFaint(), new Ability(Abilities.HEALER, 5) .unimplemented(), new Ability(Abilities.FRIEND_GUARD, 5) diff --git a/src/locales/de/battle.ts b/src/locales/de/battle.ts index b48aa1129..656ebb851 100644 --- a/src/locales/de/battle.ts +++ b/src/locales/de/battle.ts @@ -46,7 +46,7 @@ export const battle: SimpleTranslationEntries = { "runAwayCannotEscape": 'You can\'t escape!', "escapeVerbSwitch": "auswechseln", "escapeVerbFlee": "flucht", - "notDisabled": "{{moveName}} ist\nnicht mehr deaktiviert!", + "notDisabled": "{{pokemonName}}'s {{moveName}} ist\nnicht mehr deaktiviert!", "skipItemQuestion": "Are you sure you want to skip taking an item?", "eggHatching": "Oh?", "ivScannerUseQuestion": "Use IV Scanner on {{pokemonName}}?" diff --git a/src/locales/en/battle.ts b/src/locales/en/battle.ts index e307a3a52..7c948e6f0 100644 --- a/src/locales/en/battle.ts +++ b/src/locales/en/battle.ts @@ -46,7 +46,7 @@ export const battle: SimpleTranslationEntries = { "runAwayCannotEscape": 'You can\'t escape!', "escapeVerbSwitch": "switching", "escapeVerbFlee": "fleeing", - "notDisabled": "{{moveName}} is disabled\nno more!", + "notDisabled": "{{pokemonName}}'s {{moveName}} is disabled\nno more!", "skipItemQuestion": "Are you sure you want to skip taking an item?", "eggHatching": "Oh?", "ivScannerUseQuestion": "Use IV Scanner on {{pokemonName}}?" diff --git a/src/locales/es/battle.ts b/src/locales/es/battle.ts index f4bf22bb9..6fdcf4fbc 100644 --- a/src/locales/es/battle.ts +++ b/src/locales/es/battle.ts @@ -46,7 +46,7 @@ export const battle: SimpleTranslationEntries = { "runAwayCannotEscape": "¡No has podido escapar!", "escapeVerbSwitch": "cambiar", "escapeVerbFlee": "huir", - "notDisabled": "¡El movimiento {{moveName}}\nya no está anulado!", + "notDisabled": "¡El movimiento {{moveName}} de {{pokemonName}}\nya no está anulado!", "skipItemQuestion": "¿Estás seguro de que no quieres coger un objeto?", "eggHatching": "¿Y esto?", "ivScannerUseQuestion": "¿Quieres usar el Escáner de IVs en {{pokemonName}}?" diff --git a/src/locales/fr/battle.ts b/src/locales/fr/battle.ts index 56ab69215..1d6c284a5 100644 --- a/src/locales/fr/battle.ts +++ b/src/locales/fr/battle.ts @@ -46,7 +46,7 @@ export const battle: SimpleTranslationEntries = { "runAwayCannotEscape": "Fuite impossible !", "escapeVerbSwitch": "le changement", "escapeVerbFlee": "la fuite", - "notDisabled": "{{moveName}} n’est plus sous entrave !", + "notDisabled": "{{pokemonName}}'s {{moveName}} n’est plus sous entrave !", "skipItemQuestion": "Êtes-vous sûr·e de ne pas vouloir prendre d’objet ?", "eggHatching": "Oh ?", "ivScannerUseQuestion": "Utiliser le Scanner d’IV sur {{pokemonName}} ?" diff --git a/src/locales/it/battle.ts b/src/locales/it/battle.ts index 247e6e38e..a3cffaa60 100644 --- a/src/locales/it/battle.ts +++ b/src/locales/it/battle.ts @@ -46,7 +46,7 @@ export const battle: SimpleTranslationEntries = { "runAwayCannotEscape": 'Non puoi fuggire!', "escapeVerbSwitch": "cambiando", "escapeVerbFlee": "fuggendo", - "notDisabled": "{{moveName}} non è più\ndisabilitata!", + "notDisabled": "{{pokemonName}}'s {{moveName}} non è più\ndisabilitata!", "skipItemQuestion": "Sei sicuro di non voler prendere nessun oggetto?", "eggHatching": "Oh?", "ivScannerUseQuestion": "Vuoi usare lo scanner di IV su {{pokemonName}}?" diff --git a/src/phases.ts b/src/phases.ts index 9595ab9c3..25b0c3b75 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -23,7 +23,7 @@ import { FusePokemonModifierType, ModifierPoolType, ModifierType, ModifierTypeFu import SoundFade from "phaser3-rex-plugins/plugins/soundfade"; import { BattlerTagLapseType, EncoreTag, HideSpriteTag as HiddenTag, ProtectedTag, TrappedTag } from "./data/battler-tags"; import { BattlerTagType } from "./data/enums/battler-tag-type"; -import { getPokemonMessage } from "./messages"; +import { getPokemonMessage, getPokemonPrefix } from "./messages"; import { Starter } from "./ui/starter-select-ui-handler"; import { Gender } from "./data/gender"; import { Weather, WeatherType, getRandomWeatherType, getTerrainBlockMessage, getWeatherDamageMessage, getWeatherLapseMessage } from "./data/weather"; @@ -2046,7 +2046,7 @@ export class TurnEndPhase extends FieldPhase { pokemon.lapseTags(BattlerTagLapseType.TURN_END); if (pokemon.summonData.disabledMove && !--pokemon.summonData.disabledTurns) { - this.scene.pushPhase(new MessagePhase(this.scene, i18next.t('battle:notDisabled', { moveName: allMoves[pokemon.summonData.disabledMove].name }))); + this.scene.pushPhase(new MessagePhase(this.scene, i18next.t('battle:notDisabled', { pokemonName: `${getPokemonPrefix(pokemon)}${pokemon.name}`, moveName: allMoves[pokemon.summonData.disabledMove].name }))); pokemon.summonData.disabledMove = Moves.NONE; } From 71e9d0c3854d9ba05f945c99d6d972335130e291 Mon Sep 17 00:00:00 2001 From: Lugiad Date: Thu, 9 May 2024 03:00:38 +0200 Subject: [PATCH 3/4] Fix French battle.ts (#663) Fix after global edit to "notDisabled" --- src/locales/fr/battle.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locales/fr/battle.ts b/src/locales/fr/battle.ts index 1d6c284a5..e34902b8c 100644 --- a/src/locales/fr/battle.ts +++ b/src/locales/fr/battle.ts @@ -46,7 +46,7 @@ export const battle: SimpleTranslationEntries = { "runAwayCannotEscape": "Fuite impossible !", "escapeVerbSwitch": "le changement", "escapeVerbFlee": "la fuite", - "notDisabled": "{{pokemonName}}'s {{moveName}} n’est plus sous entrave !", + "notDisabled": "La capacité {{moveName}}\nde {{pokemonName}} n’est plus sous entrave !", "skipItemQuestion": "Êtes-vous sûr·e de ne pas vouloir prendre d’objet ?", "eggHatching": "Oh ?", "ivScannerUseQuestion": "Utiliser le Scanner d’IV sur {{pokemonName}} ?" From 76ac86d2ae2336e001a321ba54331442137ad3ab Mon Sep 17 00:00:00 2001 From: alpaca Date: Wed, 8 May 2024 21:21:55 -0400 Subject: [PATCH 4/4] Implements healer (#259) * Implements healer * adds an ally check to the condition * done testing, changes chance back to 30% * adds comment header for PostTurnResetStatusAbAttr * adds override to resetStatus to not allow revive * dont revive * override revert --- src/data/ability.ts | 27 ++++++++++++++++++++++----- src/field/pokemon.ts | 9 ++++++++- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 715c3f7d4..04cd18ada 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -2055,13 +2055,30 @@ export class PostTurnAbAttr extends AbAttr { } } +/** + * After the turn ends, resets the status of either the ability holder or their ally + * @param {boolean} allyTarget Whether to target ally, defaults to false (self-target) + */ export class PostTurnResetStatusAbAttr extends PostTurnAbAttr { + private allyTarget: boolean; + private target: Pokemon; + + constructor(allyTarget: boolean = false) { + super(true); + this.allyTarget = allyTarget; + } + applyPostTurn(pokemon: Pokemon, passive: boolean, args: any[]): boolean { - if (pokemon.status) { + if (this.allyTarget) { + this.target = pokemon.getAlly(); + } else { + this.target = pokemon; + } + if (this.target?.status) { - pokemon.scene.queueMessage(getPokemonMessage(pokemon, getStatusEffectHealText(pokemon.status?.effect))); - pokemon.resetStatus(); - pokemon.updateInfo(); + this.target.scene.queueMessage(getPokemonMessage(this.target, getStatusEffectHealText(this.target.status?.effect))); + this.target.resetStatus(false); + this.target.updateInfo(); return true; } @@ -3109,7 +3126,7 @@ export function initAbilities() { .attr(PostDefendMoveDisableAbAttr, 30) .bypassFaint(), new Ability(Abilities.HEALER, 5) - .unimplemented(), + .conditionalAttr(pokemon => pokemon.getAlly() && Utils.randSeedInt(10) < 3, PostTurnResetStatusAbAttr, true), new Ability(Abilities.FRIEND_GUARD, 5) .ignorable() .unimplemented(), diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index f12fc14b1..1ba88e05a 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1959,8 +1959,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return true; } - resetStatus(): void { + /** + * Resets the status of a pokemon + * @param revive whether revive should be cured, defaults to true + */ + resetStatus(revive: boolean = true): void { const lastStatus = this.status?.effect; + if (!revive && lastStatus === StatusEffect.FAINT) { + return; + } this.status = undefined; if (lastStatus === StatusEffect.SLEEP) { this.setFrameRate(12);