mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-23 06:53:27 +02:00
Make more arrays readonly
This commit is contained in:
parent
6896e9abaa
commit
e938ff608d
@ -6699,7 +6699,7 @@ function getPokemonWithWeatherBasedForms() {
|
||||
|
||||
// biome-ignore format: prevent biome from removing the newlines (e.g. prevent `new Ability(...).attr(...)`)
|
||||
export function initAbilities() {
|
||||
allAbilities.push(
|
||||
(allAbilities as Ability[]).push(
|
||||
new Ability(AbilityId.NONE, 3),
|
||||
new Ability(AbilityId.STENCH, 3)
|
||||
.attr(PostAttackApplyBattlerTagAbAttr, false, (user, target, move) => !move.hasAttr("FlinchAttr") && !move.hitsSubstitute(user, target) ? 10 : 0, BattlerTagType.FLINCHED),
|
||||
|
@ -8,7 +8,7 @@ import { SpeciesId } from "#enums/species-id";
|
||||
|
||||
// biome-ignore format: manually formatted
|
||||
export function initSpecies() {
|
||||
allSpecies.push(
|
||||
(allSpecies as PokemonSpecies[]).push(
|
||||
new PokemonSpecies(SpeciesId.BULBASAUR, 1, false, false, false, "Seed Pokémon", PokemonType.GRASS, PokemonType.POISON, 0.7, 6.9, AbilityId.OVERGROW, AbilityId.NONE, AbilityId.CHLOROPHYLL, 318, 45, 49, 49, 65, 65, 45, 45, 50, 64, GrowthRate.MEDIUM_SLOW, 87.5, false),
|
||||
new PokemonSpecies(SpeciesId.IVYSAUR, 1, false, false, false, "Seed Pokémon", PokemonType.GRASS, PokemonType.POISON, 1, 13, AbilityId.OVERGROW, AbilityId.NONE, AbilityId.CHLOROPHYLL, 405, 60, 62, 63, 80, 80, 60, 45, 50, 142, GrowthRate.MEDIUM_SLOW, 87.5, false),
|
||||
new PokemonSpecies(SpeciesId.VENUSAUR, 1, false, false, false, "Seed Pokémon", PokemonType.GRASS, PokemonType.POISON, 2, 100, AbilityId.OVERGROW, AbilityId.NONE, AbilityId.CHLOROPHYLL, 525, 80, 82, 83, 100, 100, 80, 45, 50, 263, GrowthRate.MEDIUM_SLOW, 87.5, true, true,
|
||||
|
@ -3,9 +3,9 @@ import type { PokemonSpecies } from "#data/pokemon-species";
|
||||
import type { ModifierTypes } from "#modifiers/modifier-type";
|
||||
import type { Move } from "#moves/move";
|
||||
|
||||
export const allAbilities: Ability[] = [];
|
||||
export const allMoves: Move[] = [];
|
||||
export const allSpecies: PokemonSpecies[] = [];
|
||||
export const allAbilities: readonly Ability[] = [];
|
||||
export const allMoves: readonly Move[] = [];
|
||||
export const allSpecies: readonly PokemonSpecies[] = [];
|
||||
|
||||
// TODO: Figure out what this is used for and provide an appropriate tsdoc comment
|
||||
export const modifierTypes = {} as ModifierTypes;
|
||||
|
@ -8394,7 +8394,7 @@ const MoveAttrs = Object.freeze({
|
||||
export type MoveAttrConstructorMap = typeof MoveAttrs;
|
||||
|
||||
export function initMoves() {
|
||||
allMoves.push(
|
||||
(allMoves as Move[]).push(
|
||||
new SelfStatusMove(MoveId.NONE, PokemonType.NORMAL, MoveCategory.STATUS, -1, -1, 0, 1),
|
||||
new AttackMove(MoveId.POUND, PokemonType.NORMAL, MoveCategory.PHYSICAL, 40, 100, 35, -1, 0, 1),
|
||||
new AttackMove(MoveId.KARATE_CHOP, PokemonType.FIGHTING, MoveCategory.PHYSICAL, 50, 100, 25, -1, 0, 1)
|
||||
|
@ -78,7 +78,7 @@ const POOL_1_POKEMON = [
|
||||
SpeciesId.RIBOMBEE,
|
||||
SpeciesId.SPIDOPS,
|
||||
SpeciesId.LOKIX,
|
||||
];
|
||||
] as const;
|
||||
|
||||
const POOL_2_POKEMON = [
|
||||
SpeciesId.SCYTHER,
|
||||
@ -104,41 +104,20 @@ const POOL_2_POKEMON = [
|
||||
SpeciesId.CENTISKORCH,
|
||||
SpeciesId.FROSMOTH,
|
||||
SpeciesId.KLEAVOR,
|
||||
];
|
||||
] as const;
|
||||
|
||||
const POOL_3_POKEMON: { species: SpeciesId; formIndex?: number }[] = [
|
||||
{
|
||||
species: SpeciesId.PINSIR,
|
||||
formIndex: 1,
|
||||
},
|
||||
{
|
||||
species: SpeciesId.SCIZOR,
|
||||
formIndex: 1,
|
||||
},
|
||||
{
|
||||
species: SpeciesId.HERACROSS,
|
||||
formIndex: 1,
|
||||
},
|
||||
{
|
||||
species: SpeciesId.ORBEETLE,
|
||||
formIndex: 1,
|
||||
},
|
||||
{
|
||||
species: SpeciesId.CENTISKORCH,
|
||||
formIndex: 1,
|
||||
},
|
||||
{
|
||||
species: SpeciesId.DURANT,
|
||||
},
|
||||
{
|
||||
species: SpeciesId.VOLCARONA,
|
||||
},
|
||||
{
|
||||
species: SpeciesId.GOLISOPOD,
|
||||
},
|
||||
];
|
||||
const POOL_3_POKEMON = [
|
||||
{ species: SpeciesId.PINSIR, formIndex: 1 },
|
||||
{ species: SpeciesId.SCIZOR, formIndex: 1 },
|
||||
{ species: SpeciesId.HERACROSS, formIndex: 1 },
|
||||
{ species: SpeciesId.ORBEETLE, formIndex: 1 },
|
||||
{ species: SpeciesId.CENTISKORCH, formIndex: 1 },
|
||||
{ species: SpeciesId.DURANT } as { species: SpeciesId.DURANT; formIndex: undefined },
|
||||
{ species: SpeciesId.VOLCARONA } as { species: SpeciesId.VOLCARONA; formIndex: undefined },
|
||||
{ species: SpeciesId.GOLISOPOD } as { species: SpeciesId.GOLISOPOD; formIndex: undefined },
|
||||
] as const;
|
||||
|
||||
const POOL_4_POKEMON = [SpeciesId.GENESECT, SpeciesId.SLITHER_WING, SpeciesId.BUZZWOLE, SpeciesId.PHEROMOSA];
|
||||
const POOL_4_POKEMON = [SpeciesId.GENESECT, SpeciesId.SLITHER_WING, SpeciesId.BUZZWOLE, SpeciesId.PHEROMOSA] as const;
|
||||
|
||||
const PHYSICAL_TUTOR_MOVES = [
|
||||
MoveId.MEGAHORN,
|
||||
@ -146,7 +125,7 @@ const PHYSICAL_TUTOR_MOVES = [
|
||||
MoveId.BUG_BITE,
|
||||
MoveId.FIRST_IMPRESSION,
|
||||
MoveId.LUNGE,
|
||||
];
|
||||
] as const;
|
||||
|
||||
const SPECIAL_TUTOR_MOVES = [
|
||||
MoveId.SILVER_WIND,
|
||||
@ -154,7 +133,7 @@ const SPECIAL_TUTOR_MOVES = [
|
||||
MoveId.BUG_BUZZ,
|
||||
MoveId.POLLEN_PUFF,
|
||||
MoveId.STRUGGLE_BUG,
|
||||
];
|
||||
] as const;
|
||||
|
||||
const STATUS_TUTOR_MOVES = [
|
||||
MoveId.STRING_SHOT,
|
||||
@ -162,14 +141,20 @@ const STATUS_TUTOR_MOVES = [
|
||||
MoveId.RAGE_POWDER,
|
||||
MoveId.STICKY_WEB,
|
||||
MoveId.SILK_TRAP,
|
||||
];
|
||||
] as const;
|
||||
|
||||
const MISC_TUTOR_MOVES = [MoveId.LEECH_LIFE, MoveId.U_TURN, MoveId.HEAL_ORDER, MoveId.QUIVER_DANCE, MoveId.INFESTATION];
|
||||
const MISC_TUTOR_MOVES = [
|
||||
MoveId.LEECH_LIFE,
|
||||
MoveId.U_TURN,
|
||||
MoveId.HEAL_ORDER,
|
||||
MoveId.QUIVER_DANCE,
|
||||
MoveId.INFESTATION,
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Wave breakpoints that determine how strong to make the Bug-Type Superfan's team
|
||||
*/
|
||||
const WAVE_LEVEL_BREAKPOINTS = [30, 50, 70, 100, 120, 140, 160];
|
||||
const WAVE_LEVEL_BREAKPOINTS = [30, 50, 70, 100, 120, 140, 160] as const;
|
||||
|
||||
/**
|
||||
* Bug Type Superfan encounter.
|
||||
@ -517,8 +502,8 @@ function getTrainerConfigForWave(waveIndex: number) {
|
||||
const config = trainerConfigs[TrainerType.BUG_TYPE_SUPERFAN].clone();
|
||||
config.name = i18next.t("trainerNames:bugTypeSuperfan");
|
||||
|
||||
let pool3Copy = POOL_3_POKEMON.slice(0);
|
||||
pool3Copy = randSeedShuffle(pool3Copy);
|
||||
const pool3Copy = randSeedShuffle(POOL_3_POKEMON.slice());
|
||||
// Bang is fine here, as we know pool3Copy has at least 1 entry
|
||||
const pool3Mon = pool3Copy.pop()!;
|
||||
|
||||
if (waveIndex < WAVE_LEVEL_BREAKPOINTS[0]) {
|
||||
@ -579,7 +564,6 @@ function getTrainerConfigForWave(waveIndex: number) {
|
||||
}),
|
||||
);
|
||||
} else if (waveIndex < WAVE_LEVEL_BREAKPOINTS[5]) {
|
||||
pool3Copy = randSeedShuffle(pool3Copy);
|
||||
const pool3Mon2 = pool3Copy.pop()!;
|
||||
config
|
||||
.setPartyTemplates(new TrainerPartyTemplate(5, PartyMemberStrength.AVERAGE))
|
||||
@ -657,7 +641,6 @@ function getTrainerConfigForWave(waveIndex: number) {
|
||||
)
|
||||
.setPartyMemberFunc(4, getRandomPartyMemberFunc(POOL_4_POKEMON, TrainerSlot.TRAINER, true));
|
||||
} else {
|
||||
pool3Copy = randSeedShuffle(pool3Copy);
|
||||
const pool3Mon2 = pool3Copy.pop()!;
|
||||
config
|
||||
.setPartyTemplates(
|
||||
|
@ -35,7 +35,7 @@ export class SpeciesFormChange {
|
||||
public formKey: string;
|
||||
public trigger: SpeciesFormChangeTrigger;
|
||||
public quiet: boolean;
|
||||
public readonly conditions: SpeciesFormChangeCondition[];
|
||||
public readonly conditions: readonly SpeciesFormChangeCondition[];
|
||||
|
||||
constructor(
|
||||
speciesId: SpeciesId,
|
||||
|
@ -1000,7 +1000,7 @@ let t = 0;
|
||||
* @param postProcess
|
||||
*/
|
||||
export function getRandomPartyMemberFunc(
|
||||
speciesPool: SpeciesId[],
|
||||
speciesPool: readonly SpeciesId[],
|
||||
trainerSlot: TrainerSlot = TrainerSlot.TRAINER,
|
||||
ignoreEvolution = false,
|
||||
postProcess?: (enemyPokemon: EnemyPokemon) => void,
|
||||
|
@ -588,7 +588,7 @@ export class Arena {
|
||||
overrideTint(): [number, number, number] {
|
||||
switch (Overrides.ARENA_TINT_OVERRIDE) {
|
||||
case TimeOfDay.DUSK:
|
||||
return [98, 48, 73].map(c => Math.round((c + 128) / 2)) as [number, number, number];
|
||||
return [113, 88, 101];
|
||||
case TimeOfDay.NIGHT:
|
||||
return [64, 64, 64];
|
||||
case TimeOfDay.DAWN:
|
||||
|
@ -132,20 +132,16 @@ export function randSeedItem<T>(items: ArrayLike<T>): T {
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuffle a list using the seeded rng. Utilises the Fisher-Yates algorithm.
|
||||
* Shuffle a list in place using the seeded rng and the Fisher-Yates algorithm.
|
||||
* @param items An array of items.
|
||||
* @returns A new shuffled array of items.
|
||||
* @returns `items` shuffled in place.
|
||||
*/
|
||||
export function randSeedShuffle<T>(items: T[]): T[] {
|
||||
if (items.length <= 1) {
|
||||
return items;
|
||||
}
|
||||
const newArray = items.slice(0);
|
||||
for (let i = items.length - 1; i > 0; i--) {
|
||||
const j = Phaser.Math.RND.integerInRange(0, i);
|
||||
[newArray[i], newArray[j]] = [newArray[j], newArray[i]];
|
||||
[items[i], items[j]] = [items[j], items[i]];
|
||||
}
|
||||
return newArray;
|
||||
return items;
|
||||
}
|
||||
|
||||
export function getFrameMs(frameCount: number): number {
|
||||
@ -338,7 +334,7 @@ export function rgbToHsv(r: number, g: number, b: number) {
|
||||
* @param rgb1 First RGB color in array
|
||||
* @param rgb2 Second RGB color in array
|
||||
*/
|
||||
export function deltaRgb(rgb1: number[], rgb2: number[]): number {
|
||||
export function deltaRgb(rgb1: readonly number[], rgb2: readonly number[]): number {
|
||||
const [r1, g1, b1] = rgb1;
|
||||
const [r2, g2, b2] = rgb2;
|
||||
const drp2 = Math.pow(r1 - r2, 2);
|
||||
@ -362,7 +358,7 @@ export function rgbHexToRgba(hex: string) {
|
||||
};
|
||||
}
|
||||
|
||||
export function rgbaToInt(rgba: number[]): number {
|
||||
export function rgbaToInt(rgba: readonly number[]): number {
|
||||
return (rgba[0] << 24) + (rgba[1] << 16) + (rgba[2] << 8) + rgba[3];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user