import { ReactNode } from 'react'; import { Mod } from '../../../mod/poe'; import { RollableValue, MinMaxValue, AugmentableValue, } from '../../../util/value'; import { ExclusifyUnion } from '../../../util/types'; export type Item = AbstractItem & ItemProperties; /** * if base.id is provided the component tries to translate * the basename according to the provided messages * for magic items this means that you have to set `prefix` and `suffix` * to the respective mod id to provide full i18n support */ export interface AbstractItem { base: { id?: string; name?: string; }; // only required for rare and unique items name?: string; rarity: Rarity; requirements?: { [key: string]: AugmentableValue | undefined; level?: AugmentableValue; dexterity?: AugmentableValue; intelligence?: AugmentableValue; strength?: AugmentableValue; }; // stats for default view craftedStats?: ReactNode[]; enchantStats?: ReactNode[]; explicitStats?: ReactNode[]; implicitStats?: ReactNode[]; utilityStats?: ReactNode[]; // in case only stats are given and the item is magic we need to know // the id of the prefix/suffix mod prefix?: string; suffix?: string; elder?: boolean; shaper?: boolean; corrupted?: boolean; } export type Rarity = 'normal' | 'magic' | 'rare' | 'unique'; export type ItemProperties = ExclusifyUnion< ShieldProperties | ArmourProperties | WeaponProperties | NoProperties >; export interface AbstractProperties { quality?: number; } export interface ArmourProperties extends AbstractProperties { armour?: AugmentableValue; energy_shield?: AugmentableValue; evasion?: AugmentableValue; } export function isArmourProperties( props: ItemProperties, ): props is ArmourProperties { return ['armour', 'energy_shield', 'evasion'].some(prop => prop in props); } export interface ShieldProperties extends ArmourProperties { // in percent block: AugmentableValue; } export function isShieldProperties( props: ItemProperties, ): props is ShieldProperties { return 'block' in props; } export interface WeaponProperties extends AbstractProperties { physical_damage?: AugmentableValue; cold_damage?: MinMaxValue; fire_damage?: MinMaxValue; lightning_damage?: MinMaxValue; chaos_damage?: MinMaxValue; // attacks per 100s aps?: AugmentableValue; /** * value: 0-10000 * 10000 => 100% * 1000 => 10% * 100 => 1% * 10 => 0.1% * 1 => 1% */ crit?: AugmentableValue; range?: AugmentableValue; } export function isWeaponProperties( props: ItemProperties, ): props is WeaponProperties { return [ 'physical_damage', 'cold_damage', 'fire_damage', 'lightning_damage', 'chaos_damage', 'aps', 'crit', 'range', ].some(prop => prop in props); } export type NoProperties = AbstractProperties; export type Affix = ReactNode | Mod; export type Affixes = Affix[];