mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 00:52:47 +02:00
Fixed several bugs related to accessing and visualizing held items
This commit is contained in:
parent
1e9239720d
commit
f26cb11e0b
@ -2906,7 +2906,10 @@ export default class BattleScene extends SceneBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.updateParty(player ? this.getPlayerParty() : this.getEnemyParty(), true);
|
this.updateParty(player ? this.getPlayerParty() : this.getEnemyParty(), true);
|
||||||
(player ? this.modifierBar : this.enemyModifierBar).updateModifiers(modifiers);
|
|
||||||
|
const pokemonA = player ? this.getPlayerParty()[0] : this.getEnemyParty()[0];
|
||||||
|
|
||||||
|
(player ? this.modifierBar : this.enemyModifierBar).updateModifiers(modifiers, pokemonA);
|
||||||
if (!player) {
|
if (!player) {
|
||||||
this.updateUIPositions();
|
this.updateUIPositions();
|
||||||
}
|
}
|
||||||
|
@ -1004,6 +1004,7 @@ export function getRandomPartyMemberFunc(
|
|||||||
undefined,
|
undefined,
|
||||||
false,
|
false,
|
||||||
undefined,
|
undefined,
|
||||||
|
undefined,
|
||||||
postProcess,
|
postProcess,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -1028,7 +1029,16 @@ function getSpeciesFilterRandomPartyMemberFunc(
|
|||||||
.getTrainerSpeciesForLevel(level, true, strength, waveIndex),
|
.getTrainerSpeciesForLevel(level, true, strength, waveIndex),
|
||||||
);
|
);
|
||||||
|
|
||||||
return globalScene.addEnemyPokemon(species, level, trainerSlot, undefined, false, undefined, postProcess);
|
return globalScene.addEnemyPokemon(
|
||||||
|
species,
|
||||||
|
level,
|
||||||
|
trainerSlot,
|
||||||
|
undefined,
|
||||||
|
false,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
postProcess,
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,6 +339,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
this.exp = dataSource?.exp || getLevelTotalExp(this.level, species.growthRate);
|
this.exp = dataSource?.exp || getLevelTotalExp(this.level, species.growthRate);
|
||||||
this.levelExp = dataSource?.levelExp || 0;
|
this.levelExp = dataSource?.levelExp || 0;
|
||||||
|
|
||||||
|
this.heldItemManager = new PokemonItemManager();
|
||||||
|
|
||||||
if (dataSource) {
|
if (dataSource) {
|
||||||
this.id = dataSource.id;
|
this.id = dataSource.id;
|
||||||
this.hp = dataSource.hp;
|
this.hp = dataSource.hp;
|
||||||
@ -444,8 +446,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
if (!dataSource) {
|
if (!dataSource) {
|
||||||
this.calculateStats();
|
this.calculateStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.heldItemManager = new PokemonItemManager();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,7 +2,7 @@ import type { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
|
|||||||
import type Pokemon from "#app/field/pokemon";
|
import type Pokemon from "#app/field/pokemon";
|
||||||
import { coerceArray, getEnumValues, randSeedFloat, randSeedInt } from "#app/utils/common";
|
import { coerceArray, getEnumValues, randSeedFloat, randSeedInt } from "#app/utils/common";
|
||||||
import { BerryType } from "#enums/berry-type";
|
import { BerryType } from "#enums/berry-type";
|
||||||
import { HeldItemCategoryId, HeldItemId, isCategoryId } from "#enums/held-item-id";
|
import { HeldItemCategoryId, HeldItemId, HeldItemNames, isCategoryId } from "#enums/held-item-id";
|
||||||
import { HeldItemPoolType } from "#enums/modifier-pool-type";
|
import { HeldItemPoolType } from "#enums/modifier-pool-type";
|
||||||
import type { PokemonType } from "#enums/pokemon-type";
|
import type { PokemonType } from "#enums/pokemon-type";
|
||||||
import { RewardTier } from "#enums/reward-tier";
|
import { RewardTier } from "#enums/reward-tier";
|
||||||
@ -246,8 +246,11 @@ function getPoolWeights(pool: HeldItemPool, pokemon: Pokemon): number[] {
|
|||||||
return pool.map(p => {
|
return pool.map(p => {
|
||||||
let weight = typeof p.weight === "function" ? p.weight(coerceArray(pokemon)) : p.weight;
|
let weight = typeof p.weight === "function" ? p.weight(coerceArray(pokemon)) : p.weight;
|
||||||
|
|
||||||
if (typeof p.entry === "number") {
|
if (typeof p.entry === "number" && !isCategoryId(p.entry)) {
|
||||||
const itemId = p.entry as HeldItemId;
|
const itemId = p.entry as HeldItemId;
|
||||||
|
console.log("ITEM ID: ", itemId, HeldItemNames[itemId]);
|
||||||
|
console.log(allHeldItems[itemId]);
|
||||||
|
|
||||||
if (pokemon.heldItemManager.getStack(itemId) >= allHeldItems[itemId].getMaxStackCount()) {
|
if (pokemon.heldItemManager.getStack(itemId) >= allHeldItems[itemId].getMaxStackCount()) {
|
||||||
weight = 0;
|
weight = 0;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ export class BaseStatTotalHeldItem extends HeldItem {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get icon(): string {
|
get iconName(): string {
|
||||||
return "berry_juice";
|
return "berry_juice";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { getBerryEffectDescription, getBerryEffectFunc, getBerryName } from "#app/data/berry";
|
import { getBerryEffectDescription, getBerryEffectFunc, getBerryName, getBerryPredicate } from "#app/data/berry";
|
||||||
import { BerryUsedEvent } from "#app/events/battle-scene";
|
import { BerryUsedEvent } from "#app/events/battle-scene";
|
||||||
import type Pokemon from "#app/field/pokemon";
|
import type Pokemon from "#app/field/pokemon";
|
||||||
import { globalScene } from "#app/global-scene";
|
import { globalScene } from "#app/global-scene";
|
||||||
@ -60,9 +60,9 @@ export class BerryHeldItem extends ConsumableHeldItem {
|
|||||||
* @param pokemon The {@linkcode Pokemon} that holds the berry
|
* @param pokemon The {@linkcode Pokemon} that holds the berry
|
||||||
* @returns `true` if {@linkcode BerryModifier} should be applied
|
* @returns `true` if {@linkcode BerryModifier} should be applied
|
||||||
*/
|
*/
|
||||||
// override shouldApply(pokemon: Pokemon): boolean {
|
shouldApply(pokemon: Pokemon): boolean {
|
||||||
// return !this.consumed && super.shouldApply(pokemon) && getBerryPredicate(this.berryType)(pokemon);
|
return getBerryPredicate(this.berryType)(pokemon);
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies {@linkcode BerryHeldItem}
|
* Applies {@linkcode BerryHeldItem}
|
||||||
|
@ -29,7 +29,7 @@ export class InstantReviveHeldItem extends ConsumableHeldItem {
|
|||||||
return i18next.t("modifierType:ModifierType.REVIVER_SEED.description");
|
return i18next.t("modifierType:ModifierType.REVIVER_SEED.description");
|
||||||
}
|
}
|
||||||
|
|
||||||
get icon(): string {
|
get iconName(): string {
|
||||||
return "reviver_seed";
|
return "reviver_seed";
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -29,7 +29,7 @@ export class ResetNegativeStatStageHeldItem extends ConsumableHeldItem {
|
|||||||
return i18next.t("modifierType:ModifierType.WHITE_HERB.description");
|
return i18next.t("modifierType:ModifierType.WHITE_HERB.description");
|
||||||
}
|
}
|
||||||
|
|
||||||
get icon(): string {
|
get iconName(): string {
|
||||||
return "white_herb";
|
return "white_herb";
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -24,6 +24,7 @@ import { timedEventManager } from "./global-event-manager";
|
|||||||
import { initHeldItems } from "./items/all-held-items";
|
import { initHeldItems } from "./items/all-held-items";
|
||||||
import { initModifierPools } from "./modifier/init-modifier-pools";
|
import { initModifierPools } from "./modifier/init-modifier-pools";
|
||||||
import { initModifierTypes } from "./modifier/modifier-type";
|
import { initModifierTypes } from "./modifier/modifier-type";
|
||||||
|
import { initHeldItemPools } from "./items/init-held-item-pools";
|
||||||
|
|
||||||
export class LoadingScene extends SceneBase {
|
export class LoadingScene extends SceneBase {
|
||||||
public static readonly KEY = "loading";
|
public static readonly KEY = "loading";
|
||||||
@ -368,6 +369,7 @@ export class LoadingScene extends SceneBase {
|
|||||||
|
|
||||||
initModifierTypes();
|
initModifierTypes();
|
||||||
initModifierPools();
|
initModifierPools();
|
||||||
|
initHeldItemPools();
|
||||||
|
|
||||||
initAchievements();
|
initAchievements();
|
||||||
initVouchers();
|
initVouchers();
|
||||||
|
@ -354,12 +354,12 @@ export class HeldItemReward extends PokemonModifierType {
|
|||||||
return allHeldItems[this.itemId].name;
|
return allHeldItems[this.itemId].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
get description(): string {
|
getDescription(): string {
|
||||||
return allHeldItems[this.itemId].name;
|
return allHeldItems[this.itemId].description;
|
||||||
}
|
}
|
||||||
|
|
||||||
get icon(): string {
|
getIcon(): string {
|
||||||
return allHeldItems[this.itemId].name;
|
return allHeldItems[this.itemId].iconName;
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(pokemon: Pokemon) {
|
apply(pokemon: Pokemon) {
|
||||||
@ -2070,6 +2070,11 @@ function getModifierTypeOptionWithRetry(
|
|||||||
++r < retryCount &&
|
++r < retryCount &&
|
||||||
existingOptions.filter(o => o.type.name === candidate?.type.name || o.type.group === candidate?.type.group).length
|
existingOptions.filter(o => o.type.name === candidate?.type.name || o.type.group === candidate?.type.group).length
|
||||||
) {
|
) {
|
||||||
|
console.log("Retry count:", r);
|
||||||
|
console.log(candidate?.type.group);
|
||||||
|
console.log(candidate?.type.name);
|
||||||
|
console.log(existingOptions.filter(o => o.type.name === candidate?.type.name).length);
|
||||||
|
console.log(existingOptions.filter(o => o.type.group === candidate?.type.group).length);
|
||||||
candidate = getNewModifierTypeOption(
|
candidate = getNewModifierTypeOption(
|
||||||
party,
|
party,
|
||||||
ModifierPoolType.PLAYER,
|
ModifierPoolType.PLAYER,
|
||||||
@ -2255,6 +2260,7 @@ function determineTier(
|
|||||||
retryCount = 0,
|
retryCount = 0,
|
||||||
allowLuckUpgrades = true,
|
allowLuckUpgrades = true,
|
||||||
): RewardTier {
|
): RewardTier {
|
||||||
|
const pool = getModifierPoolForType(ModifierPoolType.PLAYER);
|
||||||
if (tier === undefined) {
|
if (tier === undefined) {
|
||||||
const tierValue = randSeedInt(1024);
|
const tierValue = randSeedInt(1024);
|
||||||
if (!upgradeCount) {
|
if (!upgradeCount) {
|
||||||
|
@ -170,8 +170,7 @@ export class SelectModifierPhase extends BattlePhase {
|
|||||||
if (modifierType instanceof PokemonModifierType) {
|
if (modifierType instanceof PokemonModifierType) {
|
||||||
if (modifierType instanceof HeldItemReward) {
|
if (modifierType instanceof HeldItemReward) {
|
||||||
this.openGiveHeldItemMenu(modifierType, modifierSelectCallback);
|
this.openGiveHeldItemMenu(modifierType, modifierSelectCallback);
|
||||||
}
|
} else if (modifierType instanceof FusePokemonModifierType) {
|
||||||
if (modifierType instanceof FusePokemonModifierType) {
|
|
||||||
this.openFusionMenu(modifierType, cost, modifierSelectCallback);
|
this.openFusionMenu(modifierType, cost, modifierSelectCallback);
|
||||||
} else {
|
} else {
|
||||||
this.openModifierMenu(modifierType, cost, modifierSelectCallback);
|
this.openModifierMenu(modifierType, cost, modifierSelectCallback);
|
||||||
|
@ -779,6 +779,7 @@ class ModifierOption extends Phaser.GameObjects.Container {
|
|||||||
this.add(this.itemContainer);
|
this.add(this.itemContainer);
|
||||||
|
|
||||||
const getItem = () => {
|
const getItem = () => {
|
||||||
|
console.log("SHOWING ICON", this.modifierTypeOption.type?.name, this.modifierTypeOption.type?.getIcon());
|
||||||
const item = globalScene.add.sprite(0, 0, "items", this.modifierTypeOption.type?.getIcon());
|
const item = globalScene.add.sprite(0, 0, "items", this.modifierTypeOption.type?.getIcon());
|
||||||
return item;
|
return item;
|
||||||
};
|
};
|
||||||
|
@ -1035,9 +1035,8 @@ export default class SummaryUiHandler extends UiHandler {
|
|||||||
const heldItems = this.pokemon?.getHeldItems().sort(heldItemSortFunc);
|
const heldItems = this.pokemon?.getHeldItems().sort(heldItemSortFunc);
|
||||||
|
|
||||||
heldItems?.forEach((itemKey, i) => {
|
heldItems?.forEach((itemKey, i) => {
|
||||||
const stack = this.pokemon?.heldItemManager.getStack(itemKey);
|
|
||||||
const heldItem = allHeldItems[itemKey];
|
const heldItem = allHeldItems[itemKey];
|
||||||
const icon = heldItem.createSummaryIcon(stack);
|
const icon = heldItem.createSummaryIcon(this.pokemon);
|
||||||
|
|
||||||
console.log(icon);
|
console.log(icon);
|
||||||
icon.setPosition((i % 17) * 12 + 3, 14 * Math.floor(i / 17) + 15);
|
icon.setPosition((i % 17) * 12 + 3, 14 * Math.floor(i / 17) + 15);
|
||||||
|
Loading…
Reference in New Issue
Block a user