pokerogue/src/battle.ts

33 lines
1.0 KiB
TypeScript

import { EnemyPokemon, PlayerPokemon } from "./pokemon";
import * as Utils from "./utils";
export class Battle {
public waveIndex: integer;
public enemyLevel: integer;
public enemyPokemon: EnemyPokemon;
public playerParticipantIds: Set<integer> = new Set<integer>();
constructor(waveIndex: integer) {
this.waveIndex = waveIndex;
this.enemyLevel = this.getLevelForWave();
}
private getLevelForWave(): number {
let baseLevel = 1 + this.waveIndex / 2 + Math.pow(this.waveIndex / 25, 2);
if (!(this.waveIndex % 10))
return Math.floor(baseLevel * 1.2);
const deviation = 10 / this.waveIndex;
return Math.max(Math.round(baseLevel + Math.abs(Utils.randGauss(deviation))), 1);
}
addParticipant(playerPokemon: PlayerPokemon): void {
this.playerParticipantIds.add(playerPokemon.id);
}
removeFaintedParticipant(playerPokemon: PlayerPokemon): void {
this.playerParticipantIds.delete(playerPokemon.id);
}
}