From ad5efdf4f9bd41a55bfb8b4a87bd495a0b949f20 Mon Sep 17 00:00:00 2001 From: Xavion3 Date: Tue, 30 Apr 2024 20:47:53 +1000 Subject: [PATCH 1/6] Refactor overrides --- src/battle-scene.ts | 17 +---------------- src/field/arena.ts | 3 +-- src/field/pokemon.ts | 3 ++- src/game-mode.ts | 3 ++- src/overrides.ts | 23 +++++++++++++++++++++++ src/phases.ts | 3 ++- 6 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 src/overrides.ts diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 6b54505b6a1..4253a1805cb 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -60,25 +60,10 @@ import { SceneBase } from './scene-base'; import CandyBar from './ui/candy-bar'; import { Variant, variantData } from './data/variant'; import { Localizable } from './plugins/i18n'; +import { STARTING_WAVE_OVERRIDE, OPP_SPECIES_OVERRIDE, SEED_OVERRIDE, STARTING_BIOME_OVERRIDE } from './overrides'; export const bypassLogin = import.meta.env.VITE_BYPASS_LOGIN === "1"; -export const SEED_OVERRIDE = ''; -export const STARTER_SPECIES_OVERRIDE = 0; -export const STARTER_FORM_OVERRIDE = 0; -export const STARTING_LEVEL_OVERRIDE = 0; -export const STARTING_WAVE_OVERRIDE = 0; -export const STARTING_BIOME_OVERRIDE = Biome.TOWN; -export const STARTING_MONEY_OVERRIDE = 0; - -export const ABILITY_OVERRIDE = Abilities.NONE; -export const MOVE_OVERRIDE = Moves.NONE; -export const OPP_SPECIES_OVERRIDE = 0; -export const OPP_ABILITY_OVERRIDE = Abilities.NONE; -export const OPP_MOVE_OVERRIDE = Moves.NONE; -export const OPP_SHINY_OVERRIDE = false; -export const OPP_VARIANT_OVERRIDE = 0; - const DEBUG_RNG = false; export const startingWave = STARTING_WAVE_OVERRIDE || 1; diff --git a/src/field/arena.ts b/src/field/arena.ts index 910d998d68e..5b14560d407 100644 --- a/src/field/arena.ts +++ b/src/field/arena.ts @@ -18,8 +18,7 @@ import { TimeOfDay } from "../data/enums/time-of-day"; import { Terrain, TerrainType } from "../data/terrain"; import { PostTerrainChangeAbAttr, PostWeatherChangeAbAttr, applyPostTerrainChangeAbAttrs, applyPostWeatherChangeAbAttrs } from "../data/ability"; import Pokemon from "./pokemon"; - -const WEATHER_OVERRIDE = WeatherType.NONE; +import { WEATHER_OVERRIDE } from '../overrides'; export class Arena { public scene: BattleScene; diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 4e20bad407b..44573542fe8 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1,5 +1,5 @@ import Phaser from 'phaser'; -import BattleScene, { ABILITY_OVERRIDE, AnySound, MOVE_OVERRIDE, OPP_ABILITY_OVERRIDE, OPP_MOVE_OVERRIDE, OPP_SHINY_OVERRIDE, OPP_VARIANT_OVERRIDE } from '../battle-scene'; +import BattleScene, { AnySound } from '../battle-scene'; import { Variant, VariantSet, variantColorCache } from '#app/data/variant'; import { variantData } from '#app/data/variant'; import BattleInfo, { PlayerBattleInfo, EnemyBattleInfo } from '../ui/battle-info'; @@ -43,6 +43,7 @@ import { Nature, getNatureStatMultiplier } from '../data/nature'; import { SpeciesFormChange, SpeciesFormChangeActiveTrigger, SpeciesFormChangeMoveLearnedTrigger, SpeciesFormChangePostMoveTrigger, SpeciesFormChangeStatusEffectTrigger } from '../data/pokemon-forms'; import { TerrainType } from '../data/terrain'; import { TrainerSlot } from '../data/trainer-config'; +import { ABILITY_OVERRIDE, MOVE_OVERRIDE, OPP_ABILITY_OVERRIDE, OPP_MOVE_OVERRIDE, OPP_SHINY_OVERRIDE, OPP_VARIANT_OVERRIDE } from '../overrides'; export enum FieldPosition { CENTER, diff --git a/src/game-mode.ts b/src/game-mode.ts index 0ac3f0503f1..76c97b4c9ac 100644 --- a/src/game-mode.ts +++ b/src/game-mode.ts @@ -1,10 +1,11 @@ import { fixedBattles } from "./battle"; -import BattleScene, { STARTING_BIOME_OVERRIDE, STARTING_LEVEL_OVERRIDE, STARTING_MONEY_OVERRIDE } from "./battle-scene"; +import BattleScene from "./battle-scene"; import { Biome } from "./data/enums/biome"; import { Species } from "./data/enums/species"; import PokemonSpecies, { allSpecies } from "./data/pokemon-species"; import { Arena } from "./field/arena"; import * as Utils from "./utils"; +import { STARTING_BIOME_OVERRIDE, STARTING_LEVEL_OVERRIDE, STARTING_MONEY_OVERRIDE } from './overrides'; export enum GameModes { CLASSIC, diff --git a/src/overrides.ts b/src/overrides.ts new file mode 100644 index 00000000000..732b1a5a45b --- /dev/null +++ b/src/overrides.ts @@ -0,0 +1,23 @@ +import { Species } from './data/enums/species'; +import { Abilities } from "./data/enums/abilities"; +import { Biome } from "./data/enums/biome"; +import { Moves } from "./data/enums/moves"; +import { WeatherType } from "./data/weather"; + +export const SEED_OVERRIDE = ''; +export const STARTER_SPECIES_OVERRIDE = 0; +export const STARTER_FORM_OVERRIDE = 0; +export const STARTING_LEVEL_OVERRIDE = 0; +export const STARTING_WAVE_OVERRIDE = 0; +export const STARTING_BIOME_OVERRIDE = Biome.TOWN; +export const STARTING_MONEY_OVERRIDE = 0; +export const WEATHER_OVERRIDE = WeatherType.NONE; + +export const ABILITY_OVERRIDE = Abilities.NONE; +export const MOVE_OVERRIDE = Moves.NONE; +export const OPP_SPECIES_OVERRIDE = 0; +export const OPP_ABILITY_OVERRIDE = Abilities.NONE; +export const OPP_MOVE_OVERRIDE = Moves.NONE; + +export const OPP_SHINY_OVERRIDE = false; +export const OPP_VARIANT_OVERRIDE = 0; diff --git a/src/phases.ts b/src/phases.ts index 1393355e3f5..8934104ed80 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -1,4 +1,4 @@ -import BattleScene, { STARTER_FORM_OVERRIDE, STARTER_SPECIES_OVERRIDE, bypassLogin, startingWave } from "./battle-scene"; +import BattleScene, { bypassLogin, startingWave } from "./battle-scene"; import { default as Pokemon, PlayerPokemon, EnemyPokemon, PokemonMove, MoveResult, DamageResult, FieldPosition, HitResult, TurnMove } from "./field/pokemon"; import * as Utils from './utils'; import { Moves } from "./data/enums/moves"; @@ -57,6 +57,7 @@ import { fetchDailyRunSeed, getDailyRunStarters } from "./data/daily-run"; import { GameModes, gameModes } from "./game-mode"; import { getPokemonSpecies, speciesStarters } from "./data/pokemon-species"; import i18next from './plugins/i18n'; +import { STARTER_FORM_OVERRIDE, STARTER_SPECIES_OVERRIDE } from './overrides'; export class LoginPhase extends Phase { private showText: boolean; From 2402b8e6a07eb3c4b1886b16e595c0f9326307d6 Mon Sep 17 00:00:00 2001 From: Xavion3 Date: Tue, 30 Apr 2024 20:49:06 +1000 Subject: [PATCH 2/6] Add overrides to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4cf3196a72b..55f9203a81d 100644 --- a/.gitignore +++ b/.gitignore @@ -33,5 +33,6 @@ public/images/pokemon/icons/input/output/* public/images/character/*/ src/data/battle-anim-raw-data*.ts src/data/battle-anim-data.ts +src/overrides.ts coverage \ No newline at end of file From c7bd99b34584f0ad4149f4511b30321da23c9bbc Mon Sep 17 00:00:00 2001 From: Raphael van der Woude <47354694+RaphaelWoude@users.noreply.github.com> Date: Tue, 30 Apr 2024 16:53:00 +0200 Subject: [PATCH 3/6] Added missing menu translations (#355) * Added missing menu translations * Added missing translations to other languages --------- Co-authored-by: Raphael van der Woude --- src/locales/de/menu.ts | 5 +++++ src/locales/en/menu.ts | 5 +++++ src/locales/es/menu.ts | 7 ++++++- src/locales/fr/menu.ts | 5 +++++ src/locales/it/menu.ts | 7 ++++++- src/ui/daily-run-scoreboard.ts | 9 +++++---- src/ui/title-ui-handler.ts | 5 +++-- 7 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/locales/de/menu.ts b/src/locales/de/menu.ts index d70cd83c50d..4876fa3432a 100644 --- a/src/locales/de/menu.ts +++ b/src/locales/de/menu.ts @@ -59,4 +59,9 @@ export const menu: SimpleTranslationEntries = { "escapeVerbSwitch": "auswechseln", "escapeVerbFlee": "flucht", "notDisabled": "{{moveName}} ist\nnicht mehr deaktiviert!", + "rankings": "Rankings", + "dailyRankings": "Daily Rankings", + "noRankings": "No Rankings", + "loading": "Loading…", + "playersOnline": "Players Online" } as const; \ No newline at end of file diff --git a/src/locales/en/menu.ts b/src/locales/en/menu.ts index bce59c02c11..1d840a3eb03 100644 --- a/src/locales/en/menu.ts +++ b/src/locales/en/menu.ts @@ -78,4 +78,9 @@ export const menu: SimpleTranslationEntries = { "skipItemQuestion": "Are you sure you want to skip taking an item?", "eggHatching": "Oh?", "ivScannerUseQuestion": "Use IV Scanner on {{pokemonName}}?", + "rankings": "Rankings", + "dailyRankings": "Daily Rankings", + "noRankings": "No Rankings", + "loading": "Loading…", + "playersOnline": "Players Online" } as const; \ No newline at end of file diff --git a/src/locales/es/menu.ts b/src/locales/es/menu.ts index dc1c50b3821..e72710cee37 100644 --- a/src/locales/es/menu.ts +++ b/src/locales/es/menu.ts @@ -61,5 +61,10 @@ export const menu: SimpleTranslationEntries = { "notDisabled": "¡El movimiento {{moveName}}\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}}?" + "ivScannerUseQuestion": "¿Quieres usar el Escáner de IVs en {{pokemonName}}?", + "rankings": "Rankings", + "dailyRankings": "Daily Rankings", + "noRankings": "No Rankings", + "loading": "Loading…", + "playersOnline": "Players Online" } as const; \ No newline at end of file diff --git a/src/locales/fr/menu.ts b/src/locales/fr/menu.ts index 015132bc6c5..911445bcdca 100644 --- a/src/locales/fr/menu.ts +++ b/src/locales/fr/menu.ts @@ -73,4 +73,9 @@ export const menu: SimpleTranslationEntries = { "skipItemQuestion": "Êtes-vous sûr·e de ne pas vouloir prendre d’objet ?", "eggHatching": "Oh ?", "ivScannerUseQuestion": "Utiliser le Scanner d’IV sur {{pokemonName}} ?", + "rankings": "Rankings", + "dailyRankings": "Daily Rankings", + "noRankings": "No Rankings", + "loading": "Loading…", + "playersOnline": "Players Online" } as const; diff --git a/src/locales/it/menu.ts b/src/locales/it/menu.ts index 872315d77c0..b9e288c26ce 100644 --- a/src/locales/it/menu.ts +++ b/src/locales/it/menu.ts @@ -6,5 +6,10 @@ export const menu: SimpleTranslationEntries = { "newGame": "Nuova Partita", "loadGame": "Carica Partita", "dailyRun": "Corsa Giornaliera (Beta)", - "selectGameMode": "Seleziona una modalità di gioco." + "selectGameMode": "Seleziona una modalità di gioco.", + "rankings": "Rankings", + "dailyRankings": "Daily Rankings", + "noRankings": "No Rankings", + "loading": "Loading…", + "playersOnline": "Players Online" } as const; \ No newline at end of file diff --git a/src/ui/daily-run-scoreboard.ts b/src/ui/daily-run-scoreboard.ts index 90fef5ba5e4..1379ec6a8ef 100644 --- a/src/ui/daily-run-scoreboard.ts +++ b/src/ui/daily-run-scoreboard.ts @@ -2,6 +2,7 @@ import BattleScene from "../battle-scene"; import { TextStyle, addTextObject } from "./text"; import { WindowVariant, addWindow } from "./ui-theme"; import * as Utils from "../utils"; +import i18next from "i18next"; interface RankingEntry { rank: integer, @@ -39,7 +40,7 @@ export class DailyRunScoreboard extends Phaser.GameObjects.Container { const titleWindow = addWindow(this.scene, 0, 0, 114, 18, false, false, null, null, WindowVariant.THIN); this.add(titleWindow); - this.titleLabel = addTextObject(this.scene, titleWindow.displayWidth / 2, titleWindow.displayHeight / 2, 'Daily Rankings', TextStyle.WINDOW, { fontSize: '64px' }); + this.titleLabel = addTextObject(this.scene, titleWindow.displayWidth / 2, titleWindow.displayHeight / 2, i18next.t('menu:dailyRankings'), TextStyle.WINDOW, { fontSize: '64px' }); this.titleLabel.setOrigin(0.5, 0.5); this.add(this.titleLabel); @@ -141,7 +142,7 @@ export class DailyRunScoreboard extends Phaser.GameObjects.Container { update(category: ScoreboardCategory = this.category, page: integer = this.page) { this.rankingsContainer.removeAll(true); - this.loadingLabel.setText('Loading…'); + this.loadingLabel.setText(i18next.t('menu:loading')); this.loadingLabel.setVisible(true); if (category !== this.category) @@ -155,7 +156,7 @@ export class DailyRunScoreboard extends Phaser.GameObjects.Container { .then(jsonResponse => { this.page = page; this.category = category; - this.titleLabel.setText(`${Utils.toReadableString(ScoreboardCategory[category])} Rankings`); + this.titleLabel.setText(`${Utils.toReadableString(ScoreboardCategory[category])} ${i18next.t("menu:rankings")}`); this.prevPageButton.setAlpha(page > 1 ? 1 : 0.5); this.nextPageButton.setAlpha(page < this.pageCount ? 1 : 0.5); this.pageNumberLabel.setText(page.toString()); @@ -163,7 +164,7 @@ export class DailyRunScoreboard extends Phaser.GameObjects.Container { this.loadingLabel.setVisible(false); this.updateRankings(jsonResponse); } else - this.loadingLabel.setText('No Rankings'); + this.loadingLabel.setText(i18next.t('menu:noRankings')); }); }); } diff --git a/src/ui/title-ui-handler.ts b/src/ui/title-ui-handler.ts index 6c96e475929..c430764e4da 100644 --- a/src/ui/title-ui-handler.ts +++ b/src/ui/title-ui-handler.ts @@ -5,6 +5,7 @@ import { Mode } from "./ui"; import * as Utils from "../utils"; import { TextStyle, addTextObject } from "./text"; import { battleCountSplashMessage, splashMessages } from "../data/splash-messages"; +import i18next from "i18next"; export default class TitleUiHandler extends OptionSelectUiHandler { private titleContainer: Phaser.GameObjects.Container; @@ -37,7 +38,7 @@ export default class TitleUiHandler extends OptionSelectUiHandler { this.titleContainer.add(this.dailyRunScoreboard); - this.playerCountLabel = addTextObject(this.scene, (this.scene.game.canvas.width / 6) - 2, (this.scene.game.canvas.height / 6) - 90, '? Players Online', TextStyle.MESSAGE, { fontSize: '54px' }); + this.playerCountLabel = addTextObject(this.scene, (this.scene.game.canvas.width / 6) - 2, (this.scene.game.canvas.height / 6) - 90, `? ${i18next.t("menu:playersOnline")}`, TextStyle.MESSAGE, { fontSize: '54px' }); this.playerCountLabel.setOrigin(1, 0); this.titleContainer.add(this.playerCountLabel); @@ -61,7 +62,7 @@ export default class TitleUiHandler extends OptionSelectUiHandler { Utils.apiFetch(`game/titlestats`) .then(request => request.json()) .then(stats => { - this.playerCountLabel.setText(`${stats.playerCount} Players Online`); + this.playerCountLabel.setText(`${stats.playerCount} ${i18next.t("menu:playersOnline")}`); if (this.splashMessage === battleCountSplashMessage) this.splashMessageText.setText(battleCountSplashMessage.replace('{COUNT}', stats.battleCount.toLocaleString('en-US'))); }); From 8e64eaea3f3e6dc93572f88095e2128f1fe1a3f9 Mon Sep 17 00:00:00 2001 From: NxKarim <43686802+NxKarim@users.noreply.github.com> Date: Tue, 30 Apr 2024 09:47:10 -0600 Subject: [PATCH 4/6] Some Fixes (HPRatio, Hustle, Imposter, Sleep Talk) (#353) * Some Fixes - HP ratio related checks (`getHpRatio`): Added rounding to 2 decimals for non-precise option. - Hustle (`BattleStatMultiplierAbAttr`): added optional condition; Hustle now works only for physical attacks. - Imposter (`PostSummonTransformAbAttr`): Switch in a double battle after both foes have been defeated no longer crashes the game. - Sleep Talk (`RandomMovesetMoveAttr`): Single target moves no longer target allies. * Formatting changes for consistency --------- Co-authored-by: Flashfyre --- src/data/ability.ts | 15 +++++++++++---- src/data/move.ts | 22 +++++++++++++++++----- src/field/pokemon.ts | 2 +- src/phases.ts | 2 +- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 281a37cfd0c..2ac7d6be1ac 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -976,16 +976,19 @@ export class FieldMoveTypePowerBoostAbAttr extends FieldMovePowerBoostAbAttr { export class BattleStatMultiplierAbAttr extends AbAttr { private battleStat: BattleStat; private multiplier: number; + private condition: PokemonAttackCondition; - constructor(battleStat: BattleStat, multiplier: number) { + constructor(battleStat: BattleStat, multiplier: number, condition?: PokemonAttackCondition) { super(false); this.battleStat = battleStat; this.multiplier = multiplier; + this.condition = condition; } applyBattleStat(pokemon: Pokemon, passive: boolean, battleStat: BattleStat, statValue: Utils.NumberHolder, args: any[]): boolean | Promise { - if (battleStat === this.battleStat) { + const move = (args[0] as Move); + if (battleStat === this.battleStat && (!this.condition || this.condition(pokemon, null, move))) { statValue.value *= this.multiplier; return true; } @@ -1402,6 +1405,7 @@ export class TraceAbAttr extends PostSummonAbAttr { const targets = pokemon.getOpponents(); if (!targets.length) return false; + let target: Pokemon; if (targets.length > 1) pokemon.scene.executeWithSeedOffset(() => target = Utils.randSeedItem(targets), pokemon.scene.currentBattle.waveIndex); @@ -1427,6 +1431,9 @@ export class PostSummonTransformAbAttr extends PostSummonAbAttr { applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { const targets = pokemon.getOpponents(); + if (!targets.length) + return false; + let target: Pokemon; if (targets.length > 1) pokemon.scene.executeWithSeedOffset(() => target = Utils.randSeedItem(targets), pokemon.scene.currentBattle.waveIndex); @@ -2642,8 +2649,8 @@ export function initAbilities() { new Ability(Abilities.TRUANT, 3) .attr(PostSummonAddBattlerTagAbAttr, BattlerTagType.TRUANT, 1, false), new Ability(Abilities.HUSTLE, 3) - .attr(BattleStatMultiplierAbAttr, BattleStat.ATK, 1.5) - .attr(BattleStatMultiplierAbAttr, BattleStat.ACC, 0.8), + .attr(BattleStatMultiplierAbAttr, BattleStat.ATK, 1.5, (user, target, move) => move.category == MoveCategory.PHYSICAL) + .attr(BattleStatMultiplierAbAttr, BattleStat.ACC, 0.8, (user, target, move) => move.category == MoveCategory.PHYSICAL), new Ability(Abilities.CUTE_CHARM, 3) .attr(PostDefendContactApplyTagChanceAbAttr, 30, BattlerTagType.INFATUATED), new Ability(Abilities.PLUS, 3) diff --git a/src/data/move.ts b/src/data/move.ts index 30c97a1ac8d..a95ce9c91f4 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -3099,11 +3099,23 @@ export class RandomMovesetMoveAttr extends OverrideMoveEffectAttr { const moveTargets = getMoveTargets(user, move.moveId); if (!moveTargets.targets.length) return false; - const targets = moveTargets.multiple || moveTargets.targets.length === 1 - ? moveTargets.targets - : moveTargets.targets.indexOf(target.getBattlerIndex()) > -1 - ? [ target.getBattlerIndex() ] - : [ moveTargets.targets[user.randSeedInt(moveTargets.targets.length)] ]; + let selectTargets: BattlerIndex[]; + switch (true) { + case (moveTargets.multiple || moveTargets.targets.length === 1): { + selectTargets = moveTargets.targets; + break; + } + case (moveTargets.targets.indexOf(target.getBattlerIndex()) > -1): { + selectTargets = [ target.getBattlerIndex() ]; + break; + } + default: { + moveTargets.targets.splice(moveTargets.targets.indexOf(user.getAlly().getBattlerIndex())); + selectTargets = [ moveTargets.targets[user.randSeedInt(moveTargets.targets.length)] ]; + break; + } + } + const targets = selectTargets; user.getMoveQueue().push({ move: move.moveId, targets: targets, ignorePP: true }); user.scene.unshiftPhase(new MovePhase(user.scene, user, targets, moveset[moveIndex], true)); return true; diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 44573542fe8..9a7bfb48621 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -658,7 +658,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { getHpRatio(precise: boolean = false): number { return precise ? this.hp / this.getMaxHp() - : ((this.hp / this.getMaxHp()) * 100) / 100; + : Math.round((this.hp / this.getMaxHp()) * 100) / 100; } generateGender(): void { diff --git a/src/phases.ts b/src/phases.ts index 8934104ed80..8eda33de20e 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2548,7 +2548,7 @@ export class MoveEffectPhase extends PokemonPhase { : 3 / (3 + Math.min(targetEvasionLevel.value - userAccuracyLevel.value, 6)); } - applyBattleStatMultiplierAbAttrs(BattleStatMultiplierAbAttr, user, BattleStat.ACC, accuracyMultiplier); + applyBattleStatMultiplierAbAttrs(BattleStatMultiplierAbAttr, user, BattleStat.ACC, accuracyMultiplier, this.move.getMove()); const evasionMultiplier = new Utils.NumberHolder(1); applyBattleStatMultiplierAbAttrs(BattleStatMultiplierAbAttr, this.getTarget(), BattleStat.EVA, evasionMultiplier); From 1e7c329928d422d098167f936530d0d0ea63b41c Mon Sep 17 00:00:00 2001 From: Reldnahc Date: Tue, 30 Apr 2024 11:38:24 -0500 Subject: [PATCH 5/6] Implement move wish (#323) * implement wish move * Serene grace implementation idea * only do the thingy if it actually gets effected. * Revert "only do the thingy if it actually gets effected." This reverts commit 4b084658d26d0aa4d38bdd18f8f051dbc3ca11a3. * Revert "Serene grace implementation idea" This reverts commit 4dd2504bc7cdf3d9ce4ea52c1c680dfc50f01adc. * Fixes for Wish implementation --------- Co-authored-by: Flashfyre --- src/data/arena-tag.ts | 31 +++++++++++++++++++++++++++++-- src/data/enums/arena-tag-type.ts | 1 + src/data/move.ts | 4 ++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/data/arena-tag.ts b/src/data/arena-tag.ts index bb76a9880b3..a879c68d4ce 100644 --- a/src/data/arena-tag.ts +++ b/src/data/arena-tag.ts @@ -1,10 +1,10 @@ import { Arena } from "../field/arena"; import { Type } from "./type"; import * as Utils from "../utils"; -import { MoveCategory, StatChangeAttr, allMoves } from "./move"; +import { MoveCategory, allMoves } from "./move"; import { getPokemonMessage } from "../messages"; import Pokemon, { HitResult, PokemonMove } from "../field/pokemon"; -import { MoveEffectPhase, StatChangePhase } from "../phases"; +import { MoveEffectPhase, PokemonHealPhase, StatChangePhase} from "../phases"; import { StatusEffect } from "./status-effect"; import { BattlerIndex } from "../battle"; import { Moves } from "./enums/moves"; @@ -146,6 +146,31 @@ class AuroraVeilTag extends WeakenMoveScreenTag { } } +class WishTag extends ArenaTag { + private battlerIndex: BattlerIndex; + private triggerMessage: string; + private healHp: number; + + constructor(turnCount: integer, sourceId: integer, side: ArenaTagSide) { + super(ArenaTagType.WISH, turnCount, Moves.WISH, sourceId, side); + } + + onAdd(arena: Arena): void { + const user = arena.scene.getPokemonById(this.sourceId); + this.battlerIndex = user.getBattlerIndex(); + this.triggerMessage = getPokemonMessage(user, '\'s wish\ncame true!'); + this.healHp = Math.max(Math.floor(user.getMaxHp() / 2), 1); + } + + onRemove(arena: Arena): void { + const target = arena.scene.getField()[this.battlerIndex]; + if (target?.isActive(true)) { + arena.scene.queueMessage(this.triggerMessage); + arena.scene.unshiftPhase(new PokemonHealPhase(target.scene, target.getBattlerIndex(), this.healHp, null, true, false)); + } + } +} + export class WeakenMoveTypeTag extends ArenaTag { private weakenedType: Type; @@ -472,6 +497,8 @@ export function getArenaTag(tagType: ArenaTagType, turnCount: integer, sourceMov case ArenaTagType.FUTURE_SIGHT: case ArenaTagType.DOOM_DESIRE: return new DelayedAttackTag(tagType, sourceMove, sourceId, targetIndex); + case ArenaTagType.WISH: + return new WishTag(turnCount, sourceId, side); case ArenaTagType.STEALTH_ROCK: return new StealthRockTag(sourceId, side); case ArenaTagType.STICKY_WEB: diff --git a/src/data/enums/arena-tag-type.ts b/src/data/enums/arena-tag-type.ts index cc08ca4fdcf..8478b6f3f57 100644 --- a/src/data/enums/arena-tag-type.ts +++ b/src/data/enums/arena-tag-type.ts @@ -8,6 +8,7 @@ export enum ArenaTagType { MIST = "MIST", FUTURE_SIGHT = "FUTURE_SIGHT", DOOM_DESIRE = "DOOM_DESIRE", + WISH = "WISH", STEALTH_ROCK = "STEALTH_ROCK", STICKY_WEB = "STICKY_WEB", TRICK_ROOM = "TRICK_ROOM", diff --git a/src/data/move.ts b/src/data/move.ts index a95ce9c91f4..565c3b24125 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -4493,8 +4493,8 @@ export function initMoves() { .attr(AbilityCopyAttr), new SelfStatusMove(Moves.WISH, Type.NORMAL, -1, 10, -1, 0, 3) .triageMove() - .unimplemented(), - new SelfStatusMove(Moves.ASSIST, Type.NORMAL, -1, 20, -1, 0, 3) + .attr(AddArenaTagAttr, ArenaTagType.WISH, 2, true), + new SelfStatusMove(Moves.ASSIST, Type.NORMAL, -1, 20, -1, 0, 3) .attr(RandomMovesetMoveAttr, true) .ignoresVirtual(), new SelfStatusMove(Moves.INGRAIN, Type.GRASS, -1, 20, -1, 0, 3) From 55dc33964739b05905613e6d41d16d3b3543e58a Mon Sep 17 00:00:00 2001 From: Nero <122359402+paulcazac@users.noreply.github.com> Date: Tue, 30 Apr 2024 18:42:20 +0200 Subject: [PATCH 6/6] Bug Fixes and QoL: Minor changes to UI related bugs (#356) * bug fix: updates move description correctly viewing the description of move slot 1 in a pokemon's move summary UI only updated the first time it was viewed per session, exiting the party UI and re-entering caused the moves in a pokemon's summary screen to not automatically populate the description box unless you moved the cursor down to move 2 and then back up to move 1 * slight logic changes to fix party UI controls when battlerCount = 2 (double battle), starting in party slot 1 and pressing DOWN -> UP -> RIGHT would move the cursor back down when it should be moving it to the right: these changes fix that * finalised the minor UI changes * finalising * refactor * removed console logs used for testing * bug fix: updates move description correctly viewing the description of move slot 1 in a pokemon's move summary UI only updated the first time it was viewed per session, exiting the party UI and re-entering caused the moves in a pokemon's summary screen to not automatically populate the description box unless you moved the cursor down to move 2 and then back up to move 1 * slight logic changes to fix party UI controls when battlerCount = 2 (double battle), starting in party slot 1 and pressing DOWN -> UP -> RIGHT would move the cursor back down when it should be moving it to the right: these changes fix that * finalised the minor UI changes * finalising * refactor * removed console logs used for testing --- package-lock.json | 4 ++-- src/ui/party-ui-handler.ts | 15 +++++++++++---- src/ui/summary-ui-handler.ts | 31 ++++++++++++++++++++++--------- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5521dcc86a8..ecaadf378ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pokemon-rogue-battle", - "version": "1.0.1", + "version": "1.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pokemon-rogue-battle", - "version": "1.0.1", + "version": "1.0.3", "dependencies": { "@material/material-color-utilities": "^0.2.7", "crypto-js": "^4.2.0", diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index 30558b5bda0..29a4037f12f 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -383,6 +383,7 @@ export default class PartyUiHandler extends MessageUiHandler { } const slotCount = this.partySlots.length; + const battlerCount = this.scene.currentBattle.getBattlerCount(); switch (button) { case Button.UP: @@ -392,14 +393,20 @@ export default class PartyUiHandler extends MessageUiHandler { success = this.setCursor(this.cursor < 6 ? this.cursor < slotCount - 1 ? this.cursor + 1 : 6 : 0); break; case Button.LEFT: - if (this.cursor >= this.scene.currentBattle.getBattlerCount() && this.cursor < 6) + if (this.cursor >= battlerCount && this.cursor <= 6) success = this.setCursor(0); break; case Button.RIGHT: - const battlerCount = this.scene.currentBattle.getBattlerCount(); - if (slotCount > battlerCount && this.cursor < battlerCount) - success = this.setCursor(this.lastCursor < 6 ? this.lastCursor || battlerCount : battlerCount); + if (slotCount === battlerCount){ + success = this.setCursor(6); break; + } else if (battlerCount >= 2 && slotCount > battlerCount && this.getCursor() === 0 && this.lastCursor === 1){ + success = this.setCursor(2); + break; + } else if (slotCount > battlerCount && this.cursor < battlerCount){ + success = this.setCursor(this.lastCursor < 6 ? this.lastCursor || battlerCount : battlerCount); + break; + } } } diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index 44003a7c8fc..cf5eb3639fd 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -364,9 +364,16 @@ export default class SummaryUiHandler extends UiHandler { case Button.LEFT: this.moveSelect = false; this.setCursor(Page.STATS); - this.hideMoveEffect(); - success = true; - break; + if (this.summaryUiMode === SummaryUiMode.LEARN_MOVE){ + this.hideMoveEffect(); + this.destroyBlinkCursor(); + success = true; + break; + } else { + this.hideMoveSelect(); + success = true; + break; + } } } } else { @@ -426,11 +433,9 @@ export default class SummaryUiHandler extends UiHandler { } setCursor(cursor: integer, overrideChanged: boolean = false): boolean { - let changed: boolean; + let changed: boolean = overrideChanged || this.moveCursor !== cursor; if (this.moveSelect) { - changed = overrideChanged || this.moveCursor !== cursor; - if (changed) { this.moveCursor = cursor; const selectedMove = this.getSelectedMove(); @@ -462,7 +467,6 @@ export default class SummaryUiHandler extends UiHandler { y: `-=${14.83 * (moveDescriptionLineCount - 3)}` }); } - } if (!this.moveCursorObj) { this.moveCursorObj = this.scene.add.sprite(-2, 0, 'summary_moves_cursor', 'highlight'); @@ -527,6 +531,11 @@ export default class SummaryUiHandler extends UiHandler { this.setCursor(0, true); this.showMoveEffect(); } + else if (this.cursor===Page.MOVES) { + this.moveCursorObj = null; + this.showMoveSelect(); + this.showMoveEffect(); + } } else this.summaryPageTransitionContainer.x -= 214; @@ -871,6 +880,12 @@ export default class SummaryUiHandler extends UiHandler { this.moveSelect = false; this.extraMoveRowContainer.setVisible(false); this.moveDescriptionText.setText(''); + + this.destroyBlinkCursor(); + this.hideMoveEffect(); + } + + destroyBlinkCursor(){ if (this.moveCursorBlinkTimer) { this.moveCursorBlinkTimer.destroy(); this.moveCursorBlinkTimer = null; @@ -883,8 +898,6 @@ export default class SummaryUiHandler extends UiHandler { this.selectedMoveCursorObj.destroy(); this.selectedMoveCursorObj = null; } - - this.hideMoveEffect(); } showMoveEffect(instant?: boolean) {