Add logic to space out trainer battles in classic mode

pull/12/head
Flashfyre 2023-12-08 09:48:03 -05:00
parent 9a42b05dd6
commit 5441ecbd73
3 changed files with 23 additions and 3 deletions

View File

@ -636,7 +636,27 @@ export default class BattleScene extends Phaser.Scene {
newBattleType = BattleType.TRAINER; newBattleType = BattleType.TRAINER;
else if (newWaveIndex % 10 !== 1 && newWaveIndex % 10) { else if (newWaveIndex % 10 !== 1 && newWaveIndex % 10) {
const trainerChance = this.arena.getTrainerChance(); const trainerChance = this.arena.getTrainerChance();
newBattleType = trainerChance && !Utils.randSeedInt(trainerChance) ? BattleType.TRAINER : BattleType.WILD; let allowTrainerBattle = true;
if (trainerChance && this.gameMode === GameMode.CLASSIC) {
const waveBase = Math.floor(newWaveIndex / 10) * 10;
for (let w = Math.max(newWaveIndex - 3, waveBase + 2); w <= Math.min(newWaveIndex + 3, waveBase + 9); w++) {
if (w === newWaveIndex)
continue;
if (((w > 20 && !(w % 30)) || fixedBattles.hasOwnProperty(w))) {
allowTrainerBattle = false;
break;
} else if (w < newWaveIndex) {
this.executeWithSeedOffset(() => {
const waveTrainerChance = this.arena.getTrainerChance();
if (!Utils.randSeedInt(waveTrainerChance))
allowTrainerBattle = false;
}, w);
if (!allowTrainerBattle)
break;
}
}
}
newBattleType = allowTrainerBattle && trainerChance && !Utils.randSeedInt(trainerChance) ? BattleType.TRAINER : BattleType.WILD;
} else } else
newBattleType = BattleType.WILD; newBattleType = BattleType.WILD;
} else } else

View File

@ -1,5 +1,5 @@
import BattleScene, { startingWave } from "../battle-scene"; import BattleScene, { startingWave } from "../battle-scene";
import { ModifierType, ModifierTypeFunc, modifierTypes } from "../modifier/modifier-type"; import { ModifierTypeFunc, modifierTypes } from "../modifier/modifier-type";
import { EnemyPokemon } from "../pokemon"; import { EnemyPokemon } from "../pokemon";
import * as Utils from "../utils"; import * as Utils from "../utils";
import { Moves } from "./move"; import { Moves } from "./move";

View File

@ -1,5 +1,5 @@
import Pokemon from "./pokemon"; import Pokemon from "./pokemon";
export function getPokemonMessage(pokemon: Pokemon, content: string): string { export function getPokemonMessage(pokemon: Pokemon, content: string): string {
return `${!pokemon.isPlayer() ? 'Wild ' : ''}${pokemon.name}${content}`; return `${!pokemon.isPlayer() ? pokemon.hasTrainer() ? 'Foe ' : 'Wild ' : ''}${pokemon.name}${content}`;
} }