Add some type specifications so biome is happy

This commit is contained in:
Wlowscha 2025-07-13 12:55:07 +02:00
parent e7bb3a7443
commit eaead476e8
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
5 changed files with 14 additions and 7 deletions

View File

@ -128,7 +128,7 @@ export function getHeldItemCategory(itemId: HeldItemId): HeldItemCategoryId {
return (itemId & ITEM_CATEGORY_MASK) as HeldItemCategoryId;
}
export function isCategoryId(id: number): boolean {
export function isCategoryId(id: number): id is HeldItemCategoryId {
return (Object.values(HeldItemCategoryId) as number[]).includes(id);
}

View File

@ -287,7 +287,7 @@ export function assignItemsFromConfiguration(config: HeldItemConfiguration, poke
if (isCategoryId(entry)) {
assignItemsFromCategory(entry, pokemon, actualCount);
}
pokemon.heldItemManager.add(entry, actualCount);
pokemon.heldItemManager.add(entry as HeldItemId, actualCount);
}
if (isHeldItemSpecs(entry)) {

View File

@ -6,6 +6,7 @@ import { HeldItemCategoryId, isItemInCategory } from "#enums/held-item-id";
import { CommonAnim } from "#enums/move-anims-common";
import type { Pokemon } from "#field/pokemon";
import { applyHeldItems } from "#items/all-held-items";
import type { BerryHeldItem } from "#items/berry";
import { HeldItemEffect } from "#items/held-item";
import { FieldPhase } from "#phases/field-phase";
import { BooleanHolder } from "#utils/common";
@ -34,7 +35,7 @@ export class BerryPhase extends FieldPhase {
*/
eatBerries(pokemon: Pokemon): void {
const hasUsableBerry = pokemon.getHeldItems().some(m => {
return isItemInCategory(m, HeldItemCategoryId.BERRY) && allHeldItems[m].shouldApply(pokemon);
return isItemInCategory(m, HeldItemCategoryId.BERRY) && (allHeldItems[m] as BerryHeldItem).shouldApply(pokemon);
});
if (!hasUsableBerry) {

View File

@ -1,5 +1,7 @@
import { globalScene } from "#app/global-scene";
import { allHeldItems, allTrainerItems } from "#data/data-lists";
import type { HeldItemId } from "#enums/held-item-id";
import type { TrainerItemId } from "#enums/trainer-item-id";
import type { Pokemon } from "#field/pokemon";
import { heldItemSortFunc, trainerItemSortFunc } from "#items/item-utility";
import type { TrainerItemManager } from "#items/trainer-item-manager";
@ -8,7 +10,7 @@ const iconOverflowIndex = 24;
export class ItemBar extends Phaser.GameObjects.Container {
private player: boolean;
private itemCache: number[];
private itemCache: (HeldItemId | TrainerItemId)[];
public totalVisibleLength = 0;
constructor(enemy?: boolean) {
@ -60,7 +62,10 @@ export class ItemBar extends Phaser.GameObjects.Container {
this.sendToBack(icon);
}
this.itemCache = sortedTrainerItems.concat(heldItemsA).concat(heldItemsB);
this.itemCache = ([] as (TrainerItemId | HeldItemId)[])
.concat(sortedTrainerItems)
.concat(heldItemsA)
.concat(heldItemsB);
}
addIcon(icon: Phaser.GameObjects.Container, i: number, name: string, description: string) {

View File

@ -8,6 +8,7 @@ import type { Pokemon } from "#field/pokemon";
import { getMoveTargets } from "#moves/move-utils";
import { UiHandler } from "#ui/ui-handler";
import { fixedInt, isNullOrUndefined } from "#utils/common";
import type { ItemBar } from "./item-bar-ui";
export type TargetSelectCallback = (targets: BattlerIndex[]) => void;
@ -22,7 +23,7 @@ export class TargetSelectUiHandler extends UiHandler {
private targets: BattlerIndex[];
private targetsHighlighted: Pokemon[];
private targetFlashTween: Phaser.Tweens.Tween | null;
private enemyModifiers: ModifierBar;
private enemyModifiers: ItemBar;
private targetBattleInfoMoveTween: Phaser.Tweens.Tween[] = [];
constructor() {
@ -53,7 +54,7 @@ export class TargetSelectUiHandler extends UiHandler {
return false;
}
this.enemyModifiers = globalScene.getModifierBar(true);
this.enemyModifiers = globalScene.getItemBar(true);
if (this.fieldIndex === BattlerIndex.PLAYER) {
this.resetCursor(this.cursor0, user);