UNPKG

@j03fr0st/pubg-ts

Version:

A comprehensive TypeScript wrapper for the PUBG API

210 lines 6.05 kB
import type { Platform } from '../types/assets/seasons'; /** * Unified PUBG Asset Management System * * Provides comprehensive access to all PUBG assets with full TypeScript type safety. * Uses synced local data for zero-latency performance. * * ## Recommended Usage * * All methods are synchronous and use locally cached data for optimal performance: * - `getItemName()`, `getItemInfo()`, `searchItems()` - Item management * - `getVehicleName()`, `getVehicleInfo()` - Vehicle information * - `getMapName()`, `getAllMaps()` - Map data * - `getSeasonsByPlatform()`, `getCurrentSeason()` - Season information * - `getSurvivalTitle()` - Survival title lookups * * ## Migration from Async Methods * * Legacy async methods are deprecated in favor of synchronous alternatives: * - `getSeasonInfo()` → `getSeasonsByPlatform().find(s => s.id === seasonId)` * - `getSeasons()` → `getSeasonsByPlatform('PC')` * * @example * ```typescript * const assetManager = new AssetManager(); * * // Get item information (synchronous) * const itemName = assetManager.getItemName('Item_Weapon_AK47_C'); * const itemInfo = assetManager.getItemInfo('Item_Weapon_AK47_C'); * * // Search items by category * const weapons = assetManager.getItemsByCategory('weapon'); * * // Get season information * const pcSeasons = assetManager.getSeasonsByPlatform('PC'); * const currentSeason = assetManager.getCurrentSeason('PC'); * ``` */ export interface AssetConfig { baseUrl?: string; version?: string; cacheAssets?: boolean; useLocalData?: boolean; } export interface EnhancedItemInfo { id: string; name: string; category: string; subcategory: string; description: string; } export interface EnhancedVehicleInfo { id: string; name: string; type: string; category: string; description: string; } export interface EnhancedSeasonInfo { id: string; platform: Platform; name: string; startDate: string; endDate: string; isActive: boolean; isOffseason: boolean; } export interface SurvivalTitleInfo { title: string; level: number; pointsRequired: string; description?: string; } interface SeasonInfo { id: string; name: string; startDate: string; endDate: string; isActive: boolean; isOffseason: boolean; } export declare class AssetManager { private config; protected cache: Map<string, any>; private itemCache; private vehicleCache; private seasonCache; private itemSearchIndex; constructor(config?: AssetConfig); /** * Get user-friendly item name with type safety */ getItemName(itemId: string): string; /** * Get detailed item information with enhanced metadata */ getItemInfo(itemId: string): EnhancedItemInfo | null; /** * Get all items by category with type safety */ getItemsByCategory(category: string): EnhancedItemInfo[]; /** * Search items by name using fuzzy search. * @param query The search query. * @returns An array of item information, sorted by relevance. */ searchItems(query: string): EnhancedItemInfo[]; /** * Get user-friendly vehicle name with type safety */ getVehicleName(vehicleId: string): string; /** * Get detailed vehicle information */ getVehicleInfo(vehicleId: string): EnhancedVehicleInfo | null; /** * Get user-friendly map name with type safety */ getMapName(mapId: string): string; /** * Get all available maps */ getAllMaps(): Array<{ id: string; name: string; }>; /** * Get season information by platform */ getSeasonsByPlatform(platform: Platform): EnhancedSeasonInfo[]; /** * Get current active season for a platform */ getCurrentSeason(platform?: Platform): EnhancedSeasonInfo | null; /** * Get survival title information */ getSurvivalTitle(rating: number): SurvivalTitleInfo | null; /** * Get damage causer name */ getDamageCauserName(causerId: string): string; /** * Get damage type category */ getDamageTypeCategory(damageType: string): string; /** * Get game mode name */ getGameModeName(gameModeId: string): string; /** * @deprecated Use getSeasonsByPlatform('PC') for better performance with local data. * This method will be removed in v2.0.0. * * @example * // Instead of: * const seasons = await assetManager.getSeasons(); * * // Use: * const seasons = assetManager.getSeasonsByPlatform('PC'); */ getSeasons(): Promise<SeasonInfo[]>; /** * Get asset URL for items, weapons, vehicles, etc. */ getAssetUrl(category: string, itemId: string, type?: 'icon' | 'image'): string; /** * Get weapon asset URL with type safety */ getWeaponAssetUrl(weaponId: string, type?: 'icon' | 'image'): string; /** * Get equipment asset URL with type safety */ getEquipmentAssetUrl(equipmentId: string, type?: 'icon' | 'image'): string; /** * Get vehicle asset URL with type safety */ getVehicleAssetUrl(vehicleId: string, type?: 'icon' | 'image'): string; /** * Get statistics about the asset data */ getAssetStats(): { totalItems: number; totalVehicles: number; totalMaps: number; categoryCounts: Record<string, number>; }; /** * Clear asset cache */ clearCache(): void; private categorizeItem; private subcategorizeItem; private categorizeVehicle; private humanizeItemId; private humanizeVehicleId; private humanizeMapId; private humanizeSeasonId; private isSeasonActive; protected parseDate(dateStr: string): Date; private isRatingInRange; private cleanItemId; /** * Validate configuration object */ private validateConfig; } export declare const assetManager: AssetManager; export {}; //# sourceMappingURL=assets.d.ts.map