2024-03-17 02:06:56 +00:00
|
|
|
import { fixedBattles } from "./battle";
|
2024-04-30 11:47:53 +01:00
|
|
|
import BattleScene from "./battle-scene";
|
2024-03-16 01:59:34 +00:00
|
|
|
import { Biome } from "./data/enums/biome";
|
2024-03-17 02:06:56 +00:00
|
|
|
import { Species } from "./data/enums/species";
|
|
|
|
import PokemonSpecies, { allSpecies } from "./data/pokemon-species";
|
|
|
|
import { Arena } from "./field/arena";
|
|
|
|
import * as Utils from "./utils";
|
2024-05-23 16:03:10 +01:00
|
|
|
import * as Overrides from "./overrides";
|
2024-03-16 01:59:34 +00:00
|
|
|
|
2024-03-14 20:26:57 +00:00
|
|
|
export enum GameModes {
|
2023-06-01 00:54:57 +01:00
|
|
|
CLASSIC,
|
2023-11-04 23:46:48 +00:00
|
|
|
ENDLESS,
|
2024-03-14 21:15:01 +00:00
|
|
|
SPLICED_ENDLESS,
|
|
|
|
DAILY
|
2023-11-04 23:46:48 +00:00
|
|
|
}
|
|
|
|
|
2024-03-14 20:26:57 +00:00
|
|
|
interface GameModeConfig {
|
|
|
|
isClassic?: boolean;
|
|
|
|
isEndless?: boolean;
|
|
|
|
isDaily?: boolean;
|
|
|
|
hasTrainers?: boolean;
|
|
|
|
hasFixedBattles?: boolean;
|
2024-03-17 02:06:56 +00:00
|
|
|
hasNoShop?: boolean;
|
2024-04-23 01:30:46 +01:00
|
|
|
hasShortBiomes?: boolean;
|
2024-03-14 20:26:57 +00:00
|
|
|
hasRandomBiomes?: boolean;
|
|
|
|
hasRandomBosses?: boolean;
|
|
|
|
isSplicedOnly?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class GameMode implements GameModeConfig {
|
|
|
|
public modeId: GameModes;
|
|
|
|
public isClassic: boolean;
|
|
|
|
public isEndless: boolean;
|
|
|
|
public isDaily: boolean;
|
|
|
|
public hasTrainers: boolean;
|
|
|
|
public hasFixedBattles: boolean;
|
2024-03-17 02:06:56 +00:00
|
|
|
public hasNoShop: boolean;
|
2024-04-23 01:30:46 +01:00
|
|
|
public hasShortBiomes: boolean;
|
2024-03-14 20:26:57 +00:00
|
|
|
public hasRandomBiomes: boolean;
|
|
|
|
public hasRandomBosses: boolean;
|
|
|
|
public isSplicedOnly: boolean;
|
|
|
|
|
|
|
|
constructor(modeId: GameModes, config: GameModeConfig) {
|
|
|
|
this.modeId = modeId;
|
|
|
|
Object.assign(this, config);
|
|
|
|
}
|
|
|
|
|
2024-05-09 20:52:09 +01:00
|
|
|
/**
|
|
|
|
* @returns either:
|
|
|
|
* - override from overrides.ts
|
|
|
|
* - 20 for Daily Runs
|
|
|
|
* - 5 for all other modes
|
|
|
|
*/
|
2024-03-16 01:59:34 +00:00
|
|
|
getStartingLevel(): integer {
|
2024-05-23 16:03:10 +01:00
|
|
|
if (Overrides.STARTING_LEVEL_OVERRIDE) {
|
2024-05-09 20:52:09 +01:00
|
|
|
return Overrides.STARTING_LEVEL_OVERRIDE;
|
2024-05-23 16:03:10 +01:00
|
|
|
}
|
2024-03-16 01:59:34 +00:00
|
|
|
switch (this.modeId) {
|
2024-05-23 16:03:10 +01:00
|
|
|
case GameModes.DAILY:
|
|
|
|
return 20;
|
|
|
|
default:
|
|
|
|
return 5;
|
2024-03-16 01:59:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-09 20:52:09 +01:00
|
|
|
/**
|
|
|
|
* @returns either:
|
|
|
|
* - override from overrides.ts
|
|
|
|
* - 1000
|
|
|
|
*/
|
2024-03-16 01:59:34 +00:00
|
|
|
getStartingMoney(): integer {
|
2024-05-09 20:52:09 +01:00
|
|
|
return Overrides.STARTING_MONEY_OVERRIDE || 1000;
|
2024-03-16 01:59:34 +00:00
|
|
|
}
|
|
|
|
|
2024-05-09 20:52:09 +01:00
|
|
|
/**
|
|
|
|
* @param scene current BattleScene
|
|
|
|
* @returns either:
|
|
|
|
* - random biome for Daily mode
|
|
|
|
* - override from overrides.ts
|
|
|
|
* - Town
|
|
|
|
*/
|
2024-03-16 01:59:34 +00:00
|
|
|
getStartingBiome(scene: BattleScene): Biome {
|
|
|
|
switch (this.modeId) {
|
2024-05-23 16:03:10 +01:00
|
|
|
case GameModes.DAILY:
|
|
|
|
return scene.generateRandomBiome(this.getWaveForDifficulty(1));
|
|
|
|
default:
|
|
|
|
return Overrides.STARTING_BIOME_OVERRIDE || Biome.TOWN;
|
2024-03-16 01:59:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-17 02:06:56 +00:00
|
|
|
getWaveForDifficulty(waveIndex: integer, ignoreCurveChanges: boolean = false): integer {
|
2024-03-14 20:26:57 +00:00
|
|
|
switch (this.modeId) {
|
2024-05-23 16:03:10 +01:00
|
|
|
case GameModes.DAILY:
|
|
|
|
return waveIndex + 30 + (!ignoreCurveChanges ? Math.floor(waveIndex / 5) : 0);
|
|
|
|
default:
|
|
|
|
return waveIndex;
|
2024-03-14 21:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-17 02:06:56 +00:00
|
|
|
isWaveTrainer(waveIndex: integer, arena: Arena): boolean {
|
2024-05-23 16:03:10 +01:00
|
|
|
if (this.isDaily) {
|
2024-03-17 02:06:56 +00:00
|
|
|
return waveIndex % 10 === 5 || (!(waveIndex % 10) && waveIndex > 10 && !this.isWaveFinal(waveIndex));
|
2024-05-23 16:03:10 +01:00
|
|
|
}
|
|
|
|
if ((waveIndex % 30) === (arena.scene.offsetGym ? 0 : 20) && !this.isWaveFinal(waveIndex)) {
|
2024-03-17 02:06:56 +00:00
|
|
|
return true;
|
2024-05-23 16:03:10 +01:00
|
|
|
} else if (waveIndex % 10 !== 1 && waveIndex % 10) {
|
2024-03-17 02:06:56 +00:00
|
|
|
const trainerChance = arena.getTrainerChance();
|
|
|
|
let allowTrainerBattle = true;
|
|
|
|
if (trainerChance) {
|
|
|
|
const waveBase = Math.floor(waveIndex / 10) * 10;
|
|
|
|
for (let w = Math.max(waveIndex - 3, waveBase + 2); w <= Math.min(waveIndex + 3, waveBase + 9); w++) {
|
2024-05-23 16:03:10 +01:00
|
|
|
if (w === waveIndex) {
|
2024-03-17 02:06:56 +00:00
|
|
|
continue;
|
2024-05-23 16:03:10 +01:00
|
|
|
}
|
2024-03-25 15:00:42 +00:00
|
|
|
if ((w % 30) === (arena.scene.offsetGym ? 0 : 20) || fixedBattles.hasOwnProperty(w)) {
|
2024-03-17 02:06:56 +00:00
|
|
|
allowTrainerBattle = false;
|
|
|
|
break;
|
|
|
|
} else if (w < waveIndex) {
|
|
|
|
arena.scene.executeWithSeedOffset(() => {
|
|
|
|
const waveTrainerChance = arena.getTrainerChance();
|
2024-05-23 16:03:10 +01:00
|
|
|
if (!Utils.randSeedInt(waveTrainerChance)) {
|
2024-03-17 02:06:56 +00:00
|
|
|
allowTrainerBattle = false;
|
2024-05-23 16:03:10 +01:00
|
|
|
}
|
2024-03-17 02:06:56 +00:00
|
|
|
}, w);
|
2024-05-23 16:03:10 +01:00
|
|
|
if (!allowTrainerBattle) {
|
2024-03-17 02:06:56 +00:00
|
|
|
break;
|
2024-05-23 16:03:10 +01:00
|
|
|
}
|
2024-03-17 02:06:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return allowTrainerBattle && trainerChance && !Utils.randSeedInt(trainerChance);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-03-25 15:00:42 +00:00
|
|
|
isTrainerBoss(waveIndex: integer, biomeType: Biome, offsetGym: boolean): boolean {
|
2024-03-17 02:06:56 +00:00
|
|
|
switch (this.modeId) {
|
2024-05-23 16:03:10 +01:00
|
|
|
case GameModes.DAILY:
|
|
|
|
return waveIndex > 10 && waveIndex < 50 && !(waveIndex % 10);
|
|
|
|
default:
|
|
|
|
return (waveIndex % 30) === (offsetGym ? 0 : 20) && (biomeType !== Biome.END || this.isClassic || this.isWaveFinal(waveIndex));
|
2024-03-17 02:06:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getOverrideSpecies(waveIndex: integer): PokemonSpecies {
|
|
|
|
if (this.isDaily && this.isWaveFinal(waveIndex)) {
|
2024-05-05 16:05:22 +01:00
|
|
|
const allFinalBossSpecies = allSpecies.filter(s => (s.subLegendary || s.legendary || s.mythical)
|
2024-03-17 02:06:56 +00:00
|
|
|
&& s.baseTotal >= 600 && s.speciesId !== Species.ETERNATUS && s.speciesId !== Species.ARCEUS);
|
|
|
|
return Utils.randSeedItem(allFinalBossSpecies);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2024-05-22 16:06:24 +01:00
|
|
|
/**
|
|
|
|
* Checks if wave provided is the final for current or specified game mode
|
|
|
|
* @param waveIndex
|
|
|
|
* @param modeId game mode
|
|
|
|
* @returns if the current wave is final for classic or daily OR a minor boss in endless
|
|
|
|
*/
|
|
|
|
isWaveFinal(waveIndex: integer, modeId: GameModes = this.modeId): boolean {
|
|
|
|
switch (modeId) {
|
2024-05-23 16:03:10 +01:00
|
|
|
case GameModes.CLASSIC:
|
|
|
|
return waveIndex === 200;
|
|
|
|
case GameModes.ENDLESS:
|
|
|
|
case GameModes.SPLICED_ENDLESS:
|
|
|
|
return !(waveIndex % 250);
|
|
|
|
case GameModes.DAILY:
|
|
|
|
return waveIndex === 50;
|
2024-03-14 20:26:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-23 16:03:10 +01:00
|
|
|
/**
|
2024-05-22 16:06:24 +01:00
|
|
|
* Every 10 waves is a boss battle
|
|
|
|
* @returns true if waveIndex is a multiple of 10
|
|
|
|
*/
|
2024-05-23 16:03:10 +01:00
|
|
|
isBoss(waveIndex: integer): boolean {
|
|
|
|
return waveIndex % 10 === 0;
|
|
|
|
}
|
2024-05-22 16:06:24 +01:00
|
|
|
|
2024-05-23 16:03:10 +01:00
|
|
|
/**
|
2024-05-22 16:06:24 +01:00
|
|
|
* Every 50 waves of an Endless mode is a boss
|
|
|
|
* At this time it is paradox pokemon
|
|
|
|
* @returns true if waveIndex is a multiple of 50 in Endless
|
|
|
|
*/
|
2024-05-23 16:03:10 +01:00
|
|
|
isEndlessBoss(waveIndex: integer): boolean {
|
|
|
|
return waveIndex % 50 &&
|
2024-05-22 16:06:24 +01:00
|
|
|
(this.modeId === GameModes.ENDLESS || this.modeId === GameModes.SPLICED_ENDLESS);
|
2024-05-23 16:03:10 +01:00
|
|
|
}
|
2024-05-22 16:06:24 +01:00
|
|
|
|
2024-05-23 16:03:10 +01:00
|
|
|
/**
|
2024-05-22 16:06:24 +01:00
|
|
|
* Every 250 waves of an Endless mode is a minor boss
|
|
|
|
* At this time it is Eternatus
|
|
|
|
* @returns true if waveIndex is a multiple of 250 in Endless
|
|
|
|
*/
|
2024-05-23 16:03:10 +01:00
|
|
|
isEndlessMinorBoss(waveIndex: integer): boolean {
|
|
|
|
return waveIndex % 250 === 0 &&
|
2024-05-22 16:06:24 +01:00
|
|
|
(this.modeId === GameModes.ENDLESS || this.modeId === GameModes.SPLICED_ENDLESS);
|
2024-05-23 16:03:10 +01:00
|
|
|
}
|
2024-05-22 16:06:24 +01:00
|
|
|
|
2024-05-23 16:03:10 +01:00
|
|
|
/**
|
2024-05-22 16:06:24 +01:00
|
|
|
* Every 1000 waves of an Endless mode is a major boss
|
|
|
|
* At this time it is Eternamax Eternatus
|
|
|
|
* @returns true if waveIndex is a multiple of 1000 in Endless
|
|
|
|
*/
|
2024-05-23 16:03:10 +01:00
|
|
|
isEndlessMajorBoss(waveIndex: integer): boolean {
|
|
|
|
return waveIndex % 1000 === 0 &&
|
2024-05-22 16:06:24 +01:00
|
|
|
(this.modeId === GameModes.ENDLESS || this.modeId === GameModes.SPLICED_ENDLESS);
|
2024-05-23 16:03:10 +01:00
|
|
|
}
|
2024-05-22 16:06:24 +01:00
|
|
|
|
|
|
|
|
2024-03-18 00:58:12 +00:00
|
|
|
getClearScoreBonus(): integer {
|
|
|
|
switch (this.modeId) {
|
2024-05-23 16:03:10 +01:00
|
|
|
case GameModes.CLASSIC:
|
|
|
|
return 5000;
|
|
|
|
case GameModes.DAILY:
|
|
|
|
return 2500;
|
2024-03-18 00:58:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-14 20:26:57 +00:00
|
|
|
getEnemyModifierChance(isBoss: boolean): integer {
|
|
|
|
switch (this.modeId) {
|
2024-05-23 16:03:10 +01:00
|
|
|
case GameModes.CLASSIC:
|
|
|
|
case GameModes.DAILY:
|
|
|
|
return !isBoss ? 18 : 6;
|
|
|
|
case GameModes.ENDLESS:
|
|
|
|
case GameModes.SPLICED_ENDLESS:
|
|
|
|
return !isBoss ? 12 : 4;
|
2024-03-14 20:26:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getName(): string {
|
|
|
|
switch (this.modeId) {
|
2024-05-23 16:03:10 +01:00
|
|
|
case GameModes.CLASSIC:
|
|
|
|
return "Classic";
|
|
|
|
case GameModes.ENDLESS:
|
|
|
|
return "Endless";
|
|
|
|
case GameModes.SPLICED_ENDLESS:
|
|
|
|
return "Endless (Spliced)";
|
|
|
|
case GameModes.DAILY:
|
|
|
|
return "Daily Run";
|
2024-03-14 20:26:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const gameModes = Object.freeze({
|
|
|
|
[GameModes.CLASSIC]: new GameMode(GameModes.CLASSIC, { isClassic: true, hasTrainers: true, hasFixedBattles: true }),
|
2024-04-23 01:30:46 +01:00
|
|
|
[GameModes.ENDLESS]: new GameMode(GameModes.ENDLESS, { isEndless: true, hasShortBiomes: true, hasRandomBosses: true }),
|
|
|
|
[GameModes.SPLICED_ENDLESS]: new GameMode(GameModes.SPLICED_ENDLESS, { isEndless: true, hasShortBiomes: true, hasRandomBosses: true, isSplicedOnly: true }),
|
2024-03-17 02:06:56 +00:00
|
|
|
[GameModes.DAILY]: new GameMode(GameModes.DAILY, { isDaily: true, hasTrainers: true, hasNoShop: true })
|
2024-05-23 16:03:10 +01:00
|
|
|
});
|