Implement trainer battles and various changes

Implement trainer battles; add dialogue functionality; add random session seed for predictable random results; remove capitalization from text; add full party heal after every 10 waves
This commit is contained in:
Flashfyre committed 2023-10-18 18:01:15 -04:00
1 parent 75bd40863e
commit 83c70889fc
50 files changed
+1500 -399

No files matched your search

+8 -3
View File
@@ -24,6 +24,7 @@ interface SystemSaveData {
}
interface SessionSaveData {
seed: string;
gameMode: GameMode;
party: PokemonData[];
enemyParty: PokemonData[];
@@ -134,6 +135,7 @@ export class GameData {
saveSession(scene: BattleScene): boolean {
const sessionData = {
seed: scene.seed,
gameMode: scene.gameMode,
party: scene.getParty().map(p => new PokemonData(p)),
enemyParty: scene.getEnemyParty().map(p => new PokemonData(p)),
@@ -191,6 +193,9 @@ export class GameData {
console.debug(sessionData);
scene.seed = sessionData.seed || this.scene.game.config.seed[0];
scene.resetSeed();
scene.gameMode = sessionData.gameMode || GameMode.CLASSIC;
const loadPokemonAssets: Promise<void>[] = [];
@@ -213,11 +218,11 @@ export class GameData {
if (sessionData.enemyField)
sessionData.enemyParty = sessionData.enemyField;
scene.newArena(sessionData.arena.biome, true);
const battleType = sessionData.battleType || 0;
const battle = scene.newBattle(sessionData.waveIndex, battleType, sessionData.trainer, battleType === BattleType.TRAINER ? trainerConfigs[sessionData.trainer.trainerType].isDouble : sessionData.enemyParty.length > 1);
scene.newArena(sessionData.arena.biome, true);
sessionData.enemyParty.forEach((enemyData, e) => {
const enemyPokemon = enemyData.toPokemon(scene) as EnemyPokemon;
battle.enemyParty[e] = enemyPokemon;
@@ -334,7 +339,7 @@ export class GameData {
if (newCatch && !hasPrevolution) {
this.scene.playSoundWithoutBgm('level_up_fanfare', 1500);
this.scene.ui.showText(`${species.name.toUpperCase()} has been\nadded as a starter!`, null, () => resolve(), null, true);
this.scene.ui.showText(`${species.name} has been\nadded as a starter!`, null, () => resolve(), null, true);
return;
}
}
+23
View File
@@ -1,6 +1,12 @@
import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
import FadeIn from 'phaser3-rex-plugins/plugins/audio/fade/FadeIn';
import FadeOut from 'phaser3-rex-plugins/plugins/audio/fade/FadeOut';
import BattleScene from "../battle-scene";
import * as Utils from "../utils";
type FadeIn = typeof FadeIn;
type FadeOut = typeof FadeOut;
export function initGameSpeed() {
const thisArg = this as BattleScene;
@@ -32,4 +38,21 @@ export function initGameSpeed() {
config.delay = transformValue(config.delay);
return originalAddCounter.apply(this, [ config ]);
};
const originalFadeOut = SoundFade.fadeOut;
SoundFade.fadeOut = ((
scene: Phaser.Scene,
sound: Phaser.Sound.BaseSound,
duration: number,
destroy?: boolean
) => originalFadeOut(scene, sound, thisArg.gameSpeed === 1 ? duration : Math.ceil(duration /= thisArg.gameSpeed), destroy)) as FadeOut;
const originalFadeIn = SoundFade.fadeIn;
SoundFade.fadeIn = ((
scene: Phaser.Scene,
sound: string | Phaser.Sound.BaseSound,
duration: number,
endVolume?: number,
startVolume?: number
) => originalFadeIn(scene, sound, thisArg.gameSpeed === 1 ? duration : Math.ceil(duration /= thisArg.gameSpeed), endVolume, startVolume)) as FadeIn;
}
+3 -1
View File
@@ -5,14 +5,16 @@ import Trainer from "../trainer";
export default class TrainerData {
public trainerType: TrainerType;
public female: boolean;
public partyTemplateIndex: integer;
constructor(source: Trainer | any) {
const sourceTrainer = source instanceof Trainer ? source as Trainer : null;
this.trainerType = sourceTrainer ? sourceTrainer.config.trainerType : source.trainerType;
this.female = source.female;
this.partyTemplateIndex = source.partyMemberTemplateIndex;
}
toTrainer(scene: BattleScene): Trainer {
return new Trainer(scene, this.trainerType, this.female);
return new Trainer(scene, this.trainerType, this.female, this.partyTemplateIndex);
}
}
+1 -1
View File
@@ -8,6 +8,6 @@ export function getUnlockableName(unlockable: Unlockables) {
case Unlockables.ENDLESS_MODE:
return 'Endless Mode';
case Unlockables.MINI_BLACK_HOLE:
return 'MINI BLACK HOLE';
return 'Mini Black Hole';
}
}