mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 09:02:47 +02:00
Changes to the summary ui handler
This commit is contained in:
parent
301db8a1de
commit
6fb85ea742
@ -1,6 +1,8 @@
|
||||
import { formChangeItemName } from "#app/data/pokemon-forms";
|
||||
import type Pokemon from "#app/field/pokemon";
|
||||
import { globalScene } from "#app/global-scene";
|
||||
import { allHeldItems } from "#app/items/all-held-items";
|
||||
import type { FormChangeItem } from "#enums/form-change-item";
|
||||
import type { HeldItemId } from "#enums/held-item-id";
|
||||
import type { Modifier, PersistentModifier } from "./modifier";
|
||||
|
||||
@ -30,6 +32,19 @@ export const heldItemSortFunc = (a: HeldItemId, b: HeldItemId): number => {
|
||||
return itemIdMatch;
|
||||
};
|
||||
|
||||
export const formChangeItemSortFunc = (a: FormChangeItem, b: FormChangeItem): number => {
|
||||
const nameA = formChangeItemName(a);
|
||||
const nameB = formChangeItemName(b);
|
||||
const itemNameMatch = nameA.localeCompare(nameB);
|
||||
const itemIdMatch = a - b;
|
||||
|
||||
if (itemIdMatch === 0) {
|
||||
return itemNameMatch;
|
||||
//Finally sort by item name
|
||||
}
|
||||
return itemIdMatch;
|
||||
};
|
||||
|
||||
export class ModifierBar extends Phaser.GameObjects.Container {
|
||||
private player: boolean;
|
||||
private modifierCache: (PersistentModifier | HeldItemId)[];
|
||||
|
@ -25,7 +25,6 @@ import { MoveCategory } from "#enums/MoveCategory";
|
||||
import { getPokeballAtlasKey } from "#app/data/pokeball";
|
||||
import { getGenderColor, getGenderSymbol } from "#app/data/gender";
|
||||
import { getLevelRelExp, getLevelTotalExp } from "#app/data/exp";
|
||||
import { PokemonHeldItemModifier } from "#app/modifier/modifier";
|
||||
import { StatusEffect } from "#enums/status-effect";
|
||||
import { getBiomeName } from "#app/data/balance/biomes";
|
||||
import { getNatureName, getNatureStatMultiplier } from "#app/data/nature";
|
||||
@ -35,7 +34,7 @@ import { getVariantTint } from "#app/sprites/variant";
|
||||
import { Button } from "#enums/buttons";
|
||||
import type { Ability } from "#app/data/abilities/ability-class";
|
||||
import i18next from "i18next";
|
||||
import { modifierSortFunc } from "#app/modifier/modifier-bar";
|
||||
import { heldItemSortFunc } from "#app/modifier/modifier-bar";
|
||||
import { PlayerGender } from "#enums/player-gender";
|
||||
import { Stat, PERMANENT_STATS, getStatKey } from "#enums/stat";
|
||||
import { Nature } from "#enums/nature";
|
||||
@ -1033,31 +1032,9 @@ export default class SummaryUiHandler extends UiHandler {
|
||||
});
|
||||
this.ivContainer.setVisible(false);
|
||||
|
||||
const itemModifiers = (
|
||||
globalScene.findModifiers(
|
||||
m => m instanceof PokemonHeldItemModifier && m.pokemonId === this.pokemon?.id,
|
||||
this.playerParty,
|
||||
) as PokemonHeldItemModifier[]
|
||||
).sort(modifierSortFunc);
|
||||
const heldItems = this.pokemon?.getHeldItems().sort(heldItemSortFunc);
|
||||
|
||||
itemModifiers.forEach((item, i) => {
|
||||
const icon = item.getIcon(true);
|
||||
|
||||
icon.setPosition((i % 17) * 12 + 3, 14 * Math.floor(i / 17) + 15);
|
||||
this.statsContainer.add(icon);
|
||||
|
||||
icon.setInteractive(new Phaser.Geom.Rectangle(0, 0, 32, 32), Phaser.Geom.Rectangle.Contains);
|
||||
icon.on("pointerover", () => globalScene.ui.showTooltip(item.type.name, item.type.getDescription(), true));
|
||||
icon.on("pointerout", () => globalScene.ui.hideTooltip());
|
||||
});
|
||||
|
||||
const heldItemKeys = this.pokemon?.heldItemManager.getHeldItems();
|
||||
// TODO: Sort them
|
||||
//.sort(heldItemSortFunc);
|
||||
|
||||
console.log(heldItemKeys);
|
||||
|
||||
heldItemKeys?.forEach((itemKey, i) => {
|
||||
heldItems?.forEach((itemKey, i) => {
|
||||
const stack = this.pokemon?.heldItemManager.getStack(itemKey);
|
||||
const heldItem = allHeldItems[itemKey];
|
||||
const icon = heldItem.createSummaryIcon(stack);
|
||||
@ -1070,7 +1047,22 @@ export default class SummaryUiHandler extends UiHandler {
|
||||
icon.on("pointerover", () => globalScene.ui.showTooltip(heldItem.getName(), heldItem.getDescription(), true));
|
||||
icon.on("pointerout", () => globalScene.ui.hideTooltip());
|
||||
});
|
||||
/*
|
||||
const formChangeItems = this.pokemon?.heldItemManager.getFormChangeItems().sort(formChangeItemSortFunc);
|
||||
|
||||
//TODO: Make an equivalent function for form change items
|
||||
formChangeItems?.forEach((itemKey, i) => {
|
||||
const icon = heldItem.createSummaryIcon(stack);
|
||||
|
||||
console.log(icon);
|
||||
icon.setPosition((i % 17) * 12 + 3, 14 * Math.floor(i / 17) + 15);
|
||||
this.statsContainer.add(icon);
|
||||
|
||||
icon.setInteractive(new Phaser.Geom.Rectangle(0, 0, 32, 32), Phaser.Geom.Rectangle.Contains);
|
||||
icon.on("pointerover", () => globalScene.ui.showTooltip(heldItem.getName(), heldItem.getDescription(), true));
|
||||
icon.on("pointerout", () => globalScene.ui.hideTooltip());
|
||||
});
|
||||
*/
|
||||
const pkmLvl = this.pokemon?.level!; // TODO: is this bang correct?
|
||||
const pkmLvlExp = this.pokemon?.levelExp!; // TODO: is this bang correct?
|
||||
const pkmExp = this.pokemon?.exp!; // TODO: is this bang correct?
|
||||
|
Loading…
Reference in New Issue
Block a user