Add golden egg every 10 waves for exp balancing

pull/1/head
Flashfyre 2023-03-30 00:13:56 -04:00
parent 7e3cde77be
commit 807bf9da8c
5 changed files with 51 additions and 23 deletions

View File

@ -77,7 +77,7 @@ export function initAutoPlay(speed: number) {
} }
if (bestPartyMemberIndex === -1) { if (bestPartyMemberIndex === -1) {
let highestHpValue = 0; let highestHpValue = -1;
for (let p = 0; p < party.length; p++) { for (let p = 0; p < party.length; p++) {
const pokemon = party[p]; const pokemon = party[p];
if (pokemon.hp > highestHpValue) { if (pokemon.hp > highestHpValue) {
@ -135,10 +135,10 @@ export function initAutoPlay(speed: number) {
console.log('Switching to ', Species[thisArg.getParty()[bestPartyMemberIndex].species.speciesId]); console.log('Switching to ', Species[thisArg.getParty()[bestPartyMemberIndex].species.speciesId]);
nextPartyMemberIndex = bestPartyMemberIndex; nextPartyMemberIndex = bestPartyMemberIndex;
commandUiHandler.setCursor(2); commandUiHandler.setCursor(2);
this.processInput(keyCodes.Z); thisArg.time.delayedCall(20, () => this.processInput(keyCodes.Z));
} else { } else {
commandUiHandler.setCursor(0); commandUiHandler.setCursor(0);
this.processInput(keyCodes.Z); thisArg.time.delayedCall(20, () => this.processInput(keyCodes.Z));
} }
}; };
@ -150,7 +150,7 @@ export function initAutoPlay(speed: number) {
thisArg.time.delayedCall(20, () => { thisArg.time.delayedCall(20, () => {
const nextMove = playerPokemon.getNextMove() as PokemonMove; const nextMove = playerPokemon.getNextMove() as PokemonMove;
fightUiHandler.setCursor(playerPokemon.moveset.indexOf(nextMove)); fightUiHandler.setCursor(playerPokemon.moveset.indexOf(nextMove));
this.processInput(keyCodes.Z); thisArg.time.delayedCall(20, () => this.processInput(keyCodes.Z));
}); });
}; };
@ -174,7 +174,7 @@ export function initAutoPlay(speed: number) {
if (bestPartyMemberIndex) if (bestPartyMemberIndex)
nextPartyMemberIndex = bestPartyMemberIndex; nextPartyMemberIndex = bestPartyMemberIndex;
switchCheckUiHandler.setCursor(bestPartyMemberIndex ? 1 : 0); switchCheckUiHandler.setCursor(bestPartyMemberIndex ? 1 : 0);
this.processInput(keyCodes.Z); thisArg.time.delayedCall(20, () => this.processInput(keyCodes.Z));
}); });
} }
@ -210,7 +210,7 @@ export function initAutoPlay(speed: number) {
return true; return true;
} }
} else if (criticalHpPartyMemberIndex > -1){ } else if (criticalHpPartyMemberIndex > -1){
nextPartyMemberIndex = faintedPartyMemberIndex; nextPartyMemberIndex = criticalHpPartyMemberIndex;
return true; return true;
} }
} }

View File

