import { BackpackParser } from "tf2-backpack"; import { Enum, ItemTraits, ItemType, NumEnum, ParsedSchema, ParsedSchemaEntry } from "./types/index.js"; import EItemKillstreak from "./enums/EItemKillstreak.js"; import EItemQuality from "./enums/EItemQuality.js"; import EItemWear from "./enums/EItemWear.js"; import EKillstreaker from "./enums/EKillstreaker.js"; import EKillstreakSheen from "./enums/EKillstreakSheen.js"; import ESpells from "./enums/ESpells.js"; import EStrangeParts from "./enums/EStrangeParts.js"; import ETraits from "./enums/ETraits.js"; import { Schema } from "@peleicht/tf2-schema"; import EGrades from "./enums/EGrades.js"; import { AllFormatAttributes, BPDocumentType, BPDocumentTypeOutgoing, BPItemV1, EconItemType, TF2ItemType, TradeOfferManagerItem } from "./types/foreign_items.js"; declare const EPaints: Enum; export declare const global_info: { ready: boolean; parsed_schema: ParsedSchema; parsed_schema_names: ParsedSchema; parsed_schema_norm_names: ParsedSchema; promos: NumEnum; tf2_item_parser: BackpackParser | undefined; EUnusualEffects: Enum; ETextures: Enum; schema: Schema | undefined; }; export default class Item implements ItemTraits { def_index: number; quality: number; name: string; id?: string; craftable: boolean; killstreak: number; killstreak_sheen: number; killstreaker: number; australium: boolean; festivized: boolean; unusual: number; texture: number | undefined; wear: number; strange: boolean; tradable: boolean; paint: number; spells: number[]; strange_parts: number[]; usable: boolean; max_uses?: number; remaining_uses?: number; level?: number; item_number?: number; target_def_index?: number; input_items?: string[]; output_item?: { def_index?: number; quality?: number; item?: Item; }; type: ItemType; needs_the: boolean; never_tradable: boolean; img?: string; /** * Create a new Item Instance with known item traits. Will throw an error when specifing an unknown def_index. */ constructor(traits: ItemTraits); /** * Initialize the Item class with a Steam API Key or a schema from tf2-schema. When providing an api key, this will automatically call itself every few hours. * This will update item definitions, so it should at least to be called following new tf2 updates. * Most methods work without calling this, but it is required to parse items from the node-tf2 module. */ static init(steam_api_key: string): Promise; static init(schema: Schema): void; static KEY: Item; static REFINED: Item; static RECLAIMED: Item; static SCRAP: Item; static FESTIVIZER: Item; static WILDCARD: Item; /** * Parses an item from a string. Ignores case and special characters. Will return undefined if the string is not a valid item. * @param name the name of the item * @param strict pass false to allow ignoring unrecognized words, which may catch typos but also lead to unexpected results. Default true. */ static fromName(name: string, strict?: boolean): Item | undefined; /** * Parses an item from a SKU. */ static fromSKU(sku: string): Item | undefined; /** * Parses items from the steam api, node-steam-user and node-steamcommunity. */ static fromEconItem(item: EconItemType): Item | undefined; /** * Parses items from the node-tf2 module and some older backpack.tf api endpoints. */ static fromTF2(item: TF2ItemType): Item | undefined; /** * Parses items from the tf2-item-format node module. */ static fromItemFormat(item: AllFormatAttributes): Item | undefined; /** * Parses items from newer backpack.tf api endpoints (snapshot, websocket, v2). */ static fromBPDocument(item: BPDocumentType): Item | undefined; /** * Parses items from a URL to a backpack.tf "stats" page (https://backpack.tf/stats/...). */ static fromBPURL(url: string): Item | undefined; protected static makeItem(input: any, parser: (...input: any) => ItemTraits | undefined, ...args: any[]): Item | undefined; /** * Creates an Item from an ItemTraits object. Useful for converting an Item back after using *toJSON*. */ static fromJSON(json: ItemTraits): Item; /** * Compares two Items. * Only compares traits that meaningfully differentiate items (i.e. ignores paint, killstreak sheens, killstreakers, strange parts and spells). * Use .equalExact to compare all traits. * @param item * @param ignore_traits array of ETraits entries that should be ignored during the equality check. * @return true if the items are equal, false otherwise. */ equal(item: Item, ignore_traits?: ETraits[]): boolean; /** * Checks if the Item is a key, ref, rec or scrap. */ isCurrency(): boolean; isCraftWeapon(): boolean; /** * Converts the Item to its fully qualified name. Includes name, quality, killstreak, etc. * @param include_uses Include number of remaining uses at end when item is usable and does not have all uses remaining (ie. " (2/5 uses)"). Default true. */ toString(include_uses?: boolean): string; /** * Converts the Item to a SKU. Equivalent to the widely used Marketplace.tf SKU. * Note that the backpack.tf api usually expects a name (use *toString*) when using the sku parameter. */ toSKU(): string | undefined; /** * Converts the Item to JSON. Useful for saving items to a database or file. Convert them back to items using *fromJSON*. * @param include_defaults Include traits that are equal to their default value, greatly increasing the size of the output. Default false. */ toJSON(include_defaults?: boolean): ItemTraits; /** * Obtains the URL to the item on backpack.tf. */ toBPURL(): string; /** * Converts the item to the new backpack.tf item format. Used across the new v2 api endpoints. */ toBPDocument(): BPDocumentTypeOutgoing; /** * Converts the item to an item for the old backpack.tf api endpoints. */ toBPItemV1(): BPItemV1; private toBPName; private getBPPriceIndex; /** * Creates a TradeOfferManager item from the Item. Used for sending trade offers using steam-tradeoffer-manager. */ toTradeOfferManagerItem(): TradeOfferManagerItem; /** * Compare all item traits, even those one would rarely check like killstreak sheen, paints and strange parts. Recommend using *.equal* instead. * @item item to compare to * @ignore_traits array of ETraits entries that should be ignored during the equality check. */ equalExact(item: Item, ignore_traits?: ETraits[]): boolean; getGrade(): EGrades | undefined; /** * Effectively same as this.equal, but used for handling the ignore_traits parameter (this.equal does not check this parameter to avoid the overhead when using the default empty setting). */ protected conditionalEqual(item: Item, ignore_traits?: ETraits[]): boolean; /** * Duplicate the Item. Useful for creating a copy of an item that can be modified without affecting the original. */ duplicate(): Item; /** * Converts the Item into an easily readable String without Name. Does not includes wear, item number or uses. */ startAttributesToText(): string; endAttributesToText(include_uses: boolean): string; /** * Some Items have several possible def_index values depending on quality, style or obtain method. This method returns the lowest possible def_index for the item. */ static normalizeDefIndex(def_index?: number): number | undefined; /** * Identifies if an item is usable and how many uses it has. * @returns [usable, max_uses, remaining_uses] */ static identifyUses(def_index: number, name: string, type: ItemType): [boolean, number | undefined, number | undefined]; /** * Get the parsed schema entry for an item. */ static getSchemaItem(def_index?: number, name?: string): ParsedSchemaEntry | undefined; } /** * Normalize an item name. Removes special characters, double spaces, "the" and "taunt" from the start. */ export declare function normalizeName(name: string): string; /** * Replace special characters with their normal counterparts. Removes double spaces, "the" and "taunt" from the start. * * Used for normalizing item names, textures and unusual effects. */ export declare function replaceSpecialCharacters(text: string): string; declare const parsed_schema: ParsedSchema, parsed_schema_names: ParsedSchema, parsed_schema_norm_names: ParsedSchema, promos: NumEnum, ETextures: Enum, EUnusualEffects: Enum; export * from "./types/foreign_items.js"; export * from "./types/index.js"; export { EItemKillstreak, EItemQuality, EItemWear, EKillstreaker, EKillstreakSheen, EPaints, ESpells, EStrangeParts, ETextures, ETraits, EUnusualEffects, parsed_schema, parsed_schema_names, parsed_schema_norm_names, promos }; /** * After calling *init*, this will return true when the Item class is ready to be used. */ export declare function isReady(): boolean;