Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Smeargle Mode #4291

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/battle-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,8 @@ export default class BattleScene extends SceneBase {
}
});

console.log(this);

this.updateBiomeWaveText();
this.updateMoneyText();
this.updateScoreText();
Expand Down
35 changes: 35 additions & 0 deletions src/data/challenge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,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()) && pokemon.isPlayer()) {
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
Expand Down Expand Up @@ -985,6 +1017,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");
}
Expand All @@ -997,5 +1031,6 @@ export function initChallenges() {
new SingleTypeChallenge(),
new FreshStartChallenge(),
new InverseBattleChallenge(),
new SmeargleChallenge()
);
}
1 change: 1 addition & 0 deletions src/enums/challenges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export enum Challenges {
LOWER_STARTER_POINTS,
FRESH_START,
INVERSE_BATTLE,
SMEARGLE
}
73 changes: 70 additions & 3 deletions src/phases/title-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
Expand Down Expand Up @@ -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: () => {
Expand Down Expand Up @@ -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<void>[] = [];

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();
Expand Down Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/phases/turn-start-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Loading