@ -6,9 +6,9 @@ import { Mode } from './ui/ui';
import { Command } from "./ui/command-ui-handler"; import { Command } from "./ui/command-ui-handler";
import { interp } from "./temp_interpreter"; import { interp } from "./temp_interpreter";
import { Stat } from "./pokemon-stat"; import { Stat } from "./pokemon-stat";
import { ExpBoosterModifier, getNewModifierType, ModifierType, PokemonBaseStatModifier, PokemonModifierType, regenerateModifierPoolThresholds } from "./modifier"; import { ExpBoosterModifier, getNewModifierType, getNewModifierTypes as getModifierTypesForWave, ModifierType, PokemonBaseStatModifier, PokemonModifierType, regenerateModifierPoolThresholds } from "./modifier";
import PartyUiHandler from "./ui/party-ui-handler"; import PartyUiHandler from "./ui/party-ui-handler";
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getTintColor as getPokeballTintColor, PokeballType } from "./pokeball"; import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor as getPokeballTintColor, PokeballType } from "./pokeball";
import { pokemonLevelMoves } from "./pokemon-level-moves"; import { pokemonLevelMoves } from "./pokemon-level-moves";
export class BattlePhase { export class BattlePhase {
@ -339,6 +339,8 @@ abstract class MovePhase extends BattlePhase {
} }
start() { start() {
super.start();
if (!this.canMove()) { if (!this.canMove()) {
this.end(); this.end();
return; return;
@ -381,6 +383,8 @@ abstract class MoveEffectPhase extends PokemonPhase {
} }
start() { start() {
super.start();
this.getTargetPokemon().apply(this.getUserPokemon(), this.move, () => this.end()); this.getTargetPokemon().apply(this.getUserPokemon(), this.move, () => this.end());
if (this.getTargetPokemon().hp <= 0) { if (this.getTargetPokemon().hp <= 0) {
this.scene.pushPhase(new FaintPhase(this.scene, !this.player)); this.scene.pushPhase(new FaintPhase(this.scene, !this.player));
@ -757,9 +761,7 @@ export class SelectModifierPhase extends BattlePhase {
super.start(); super.start();
regenerateModifierPoolThresholds(this.scene.getParty()); regenerateModifierPoolThresholds(this.scene.getParty());
const types: Array<ModifierType> = []; const types: Array<ModifierType> = getModifierTypesForWave(this.scene.waveIndex, 3);
for (let mt = 0; mt < 3; mt++)
types.push(getNewModifierType(this.scene.waveIndex));
this.scene.ui.setMode(Mode.MODIFIER_SELECT, types, (cursor: integer) => { this.scene.ui.setMode(Mode.MODIFIER_SELECT, types, (cursor: integer) => {
if (cursor < 0) { if (cursor < 0) {

View File

@ -239,25 +239,31 @@ export class PokemonHpRestoreModifier extends ConsumablePokemonModifier {
} }
export class ExpBoosterModifier extends Modifier { export class ExpBoosterModifier extends Modifier {
constructor(type: ModifierType) { private boostMultiplier: integer;
constructor(type: ModifierType, boostPercent: integer) {
super(type); super(type);
this.boostMultiplier = boostPercent * 0.01;
} }
add(modifierBar: ModifierBar, modifiers: Modifier[]): boolean { add(modifierBar: ModifierBar, modifiers: Modifier[]): boolean {
for (let modifier of modifiers) { for (let modifier of modifiers) {
if (modifier instanceof ExpBoosterModifier) { if (modifier instanceof ExpBoosterModifier) {
const expModifier = modifier as ExpBoosterModifier; const expModifier = modifier as ExpBoosterModifier;
if (expModifier.boostMultiplier === this.boostMultiplier) {
expModifier.incrementStack(); expModifier.incrementStack();
modifierBar.updateModifier(expModifier, modifiers); modifierBar.updateModifier(expModifier, modifiers);
return true; return true;
} }
} }
}
return super.add(modifierBar, modifiers); return super.add(modifierBar, modifiers);
} }
apply(args: any[]): boolean { apply(args: any[]): boolean {
(args[0] as Utils.IntegerHolder).value = Math.floor((args[0] as Utils.IntegerHolder).value * (1 + (this.stackCount * 0.25))); (args[0] as Utils.IntegerHolder).value = Math.floor((args[0] as Utils.IntegerHolder).value * (1 + (this.stackCount * (this.boostMultiplier))));
return true; return true;
} }
@ -292,7 +298,8 @@ export enum ModifierTier {
COMMON, COMMON,
GREAT, GREAT,
ULTRA, ULTRA,
MASTER MASTER,
LUXURY
}; };
export class ModifierType { export class ModifierType {
@ -378,6 +385,12 @@ class AllPokemonFullHpRestoreModifierType extends ModifierType {
} }
} }
class ExpBoosterModifierType extends ModifierType {
constructor(name: string, boostPercent: integer, iconImage?: string) {
super(name, `Increases gain of EXP. Points by ${boostPercent}%`, () => new ExpBoosterModifier(this, boostPercent), iconImage);
}
}
class WeightedModifierType { class WeightedModifierType {
public modifierType: ModifierType; public modifierType: ModifierType;
public weight: integer | Function; public weight: integer | Function;
@ -428,12 +441,15 @@ const modifierPool = {
const thresholdPartyMemberCount = party.filter(p => p.getHpRatio() <= 0.5).length; const thresholdPartyMemberCount = party.filter(p => p.getHpRatio() <= 0.5).length;
return Math.ceil(thresholdPartyMemberCount / 3); return Math.ceil(thresholdPartyMemberCount / 3);
}), }),
new ModifierType('LUCKY EGG', 'Increases gain of EXP. Points by 25%', (type, _args) => new ExpBoosterModifier(type)) new ExpBoosterModifierType('LUCKY EGG', 25)
].map(m => { m.setTier(ModifierTier.ULTRA); return m; }), ].map(m => { m.setTier(ModifierTier.ULTRA); return m; }),
[ModifierTier.MASTER]: [ [ModifierTier.MASTER]: [
new AddPokeballModifierType(PokeballType.MASTER_BALL, 1, 'mb'), new AddPokeballModifierType(PokeballType.MASTER_BALL, 1, 'mb'),
new WeightedModifierType(new ModifierType('SHINY CHARM', 'Dramatically increases the chance of a wild POkéMON being shiny', (type, _args) => new ShinyRateBoosterModifier(type)), 2) new WeightedModifierType(new ModifierType('SHINY CHARM', 'Dramatically increases the chance of a wild POkéMON being shiny', (type, _args) => new ShinyRateBoosterModifier(type)), 2)
].map(m => { m.setTier(ModifierTier.MASTER); return m; }) ].map(m => { m.setTier(ModifierTier.MASTER); return m; }),
[ModifierTier.LUXURY]: [
new ExpBoosterModifierType('GOLDEN EGG', 100)
].map(m => { m.setTier(ModifierTier.LUXURY); return m; }),
}; };
let modifierPoolThresholds = {}; let modifierPoolThresholds = {};
@ -467,7 +483,16 @@ export function regenerateModifierPoolThresholds(party: Array<PlayerPokemon>) {
console.log(modifierPoolThresholds) console.log(modifierPoolThresholds)
} }
export function getNewModifierType(): ModifierType { export function getNewModifierTypes(waveIndex: integer, count: integer): Array<ModifierType> {
if (waveIndex % 10 === 0)
return modifierPool[ModifierTier.LUXURY];
const ret = [];
for (let m = 0; m < count; m++)
ret.push(getNewModifierType());
return ret;
}
function getNewModifierType() {
const tierValue = Utils.randInt(256); const tierValue = Utils.randInt(256);
const tier = tierValue >= 52 ? ModifierTier.COMMON : tierValue >= 8 ? ModifierTier.GREAT : tierValue >= 1 ? ModifierTier.ULTRA : ModifierTier.MASTER; const tier = tierValue >= 52 ? ModifierTier.COMMON : tierValue >= 8 ? ModifierTier.GREAT : tierValue >= 1 ? ModifierTier.ULTRA : ModifierTier.MASTER;
const thresholds = Object.keys(modifierPoolThresholds[tier]); const thresholds = Object.keys(modifierPoolThresholds[tier]);

View File

@ -61,7 +61,7 @@ export function getPokeballCatchMultiplier(type: PokeballType): number {
} }
} }
export function getTintColor(type: PokeballType): number { export function getPokeballTintColor(type: PokeballType): number {
switch (type) { switch (type) {
case PokeballType.POKEBALL: case PokeballType.POKEBALL:
return 0xd52929; return 0xd52929;

View File

@ -1,4 +1,3 @@
import { SwitchPhase, SwitchSummonPhase } from "../battle-phase";
import BattleScene from "../battle-scene"; import BattleScene from "../battle-scene";
import { ModifierTier, ModifierType } from "../modifier"; import { ModifierTier, ModifierType } from "../modifier";
import { getPokeballAtlasKey, PokeballType } from "../pokeball"; import { getPokeballAtlasKey, PokeballType } from "../pokeball";
@ -279,7 +278,7 @@ class ModifierOption extends Phaser.GameObjects.Container {
} }
getPbAtlasKey() { getPbAtlasKey() {
return getPokeballAtlasKey(this.modifierType.tier as unknown as PokeballType); return getPokeballAtlasKey(this.modifierType.tier as integer as PokeballType);
} }
getTextTint(): integer { getTextTint(): integer {
@ -292,6 +291,8 @@ class ModifierOption extends Phaser.GameObjects.Container {
return 0xf8d038 return 0xf8d038
case ModifierTier.MASTER: case ModifierTier.MASTER:
return 0xe020c0; return 0xe020c0;
case ModifierTier.LUXURY:
return 0xe64a18;
} }
} }
} }