From 944b2a4516f1d38ceb9b65071f37d1f7c05bd175 Mon Sep 17 00:00:00 2001 From: frutescens Date: Mon, 16 Sep 2024 20:58:03 -0700 Subject: [PATCH 1/3] smeargle mode real --- src/battle-scene.ts | 2 ++ src/data/challenge.ts | 35 +++++++++++++++++++ src/enums/challenges.ts | 1 + src/phases/title-phase.ts | 73 +++++++++++++++++++++++++++++++++++++-- 4 files changed, 108 insertions(+), 3 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 516662617f16..a90ed29d2194 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -653,6 +653,8 @@ export default class BattleScene extends SceneBase { } }); + console.log(this); + this.updateBiomeWaveText(); this.updateMoneyText(); this.updateScoreText(); diff --git a/src/data/challenge.ts b/src/data/challenge.ts index 2205519c5322..77ef97219178 100644 --- a/src/data/challenge.ts +++ b/src/data/challenge.ts @@ -772,6 +772,38 @@ export class LowerStarterPointsChallenge extends Challenge { } } +/** + * Implements a mono generation challenge. + */ +export class SmeargleChallenge extends Challenge { + constructor() { + super(Challenges.SMEARGLE, 1); + } + + applyStarterChoice(pokemon: PokemonSpecies, valid: Utils.BooleanHolder, dexAttr: DexAttrProps, soft: boolean = false): boolean { + if (pokemon.speciesId !== Species.SMEARGLE) { + valid.value = false; + return true; + } + return false; + } + + applyPokemonInBattle(pokemon: Pokemon, valid: Utils.BooleanHolder): boolean { + if (pokemon.species.speciesId !== Species.SMEARGLE || pokemon.isFusion()) { + valid.value = false; + return true; + } + return false; + } + + static loadChallenge(source: SmeargleChallenge | any): SmeargleChallenge { + const newChallenge = new SmeargleChallenge(); + newChallenge.value = source.value; + newChallenge.severity = source.severity; + return newChallenge; + } +} + /** * Apply all challenges that modify starter choice. * @param gameMode {@link GameMode} The current gameMode @@ -961,6 +993,8 @@ export function copyChallenge(source: Challenge | any): Challenge { return FreshStartChallenge.loadChallenge(source); case Challenges.INVERSE_BATTLE: return InverseBattleChallenge.loadChallenge(source); + case Challenges.SMEARGLE: + return SmeargleChallenge.loadChallenge(source); } throw new Error("Unknown challenge copied"); } @@ -973,5 +1007,6 @@ export function initChallenges() { new SingleTypeChallenge(), new FreshStartChallenge(), new InverseBattleChallenge(), + new SmeargleChallenge() ); } diff --git a/src/enums/challenges.ts b/src/enums/challenges.ts index c4dc7460dfe1..da2ddd52511a 100644 --- a/src/enums/challenges.ts +++ b/src/enums/challenges.ts @@ -5,4 +5,5 @@ export enum Challenges { LOWER_STARTER_POINTS, FRESH_START, INVERSE_BATTLE, + SMEARGLE } diff --git a/src/phases/title-phase.ts b/src/phases/title-phase.ts index 52503501837c..1c5f62280ded 100644 --- a/src/phases/title-phase.ts +++ b/src/phases/title-phase.ts @@ -3,6 +3,7 @@ import BattleScene from "#app/battle-scene"; import { BattleType } from "#app/battle"; import { getDailyRunStarters, fetchDailyRunSeed } from "#app/data/daily-run"; import { Gender } from "#app/data/gender"; +import { getPokemonSpecies } from "#app/data/pokemon-species"; import { getBiomeKey } from "#app/field/arena"; import { GameModes, GameMode, getGameMode } from "#app/game-mode"; import { regenerateModifierPoolThresholds, ModifierPoolType, modifierTypes, getDailyRunStarterModifiers } from "#app/modifier/modifier-type"; @@ -21,7 +22,9 @@ import { EncounterPhase } from "./encounter-phase"; import { SelectChallengePhase } from "./select-challenge-phase"; import { SelectStarterPhase } from "./select-starter-phase"; import { SummonPhase } from "./summon-phase"; - +import { Species } from "#app/enums/species"; +import { Moves } from "#app/enums/moves"; +import { Challenges } from "#app/enums/challenges"; export class TitlePhase extends Phase { private loaded: boolean; @@ -149,6 +152,15 @@ export class TitlePhase extends Phase { }, keepOpen: true }, + { + label: "Smeargle", + handler: () => { + this.gameMode = GameModes.CHALLENGE; + this.initSmeargle(); + return true; + }, + keepOpen: true + }, { label: i18next.t("menu:settings"), handler: () => { @@ -182,6 +194,51 @@ export class TitlePhase extends Phase { }); } + initSmeargle(): void { + this.scene.ui.setMode(Mode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: integer) => { + this.scene.clearPhaseQueue(); + if (slotId === -1) { + this.scene.pushPhase(new TitlePhase(this.scene)); + return super.end(); + } + this.scene.sessionSlotId = slotId; + + + const generateSmeargles = () => { + this.scene.money = 2500; + const startingLevel = 5; + + const party = this.scene.getParty(); + const loadPokemonAssets: Promise[] = []; + + for (let i = 0; i < 6; i++) { + const smeargle = this.scene.addPlayerPokemon(getPokemonSpecies(Species.SMEARGLE), startingLevel); + smeargle.setVisible(false); + party.push(smeargle); + loadPokemonAssets.push(smeargle.loadAssets()); + } + + Promise.all(loadPokemonAssets).then(() => { + this.scene.sessionPlayTime = 0; + this.scene.lastSavePlayTime = 0; + party.forEach((p, i) => { + for (let m = 0; m < 4; m++) { + if (i === 0 && m === 0) { + p.setMove(m, Moves.TACKLE); + } else { + p.setMove(m, Moves.SKETCH); + } + } + }); + + this.end(true); + }); + }; + generateSmeargles(); + + }); + } + initDailyRun(): void { this.scene.ui.setMode(Mode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: integer) => { this.scene.clearPhaseQueue(); @@ -257,12 +314,22 @@ export class TitlePhase extends Phase { }); } - end(): void { + end(smeargle = false): void { if (!this.loaded && !this.scene.gameMode.isDaily) { this.scene.arena.preloadBgm(); this.scene.gameMode = getGameMode(this.gameMode); - if (this.gameMode === GameModes.CHALLENGE) { + if (this.gameMode === GameModes.CHALLENGE && !smeargle) { this.scene.pushPhase(new SelectChallengePhase(this.scene)); + } else if (this.gameMode === GameModes.CHALLENGE && smeargle) { + this.scene.gameMode = getGameMode(GameModes.CHALLENGE); + this.scene.gameMode.challenges.forEach(c => { + if (c.id === Challenges.SMEARGLE) { + c.value = 1; + } + }); + this.scene.newArena(this.scene.gameMode.getStartingBiome(this.scene)); + this.scene.newBattle(); + this.scene.arena.init(); } else { this.scene.pushPhase(new SelectStarterPhase(this.scene)); } From 666ba485679ef2d150799cbf289bd4bc2a296dde Mon Sep 17 00:00:00 2001 From: frutescens Date: Tue, 17 Sep 2024 09:02:46 -0700 Subject: [PATCH 2/3] fix challenge condition --- src/data/challenge.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/challenge.ts b/src/data/challenge.ts index 77ef97219178..c6443d91f70c 100644 --- a/src/data/challenge.ts +++ b/src/data/challenge.ts @@ -789,7 +789,7 @@ export class SmeargleChallenge extends Challenge { } applyPokemonInBattle(pokemon: Pokemon, valid: Utils.BooleanHolder): boolean { - if (pokemon.species.speciesId !== Species.SMEARGLE || pokemon.isFusion()) { + if ((pokemon.species.speciesId !== Species.SMEARGLE || pokemon.isFusion()) && pokemon.isPlayer()) { valid.value = false; return true; } From 318b60fa4d8c61b3c25803d2a48f1546ce67a078 Mon Sep 17 00:00:00 2001 From: frutescens Date: Tue, 17 Sep 2024 14:41:31 -0700 Subject: [PATCH 3/3] Sketch bug fix --- src/phases/turn-start-phase.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/phases/turn-start-phase.ts b/src/phases/turn-start-phase.ts index 5c1af4228c65..93edd482ec8e 100644 --- a/src/phases/turn-start-phase.ts +++ b/src/phases/turn-start-phase.ts @@ -160,7 +160,7 @@ export class TurnStartPhase extends FieldPhase { if (!queuedMove) { continue; } - const move = pokemon.getMoveset().find(m => m?.moveId === queuedMove.move) || new PokemonMove(queuedMove.move); + const move = pokemon.getMoveset().find(m => m?.moveId === queuedMove.move && m?.ppUsed < m?.getMovePp()) || new PokemonMove(queuedMove.move); if (move.getMove().hasAttr(MoveHeaderAttr)) { this.scene.unshiftPhase(new MoveHeaderPhase(this.scene, pokemon, move)); }