feat: add items
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
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 `/icons/item-icons/${file}.png`;
|
||||
};
|
||||
|
||||
export const getOfferingIconUrl = (iconFilePath: string) => {
|
||||
const file = (iconFilePath.split('/').pop() ?? '').split('.')[0];
|
||||
return `/icons/offering-icons/${file}.png`;
|
||||
};
|
||||
|
||||
export const randInRange = (min: number, max: number) => {
|
||||
const lo = Math.min(min, max);
|
||||
const hi = Math.max(min, max);
|
||||
return Math.floor(Math.random() * (hi - lo + 1)) + lo;
|
||||
};
|
||||
Reference in New Issue
Block a user