63 lines
2.1 KiB
TypeScript
63 lines
2.1 KiB
TypeScript
// ─── Equipment Helper Functions ─────────────────────────
|
|
|
|
import type { EquipmentType, EquipmentSlot, EquipmentCategory } from './types';
|
|
import { EQUIPMENT_TYPES } from './equipment-types-data';
|
|
|
|
export function getEquipmentType(id: string): EquipmentType | undefined {
|
|
return EQUIPMENT_TYPES[id];
|
|
}
|
|
|
|
export function getEquipmentByCategory(category: EquipmentCategory): EquipmentType[] {
|
|
return Object.values(EQUIPMENT_TYPES).filter(e => e.category === category) as EquipmentType[];
|
|
}
|
|
|
|
export function getEquipmentBySlot(slot: EquipmentSlot): EquipmentType[] {
|
|
return Object.values(EQUIPMENT_TYPES).filter(e => e.slot === slot) as EquipmentType[];
|
|
}
|
|
|
|
export function getAllEquipmentTypes(): EquipmentType[] {
|
|
return Object.values(EQUIPMENT_TYPES) as EquipmentType[];
|
|
}
|
|
|
|
// Get valid slots for a category
|
|
// Note: For 2-handed weapons, use getValidSlotsForEquipmentType instead
|
|
export function getValidSlotsForCategory(category: EquipmentCategory): EquipmentSlot[] {
|
|
switch (category) {
|
|
case 'caster':
|
|
case 'catalyst':
|
|
case 'sword':
|
|
return ['mainHand'];
|
|
case 'shield':
|
|
return ['offHand'];
|
|
case 'head':
|
|
return ['head'];
|
|
case 'body':
|
|
return ['body'];
|
|
case 'hands':
|
|
return ['hands'];
|
|
case 'feet':
|
|
return ['feet'];
|
|
case 'accessory':
|
|
return ['accessory1', 'accessory2'];
|
|
default:
|
|
return [];
|
|
}
|
|
}
|
|
|
|
// Get valid slots for a specific equipment type (considers 2-handed weapons)
|
|
export function getValidSlotsForEquipmentType(equipType: EquipmentType): EquipmentSlot[] {
|
|
// 2-handed weapons occupy both main hand and offhand
|
|
if (equipType.twoHanded) {
|
|
return ['mainHand', 'offHand'];
|
|
}
|
|
|
|
// Otherwise use category-based slots
|
|
return getValidSlotsForCategory(equipType.category);
|
|
}
|
|
|
|
// Check if an equipment type can be equipped in a specific slot
|
|
export function canEquipInSlot(equipmentType: EquipmentType, slot: EquipmentSlot): boolean {
|
|
const validSlots = getValidSlotsForEquipmentType(equipmentType);
|
|
return validSlots.includes(slot);
|
|
}
|