mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-09 00:49:27 +02:00
Add some type specifications so biome is happy
This commit is contained in:
parent
e7bb3a7443
commit
eaead476e8
@ -128,7 +128,7 @@ export function getHeldItemCategory(itemId: HeldItemId): HeldItemCategoryId {
|
|||||||
return (itemId & ITEM_CATEGORY_MASK) as 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);
|
return (Object.values(HeldItemCategoryId) as number[]).includes(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ export function assignItemsFromConfiguration(config: HeldItemConfiguration, poke
|
|||||||
if (isCategoryId(entry)) {
|
if (isCategoryId(entry)) {
|
||||||
assignItemsFromCategory(entry, pokemon, actualCount);
|
assignItemsFromCategory(entry, pokemon, actualCount);
|
||||||
}
|
}
|
||||||
pokemon.heldItemManager.add(entry, actualCount);
|
pokemon.heldItemManager.add(entry as HeldItemId, actualCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isHeldItemSpecs(entry)) {
|
if (isHeldItemSpecs(entry)) {
|
||||||
|
@ -6,6 +6,7 @@ import { HeldItemCategoryId, isItemInCategory } from "#enums/held-item-id";
|
|||||||
import { CommonAnim } from "#enums/move-anims-common";
|
import { CommonAnim } from "#enums/move-anims-common";
|
||||||
import type { Pokemon } from "#field/pokemon";
|
import type { Pokemon } from "#field/pokemon";
|
||||||
import { applyHeldItems } from "#items/all-held-items";
|
import { applyHeldItems } from "#items/all-held-items";
|
||||||
|
import type { BerryHeldItem } from "#items/berry";
|
||||||
import { HeldItemEffect } from "#items/held-item";
|
import { HeldItemEffect } from "#items/held-item";
|
||||||
import { FieldPhase } from "#phases/field-phase";
|
import { FieldPhase } from "#phases/field-phase";
|
||||||
import { BooleanHolder } from "#utils/common";
|
import { BooleanHolder } from "#utils/common";
|
||||||
@ -34,7 +35,7 @@ export class BerryPhase extends FieldPhase {
|
|||||||
*/
|
*/
|
||||||
eatBerries(pokemon: Pokemon): void {
|
eatBerries(pokemon: Pokemon): void {
|
||||||
const hasUsableBerry = pokemon.getHeldItems().some(m => {
|
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) {
|
if (!hasUsableBerry) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { globalScene } from "#app/global-scene";
|
import { globalScene } from "#app/global-scene";
|
||||||
import { allHeldItems, allTrainerItems } from "#data/data-lists";
|
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 type { Pokemon } from "#field/pokemon";
|
||||||
import { heldItemSortFunc, trainerItemSortFunc } from "#items/item-utility";
|
import { heldItemSortFunc, trainerItemSortFunc } from "#items/item-utility";
|
||||||
import type { TrainerItemManager } from "#items/trainer-item-manager";
|
import type { TrainerItemManager } from "#items/trainer-item-manager";
|
||||||
@ -8,7 +10,7 @@ const iconOverflowIndex = 24;
|
|||||||
|
|
||||||
export class ItemBar extends Phaser.GameObjects.Container {
|
export class ItemBar extends Phaser.GameObjects.Container {
|
||||||
private player: boolean;
|
private player: boolean;
|
||||||
private itemCache: number[];
|
private itemCache: (HeldItemId | TrainerItemId)[];
|
||||||
public totalVisibleLength = 0;
|
public totalVisibleLength = 0;
|
||||||
|
|
||||||
constructor(enemy?: boolean) {
|
constructor(enemy?: boolean) {
|
||||||
@ -60,7 +62,10 @@ export class ItemBar extends Phaser.GameObjects.Container {
|
|||||||
this.sendToBack(icon);
|
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) {
|
addIcon(icon: Phaser.GameObjects.Container, i: number, name: string, description: string) {
|
||||||
|
@ -8,6 +8,7 @@ import type { Pokemon } from "#field/pokemon";
|
|||||||
import { getMoveTargets } from "#moves/move-utils";
|
import { getMoveTargets } from "#moves/move-utils";
|
||||||
import { UiHandler } from "#ui/ui-handler";
|
import { UiHandler } from "#ui/ui-handler";
|
||||||
import { fixedInt, isNullOrUndefined } from "#utils/common";
|
import { fixedInt, isNullOrUndefined } from "#utils/common";
|
||||||
|
import type { ItemBar } from "./item-bar-ui";
|
||||||
|
|
||||||
export type TargetSelectCallback = (targets: BattlerIndex[]) => void;
|
export type TargetSelectCallback = (targets: BattlerIndex[]) => void;
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ export class TargetSelectUiHandler extends UiHandler {
|
|||||||
private targets: BattlerIndex[];
|
private targets: BattlerIndex[];
|
||||||
private targetsHighlighted: Pokemon[];
|
private targetsHighlighted: Pokemon[];
|
||||||
private targetFlashTween: Phaser.Tweens.Tween | null;
|
private targetFlashTween: Phaser.Tweens.Tween | null;
|
||||||
private enemyModifiers: ModifierBar;
|
private enemyModifiers: ItemBar;
|
||||||
private targetBattleInfoMoveTween: Phaser.Tweens.Tween[] = [];
|
private targetBattleInfoMoveTween: Phaser.Tweens.Tween[] = [];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -53,7 +54,7 @@ export class TargetSelectUiHandler extends UiHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.enemyModifiers = globalScene.getModifierBar(true);
|
this.enemyModifiers = globalScene.getItemBar(true);
|
||||||
|
|
||||||
if (this.fieldIndex === BattlerIndex.PLAYER) {
|
if (this.fieldIndex === BattlerIndex.PLAYER) {
|
||||||
this.resetCursor(this.cursor0, user);
|
this.resetCursor(this.cursor0, user);
|
||||||
|
Loading…
Reference in New Issue
Block a user