Files
HexUnlockedWeb/app/items/types.ts
T
2026-06-19 04:05:38 -03:00

42 lines
1.3 KiB
TypeScript

import { DB_BASE_URL } from '../../lib/db';
export type Item = {
id: string;
name: string;
iconFilePath: string;
};
export type Offering = {
id: string;
name: string;
iconFilePath: string;
role: number;
};
export type ItemType = 'all' | 'toolbox' | 'flashlight' | 'medkit' | 'key' | 'map' | 'other';
export type OfferingRole = 'all' | 'shared' | 'killer' | 'survivor';
export const ITEM_TYPE_LABELS: Record<ItemType, string> = {
all: 'All', toolbox: 'Toolbox', flashlight: 'Flashlight',
medkit: 'Med-Kit', key: 'Key', map: 'Map', other: 'Other',
};
export const getItemType = (id: string): ItemType => {
if (/toolbox/i.test(id)) return 'toolbox';
if (/flashlight/i.test(id)) return 'flashlight';
if (/medkit|med_?kit/i.test(id)) return 'medkit';
if (/key/i.test(id)) return 'key';
if (/map/i.test(id)) return 'map';
return 'other';
};
export const getItemIconUrl = (iconFilePath: string) => {
const file = (iconFilePath.split('/').pop() ?? '').split('.')[0];
return `${DB_BASE_URL}/icons/item-icons/${file}.png`;
};
export const getOfferingIconUrl = (iconFilePath: string) => {
const file = (iconFilePath.split('/').pop() ?? '').split('.')[0];
return `${DB_BASE_URL}/icons/offering-icons/${file}.png`;
};