[Docs] add some inline docs for boss segments logic (#2678)

This commit is contained in:
flx-sta 2024-06-27 20:20:42 -07:00 committed by GitHub
parent 4f9bd85f57
commit d5b1459422
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -3398,6 +3398,7 @@ export class EnemyPokemon extends Pokemon {
public aiType: AiType;
public bossSegments: integer;
public bossSegmentIndex: integer;
/** To indicate of the instance was populated with a dataSource -> e.g. loaded & populated from session data */
public readonly isPopulatedFromDataSource: boolean;
constructor(scene: BattleScene, species: PokemonSpecies, level: integer, trainerSlot: TrainerSlot, boss: boolean, dataSource: PokemonData) {
@ -3405,7 +3406,7 @@ export class EnemyPokemon extends Pokemon {
dataSource?.gender, dataSource ? dataSource.shiny : false, dataSource ? dataSource.variant : undefined, null, dataSource ? dataSource.nature : undefined, dataSource);
this.trainerSlot = trainerSlot;
this.isPopulatedFromDataSource = !!dataSource;
this.isPopulatedFromDataSource = !!dataSource; // if a dataSource is provided, then it was populated from dataSource
if (boss) {
this.setBoss(boss, dataSource?.bossSegments);
}
@ -3455,6 +3456,13 @@ export class EnemyPokemon extends Pokemon {
}
}
/**
* Sets the pokemons boss status. If true initializes the boss segments either from the arguments
* or through the the Scene.getEncounterBossSegments function
*
* @param boss if the pokemon is a boss
* @param bossSegments amount of boss segments (health-bar segments)
*/
setBoss(boss: boolean = true, bossSegments: integer = 0): void {
if (boss) {
this.bossSegments = bossSegments || this.scene.getEncounterBossSegments(this.scene.currentBattle.waveIndex, this.level, this.species, true);

View File

@ -868,8 +868,10 @@ export class EncounterPhase extends BattlePhase {
if (battle.battleType === BattleType.TRAINER) {
loadEnemyAssets.push(battle.trainer.loadAssets().then(() => battle.trainer.initSprite()));
} else {
// This block only applies for double battles to init the boss segments (idk why it's split up like this)
if (battle.enemyParty.filter(p => p.isBoss()).length > 1) {
for (const enemyPokemon of battle.enemyParty) {
// If the enemy pokemon is a boss and wasn't populated from data source, then set it up
if (enemyPokemon.isBoss() && !enemyPokemon.isPopulatedFromDataSource) {
enemyPokemon.setBoss(true, Math.ceil(enemyPokemon.bossSegments * (enemyPokemon.getSpeciesForm().baseTotal / totalBst)));
enemyPokemon.initBattleInfo();