Add money (currently unused) and fix issue with reward modifiers not persisting

pull/2/head
Flashfyre 2023-10-21 20:23:43 -04:00
parent 8222d67408
commit 7dbf3f62da
6 changed files with 33 additions and 10 deletions

View File

@ -231,6 +231,7 @@ export class EncounterPhase extends BattlePhase {
super.start(); super.start();
this.scene.updateWaveCountText(); this.scene.updateWaveCountText();
this.scene.updateMoneyText();
const loadEnemyAssets = []; const loadEnemyAssets = [];

View File

@ -35,6 +35,7 @@ const quickStart = false;
export const startingLevel = 5; export const startingLevel = 5;
export const startingWave = 1; export const startingWave = 1;
export const startingBiome = Biome.TOWN; export const startingBiome = Biome.TOWN;
export const startingMoney = 1000;
export enum Button { export enum Button {
UP, UP,
@ -88,8 +89,10 @@ export default class BattleScene extends Phaser.Scene {
public lastEnemyTrainer: Trainer; public lastEnemyTrainer: Trainer;
public currentBattle: Battle; public currentBattle: Battle;
public pokeballCounts: PokeballCounts; public pokeballCounts: PokeballCounts;
public money: integer;
private party: PlayerPokemon[]; private party: PlayerPokemon[];
private waveCountText: Phaser.GameObjects.Text; private waveCountText: Phaser.GameObjects.Text;
private moneyText: Phaser.GameObjects.Text;
private modifierBar: ModifierBar; private modifierBar: ModifierBar;
private enemyModifierBar: ModifierBar; private enemyModifierBar: ModifierBar;
private modifiers: PersistentModifier[]; private modifiers: PersistentModifier[];
@ -384,9 +387,14 @@ export default class BattleScene extends Phaser.Scene {
this.waveCountText = addTextObject(this, (this.game.canvas.width / 6) - 2, 0, startingWave.toString(), TextStyle.BATTLE_INFO); this.waveCountText = addTextObject(this, (this.game.canvas.width / 6) - 2, 0, startingWave.toString(), TextStyle.BATTLE_INFO);
this.waveCountText.setOrigin(1, 0); this.waveCountText.setOrigin(1, 0);
this.updateUIPositions();
this.fieldUI.add(this.waveCountText); this.fieldUI.add(this.waveCountText);
this.moneyText = addTextObject(this, (this.game.canvas.width / 6) - 2, 0, startingWave.toString(), TextStyle.MONEY);
this.moneyText.setOrigin(1, 0);
this.fieldUI.add(this.moneyText);
this.updateUIPositions();
this.party = []; this.party = [];
let loadPokemonAssets = []; let loadPokemonAssets = [];
@ -538,6 +546,8 @@ export default class BattleScene extends Phaser.Scene {
this.seed = Utils.randomString(16); this.seed = Utils.randomString(16);
console.log('Seed:', this.seed); console.log('Seed:', this.seed);
this.money = startingMoney;
this.pokeballCounts = Object.fromEntries(Utils.getEnumValues(PokeballType).filter(p => p <= PokeballType.MASTER_BALL).map(t => [ t, 0 ])); this.pokeballCounts = Object.fromEntries(Utils.getEnumValues(PokeballType).filter(p => p <= PokeballType.MASTER_BALL).map(t => [ t, 0 ]));
this.pokeballCounts[PokeballType.POKEBALL] += 5; this.pokeballCounts[PokeballType.POKEBALL] += 5;
@ -556,6 +566,9 @@ export default class BattleScene extends Phaser.Scene {
this.waveCountText.setText(startingWave.toString()); this.waveCountText.setText(startingWave.toString());
this.waveCountText.setVisible(false); this.waveCountText.setVisible(false);
this.updateMoneyText();
this.moneyText.setVisible(false);
this.newArena(startingBiome, true); this.newArena(startingBiome, true);
this.arenaBgTransition.setPosition(0, 0); this.arenaBgTransition.setPosition(0, 0);
@ -722,9 +735,15 @@ export default class BattleScene extends Phaser.Scene {
this.waveCountText.setVisible(true); this.waveCountText.setVisible(true);
} }
updateMoneyText(): void {
this.moneyText.setText(`${this.money.toLocaleString('en-US')}`);
this.moneyText.setVisible(true);
}
updateUIPositions(): void { updateUIPositions(): void {
this.waveCountText.setY(-(this.game.canvas.height / 6) + (this.enemyModifiers.length ? 15 : 0)); this.waveCountText.setY(-(this.game.canvas.height / 6) + (this.enemyModifiers.length ? 15 : 0));
this.partyExpBar.setY(this.waveCountText.y + 15); this.moneyText.setY(this.waveCountText.y + 10);
this.partyExpBar.setY(this.moneyText.y + 15);
} }
getMaxExpLevel(): integer { getMaxExpLevel(): integer {

View File

@ -4702,7 +4702,7 @@ export const biomeTrainerPools: BiomeTrainerPools = {
console.log(beautify(trainerOutput, null, 2, 120).replace(/( | (?:\{ "\d+": \[ )?| "(?:.*?)": \[ |, (?:(?:\{ )?"\d+": \[ )?)"(.*?)"/g, '$1TrainerType.$2').replace(/"(\d+)": /g, '$1: ').replace(/( )"(.*?)"/g, '$1[BiomePoolTier.$2]').replace(/( )"(.*?)"/g, '$1[Biome.$2]')); console.log(beautify(trainerOutput, null, 2, 120).replace(/( | (?:\{ "\d+": \[ )?| "(?:.*?)": \[ |, (?:(?:\{ )?"\d+": \[ )?)"(.*?)"/g, '$1TrainerType.$2').replace(/"(\d+)": /g, '$1: ').replace(/( )"(.*?)"/g, '$1[BiomePoolTier.$2]').replace(/( )"(.*?)"/g, '$1[Biome.$2]'));
} }
outputPools(); //outputPools();
/*for (let pokemon of allSpecies) { /*for (let pokemon of allSpecies) {
if (pokemon.speciesId >= Species.XERNEAS) if (pokemon.speciesId >= Species.XERNEAS)

View File

@ -1,5 +1,5 @@
import BattleScene from "../battle-scene"; import BattleScene from "../battle-scene";
import { ModifierType, modifierTypes } from "../modifier/modifier-type"; import { ModifierType, 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";
@ -413,8 +413,9 @@ export class TrainerConfig {
return this; return this;
} }
setModifierRewardFuncs(...modifierTypeFuncs: (() => ModifierType)[]): TrainerConfig { setModifierRewardFuncs(...modifierTypeFuncs: (() => ModifierTypeFunc)[]): TrainerConfig {
this.modifierRewardFuncs = modifierTypeFuncs.map(modifierTypeFunc => () => { this.modifierRewardFuncs = modifierTypeFuncs.map(func => () => {
const modifierTypeFunc = func();
const modifierType = modifierTypeFunc(); const modifierType = modifierTypeFunc();
modifierType.id = Object.keys(modifierTypes).find(k => modifierTypes[k] === modifierTypeFunc); modifierType.id = Object.keys(modifierTypes).find(k => modifierTypes[k] === modifierTypeFunc);
return modifierType; return modifierType;
@ -682,7 +683,7 @@ export const trainerConfigs: TrainerConfigs = {
$Just kidding! I lost fair and square, and now I know you'll do fine out there. $Just kidding! I lost fair and square, and now I know you'll do fine out there.
$By the way, the professor wanted me to give you some items. Hopefully they're helpful! $By the way, the professor wanted me to give you some items. Hopefully they're helpful!
$Do your best like always! I believe in you!` $Do your best like always! I believe in you!`
]).setModifierRewardFuncs(() => modifierTypes.EXP_CHARM(), () => modifierTypes.EXP_SHARE()).setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE, Species.CHIKORITA, Species.CYNDAQUIL, Species.TOTODILE, Species.TREECKO, Species.TORCHIC, Species.MUDKIP, Species.TURTWIG, Species.CHIMCHAR, Species.PIPLUP, Species.SNIVY, Species.TEPIG, Species.OSHAWOTT ])) ]).setModifierRewardFuncs(() => modifierTypes.EXP_CHARM, () => modifierTypes.EXP_SHARE).setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE, Species.CHIKORITA, Species.CYNDAQUIL, Species.TOTODILE, Species.TREECKO, Species.TORCHIC, Species.MUDKIP, Species.TURTWIG, Species.CHIMCHAR, Species.PIPLUP, Species.SNIVY, Species.TEPIG, Species.OSHAWOTT ]))
.setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEY, Species.HOOTHOOT, Species.TAILLOW, Species.STARLY, Species.PIDOVE ])), .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEY, Species.HOOTHOOT, Species.TAILLOW, Species.STARLY, Species.PIDOVE ])),
[TrainerType.RIVAL_2]: new TrainerConfig(++t).setStaticParty().setEncounterBgm(TrainerType.RIVAL).setBattleBgm('battle_rival').setPartyTemplates(trainerPartyTemplates.RIVAL_2).setEncounterMessages([ [TrainerType.RIVAL_2]: new TrainerConfig(++t).setStaticParty().setEncounterBgm(TrainerType.RIVAL).setBattleBgm('battle_rival').setPartyTemplates(trainerPartyTemplates.RIVAL_2).setEncounterMessages([
`Oh, fancy meeting you here. Looks like you're still undefeated. Right on! `Oh, fancy meeting you here. Looks like you're still undefeated. Right on!

View File

@ -518,7 +518,7 @@ export class TurnHeldItemTransferModifierType extends PokemonHeldItemModifierTyp
} }
} }
type ModifierTypeFunc = () => ModifierType; export type ModifierTypeFunc = () => ModifierType;
type WeightedModifierTypeWeightFunc = (party: Pokemon[]) => integer; type WeightedModifierTypeWeightFunc = (party: Pokemon[]) => integer;
class WeightedModifierType { class WeightedModifierType {

View File

@ -6,7 +6,8 @@ export enum TextStyle {
PARTY_RED, PARTY_RED,
SUMMARY, SUMMARY,
SUMMARY_RED, SUMMARY_RED,
SUMMARY_GOLD SUMMARY_GOLD,
MONEY
}; };
export function addTextObject(scene: Phaser.Scene, x: number, y: number, content: string, style: TextStyle, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle) { export function addTextObject(scene: Phaser.Scene, x: number, y: number, content: string, style: TextStyle, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle) {
@ -31,8 +32,8 @@ export function addTextObject(scene: Phaser.Scene, x: number, y: number, content
styleOptions.fontSize = '96px'; styleOptions.fontSize = '96px';
break; break;
case TextStyle.BATTLE_INFO: case TextStyle.BATTLE_INFO:
case TextStyle.MONEY:
styleOptions.fontSize = '72px'; styleOptions.fontSize = '72px';
styleOptions.padding = undefined;
shadowSize = 4; shadowSize = 4;
break; break;
case TextStyle.PARTY: case TextStyle.PARTY:
@ -77,6 +78,7 @@ export function getTextColor(textStyle: TextStyle, shadow?: boolean) {
case TextStyle.SUMMARY_RED: case TextStyle.SUMMARY_RED:
return !shadow ? '#f89890' : '#984038'; return !shadow ? '#f89890' : '#984038';
case TextStyle.SUMMARY_GOLD: case TextStyle.SUMMARY_GOLD:
case TextStyle.MONEY:
return !shadow ? '#e8e8a8' : '#a0a060' return !shadow ? '#e8e8a8' : '#a0a060'
} }
} }