pokerogue/src/battle.ts

33 lines
992 B
TypeScript
Raw Normal View History

2023-03-30 20:02:35 -07:00
import { EnemyPokemon, PlayerPokemon } from "./pokemon";
2023-03-31 13:04:39 -07:00
import * as Utils from "./utils";
2023-03-30 20:02:35 -07:00
export class Battle {
public waveIndex: integer;
2023-03-31 13:04:39 -07:00
public enemyLevel: integer;
2023-03-30 20:02:35 -07:00
public enemyPokemon: EnemyPokemon;
public playerParticipantIds: Set<integer> = new Set<integer>();
2023-03-31 13:04:39 -07:00
constructor(waveIndex: integer) {
2023-03-30 20:02:35 -07:00
this.waveIndex = waveIndex;
2023-03-31 13:04:39 -07:00
this.enemyLevel = this.getLevelForWave();
2023-03-30 20:02:35 -07:00
}
2023-03-31 13:04:39 -07:00
private getLevelForWave(): number {
let averageLevel = 1 + this.waveIndex * 0.5;
if (!(this.waveIndex % 10))
return Math.floor(averageLevel * 1.25);
const deviation = 10 / this.waveIndex;
return Math.max(Math.round(averageLevel + Utils.randGauss(deviation)), 1);
}
addParticipant(playerPokemon: PlayerPokemon): void {
2023-03-30 20:02:35 -07:00
this.playerParticipantIds.add(playerPokemon.id);
}
2023-03-31 13:04:39 -07:00
removeFaintedParticipant(playerPokemon: PlayerPokemon): void {
2023-03-30 20:02:35 -07:00
this.playerParticipantIds.delete(playerPokemon.id);
}
}