mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 16:02:20 +02:00
Moved sort function in the modifier bar
This commit is contained in:
parent
604c216e12
commit
50372df550
@ -1986,27 +1986,3 @@ export function overrideHeldItems(pokemon: Pokemon, isPlayer = true): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const modifierSortFunc = (a: Modifier, b: Modifier): number => {
|
|
||||||
const itemNameMatch = a.type.name.localeCompare(b.type.name);
|
|
||||||
const typeNameMatch = a.constructor.name.localeCompare(b.constructor.name);
|
|
||||||
const aId = a instanceof PokemonHeldItemModifier && a.pokemonId ? a.pokemonId : 4294967295;
|
|
||||||
const bId = b instanceof PokemonHeldItemModifier && b.pokemonId ? b.pokemonId : 4294967295;
|
|
||||||
|
|
||||||
//First sort by pokemonID
|
|
||||||
if (aId < bId) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (aId > bId) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (aId === bId) {
|
|
||||||
//Then sort by item type
|
|
||||||
if (typeNameMatch === 0) {
|
|
||||||
return itemNameMatch;
|
|
||||||
//Finally sort by item name
|
|
||||||
}
|
|
||||||
return typeNameMatch;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { globalScene } from "#app/global-scene";
|
import { globalScene } from "#app/global-scene";
|
||||||
import { modifierSortFunc, type PokemonHeldItemModifier } from "./held-item-modifier";
|
import { PokemonHeldItemModifier } from "./held-item-modifier";
|
||||||
import type { PersistentModifier } from "./modifier";
|
import type { Modifier, PersistentModifier } from "./modifier";
|
||||||
|
|
||||||
const iconOverflowIndex = 24;
|
const iconOverflowIndex = 24;
|
||||||
|
|
||||||
@ -80,3 +80,27 @@ export class ModifierBar extends Phaser.GameObjects.Container {
|
|||||||
icon.setPosition(this.player ? x : -x, y);
|
icon.setPosition(this.player ? x : -x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const modifierSortFunc = (a: Modifier, b: Modifier): number => {
|
||||||
|
const itemNameMatch = a.type.name.localeCompare(b.type.name);
|
||||||
|
const typeNameMatch = a.constructor.name.localeCompare(b.constructor.name);
|
||||||
|
const aId = a instanceof PokemonHeldItemModifier && a.pokemonId ? a.pokemonId : 4294967295;
|
||||||
|
const bId = b instanceof PokemonHeldItemModifier && b.pokemonId ? b.pokemonId : 4294967295;
|
||||||
|
|
||||||
|
//First sort by pokemonID
|
||||||
|
if (aId < bId) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (aId > bId) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (aId === bId) {
|
||||||
|
//Then sort by item type
|
||||||
|
if (typeNameMatch === 0) {
|
||||||
|
return itemNameMatch;
|
||||||
|
//Finally sort by item name
|
||||||
|
}
|
||||||
|
return typeNameMatch;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
@ -27,7 +27,8 @@ import { SettingKeyboard } from "#app/system/settings/settings-keyboard";
|
|||||||
import { getBiomeName } from "#app/data/balance/biomes";
|
import { getBiomeName } from "#app/data/balance/biomes";
|
||||||
import type { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
import type { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||||
import { globalScene } from "#app/global-scene";
|
import { globalScene } from "#app/global-scene";
|
||||||
import { modifierSortFunc, PokemonHeldItemModifier } from "#app/modifier/held-item-modifier";
|
import { PokemonHeldItemModifier } from "#app/modifier/held-item-modifier";
|
||||||
|
import { modifierSortFunc } from "#app/modifier/modifier-bar";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RunInfoUiMode indicates possible overlays of RunInfoUiHandler.
|
* RunInfoUiMode indicates possible overlays of RunInfoUiHandler.
|
||||||
|
@ -37,7 +37,8 @@ import { PlayerGender } from "#enums/player-gender";
|
|||||||
import { Stat, PERMANENT_STATS, getStatKey } from "#enums/stat";
|
import { Stat, PERMANENT_STATS, getStatKey } from "#enums/stat";
|
||||||
import { Nature } from "#enums/nature";
|
import { Nature } from "#enums/nature";
|
||||||
import { achvs } from "#app/system/achv";
|
import { achvs } from "#app/system/achv";
|
||||||
import { modifierSortFunc, PokemonHeldItemModifier } from "#app/modifier/held-item-modifier";
|
import { PokemonHeldItemModifier } from "#app/modifier/held-item-modifier";
|
||||||
|
import { modifierSortFunc } from "#app/modifier/modifier-bar";
|
||||||
|
|
||||||
enum Page {
|
enum Page {
|
||||||
PROFILE,
|
PROFILE,
|
||||||
|
Loading…
Reference in New Issue
Block a user