Add lower level limit to legendaries

pull/1/head
Flashfyre 2023-04-20 01:04:36 -04:00
parent 14c792506f
commit ebff806dbd
2 changed files with 30 additions and 4 deletions

View File

@ -25,7 +25,7 @@ export class Arena {
this.pokemonPool = biomePools[biome];
}
randomSpecies(waveIndex: integer, level: integer): PokemonSpecies {
randomSpecies(waveIndex: integer, level: integer, attempt?: integer): PokemonSpecies {
const isBoss = (waveIndex >= 100 || waveIndex % 10 === 0) && !!this.pokemonPool[BiomePoolTier.BOSS].length;
const tierValue = Utils.randInt(!isBoss ? 512 : 64);
let tier = !isBoss
@ -38,6 +38,7 @@ export class Arena {
}
const tierPool = this.pokemonPool[tier];
let ret: PokemonSpecies;
let regen = false;
if (!tierPool.length)
ret = this.scene.randomSpecies(waveIndex, level);
else {
@ -61,7 +62,30 @@ export class Arena {
}
ret = getPokemonSpecies(species);
if (ret.legendary || ret.pseudoLegendary || ret.mythical) {
switch (true) {
case (ret.baseTotal >= 720):
regen = level < 90;
break;
case (ret.baseTotal >= 670):
regen = level < 70;
break;
case (ret.baseTotal >= 580):
regen = level < 50;
break;
default:
regen = level < 30;
break;
}
}
}
if (regen && (attempt || 0) < 10) {
console.log('Incompatible level: regenerating...');
return this.randomSpecies(waveIndex, level, (attempt || 0) + 1);
}
const newSpeciesId = ret.getSpeciesForLevel(level);
if (newSpeciesId !== ret.speciesId) {
console.log('Replaced', Species[ret.speciesId], 'with', Species[newSpeciesId]);
@ -102,8 +126,6 @@ export class Arena {
if (this.weather?.weatherType === (weather || undefined))
return false;
console.log('set weather', WeatherType[weather]);
const oldWeatherType = this.weather?.weatherType || WeatherType.NONE;
this.weather = weather ? new Weather(weather, viaMove ? 5 : 0) : null;

View File

@ -239,6 +239,10 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
}
},
onComplete: () => {
if (!this.scene) {
resolve();
return;
}
if (duration)
this.scene.sound.stopByKey('exp');
if (ratio === 1) {
@ -270,7 +274,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
}
setHpNumbers(hp: integer, maxHp: integer) {
if (!this.player)
if (!this.player || !this.scene)
return;
this.hpNumbersContainer.removeAll(true);
const hpStr = hp.toString();