mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-01 14:02:18 +02:00
Held items now show up in summary
This commit is contained in:
parent
d728052c28
commit
28c04877db
@ -22,6 +22,10 @@ export class PokemonItemManager {
|
|||||||
return this.heldItems;
|
return this.heldItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getHeldItemKeys(): number[] {
|
||||||
|
return Object.keys(this.heldItems).map(k => Number(k));
|
||||||
|
}
|
||||||
|
|
||||||
hasItem(itemType: HeldItems): boolean {
|
hasItem(itemType: HeldItems): boolean {
|
||||||
return itemType in this.getHeldItems();
|
return itemType in this.getHeldItems();
|
||||||
}
|
}
|
||||||
@ -31,6 +35,10 @@ export class PokemonItemManager {
|
|||||||
return this.heldItems[itemType];
|
return this.heldItems[itemType];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getStack(itemType: HeldItems): number {
|
||||||
|
return itemType in this.getHeldItems() ? this.heldItems[itemType].stack : 0;
|
||||||
|
}
|
||||||
|
|
||||||
addHeldItem(itemType: HeldItems, addStack = 1) {
|
addHeldItem(itemType: HeldItems, addStack = 1) {
|
||||||
const maxStack = allHeldItems[itemType].getMaxStackCount();
|
const maxStack = allHeldItems[itemType].getMaxStackCount();
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ export class HeldItem implements Localizable {
|
|||||||
return this.maxStackCount;
|
return this.maxStackCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
createIcon(stackCount: number, _forSummary?: boolean): Phaser.GameObjects.Container {
|
createSummaryIcon(stackCount: number): Phaser.GameObjects.Container {
|
||||||
const container = globalScene.add.container(0, 0);
|
const container = globalScene.add.container(0, 0);
|
||||||
|
|
||||||
const item = globalScene.add.sprite(0, 12, "items");
|
const item = globalScene.add.sprite(0, 12, "items");
|
||||||
@ -79,6 +79,29 @@ export class HeldItem implements Localizable {
|
|||||||
container.add(stackText);
|
container.add(stackText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
container.setScale(0.5);
|
||||||
|
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
createPokemonIcon(stackCount: number, pokemon: Pokemon): Phaser.GameObjects.Container {
|
||||||
|
const container = globalScene.add.container(0, 0);
|
||||||
|
|
||||||
|
const pokemonIcon = globalScene.addPokemonIcon(pokemon, -2, 10, 0, 0.5, undefined, true);
|
||||||
|
container.add(pokemonIcon);
|
||||||
|
container.setName(pokemon.id.toString());
|
||||||
|
|
||||||
|
const item = globalScene.add.sprite(16, 16, "items");
|
||||||
|
item.setScale(0.5);
|
||||||
|
item.setOrigin(0, 0.5);
|
||||||
|
item.setTexture("items", this.getIcon());
|
||||||
|
container.add(item);
|
||||||
|
|
||||||
|
const stackText = this.getIconStackText(stackCount);
|
||||||
|
if (stackText) {
|
||||||
|
container.add(stackText);
|
||||||
|
}
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ 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 { allHeldItems } from "#app/modifier/all-held-items";
|
||||||
|
|
||||||
enum Page {
|
enum Page {
|
||||||
PROFILE,
|
PROFILE,
|
||||||
@ -1047,6 +1048,26 @@ export default class SummaryUiHandler extends UiHandler {
|
|||||||
icon.on("pointerout", () => globalScene.ui.hideTooltip());
|
icon.on("pointerout", () => globalScene.ui.hideTooltip());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const heldItemKeys = this.pokemon?.heldItemManager.getHeldItemKeys();
|
||||||
|
// TODO: Sort them
|
||||||
|
//.sort(heldItemSortFunc);
|
||||||
|
|
||||||
|
console.log(heldItemKeys);
|
||||||
|
|
||||||
|
heldItemKeys?.forEach((itemKey, i) => {
|
||||||
|
const stack = this.pokemon?.heldItemManager.getStack(itemKey);
|
||||||
|
const heldItem = allHeldItems[itemKey];
|
||||||
|
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 pkmLvl = this.pokemon?.level!; // TODO: is this bang correct?
|
||||||
const pkmLvlExp = this.pokemon?.levelExp!; // 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?
|
const pkmExp = this.pokemon?.exp!; // TODO: is this bang correct?
|
||||||
|
Loading…
Reference in New Issue
Block a user