replace clamp util function with Phaser function

This commit is contained in:
ImperialSympathizer 2024-10-05 19:06:43 -04:00
parent 138ec00ec0
commit ff37a1021a
5 changed files with 4 additions and 15 deletions

View File

@ -2,7 +2,7 @@ import { Species } from "#enums/species";
import { EggTier } from "#enums/egg-type";
/**
* Map of all starters and their respective {@link EggTier}, which determines which type of egg the starter hatches from.
* Map of all starters and their respective {@linkcode EggTier}, which determines the type of egg the starter hatches from.
*/
export const speciesEggTiers = {
[Species.BULBASAUR]: EggTier.COMMON,

View File

@ -12,7 +12,6 @@ import { Species } from "#enums/species";
import { EggSourceType } from "#enums/egg-source-types";
import { MANAPHY_EGG_MANAPHY_RATE, SAME_SPECIES_EGG_HA_RATE, GACHA_EGG_HA_RATE, GACHA_DEFAULT_RARE_EGGMOVE_RATE, SAME_SPECIES_EGG_RARE_EGGMOVE_RATE, GACHA_MOVE_UP_RARE_EGGMOVE_RATE, GACHA_DEFAULT_SHINY_RATE, GACHA_SHINY_UP_SHINY_RATE, SAME_SPECIES_EGG_SHINY_RATE, EGG_PITY_LEGENDARY_THRESHOLD, EGG_PITY_EPIC_THRESHOLD, EGG_PITY_RARE_THRESHOLD, SHINY_VARIANT_CHANCE, SHINY_EPIC_CHANCE, GACHA_DEFAULT_COMMON_EGG_THRESHOLD, GACHA_DEFAULT_RARE_EGG_THRESHOLD, GACHA_DEFAULT_EPIC_EGG_THRESHOLD, GACHA_LEGENDARY_UP_THRESHOLD_OFFSET, HATCH_WAVES_MANAPHY_EGG, HATCH_WAVES_COMMON_EGG, HATCH_WAVES_RARE_EGG, HATCH_WAVES_EPIC_EGG, HATCH_WAVES_LEGENDARY_EGG } from "#app/data/balance/rates";
import { speciesEggTiers } from "#app/data/balance/species-egg-tiers";
import { clampNumber } from "#app/utils";
export const EGG_SEED = 1073741824;
@ -433,7 +432,7 @@ export class Egg {
const speciesWeights : number[] = [];
for (const speciesId of speciesPool) {
// Accounts for species that have starter costs outside of the normal range for their EggTier
const speciesCostClamped = clampNumber(speciesStarterCosts[speciesId], minStarterValue, maxStarterValue);
const speciesCostClamped = Phaser.Math.Clamp(speciesStarterCosts[speciesId], minStarterValue, maxStarterValue);
let weight = Math.floor((((maxStarterValue - speciesCostClamped) / ((maxStarterValue - minStarterValue) + 1)) * 1.5 + 1) * 100);
const species = getPokemonSpecies(speciesId);
if (species.isRegional()) {

View File

@ -983,7 +983,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.scene.applyModifier(PokemonIncrementingStatModifier, this.isPlayer(), this, s, statHolder);
}
statHolder.value = Utils.clampNumber(statHolder.value, 1, Number.MAX_SAFE_INTEGER);
statHolder.value = Phaser.Math.Clamp(statHolder.value, 1, Number.MAX_SAFE_INTEGER);
this.setStat(s, statHolder.value);
}

View File

@ -593,7 +593,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
};
const updatePokemonHp = () => {
let duration = !instant ? Utils.clampNumber(Math.abs((this.lastHp) - pokemon.hp) * 5, 250, 5000) : 0;
let duration = !instant ? Phaser.Math.Clamp(Math.abs((this.lastHp) - pokemon.hp) * 5, 250, 5000) : 0;
const speed = (this.scene as BattleScene).hpBarSpeed;
if (speed) {
duration = speed >= 3 ? 0 : duration / Math.pow(2, speed);

View File

@ -38,16 +38,6 @@ export function shiftCharCodes(str: string, shiftCount: integer) {
return newStr;
}
/**
* Clamps a number
* @param value
* @param min
* @param max
*/
export function clampNumber(value: number, min: number, max: number): number {
return Math.min(Math.max(value, min), max);
}
export function randGauss(stdev: number, mean: number = 0): number {
if (!stdev) {
return 0;