diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 516662617f1..a90ed29d219 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 2205519c532..77ef9721917 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 c4dc7460dfe..da2ddd52511 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 52503501837..1c5f62280de 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)); }