Refactor large files into modular components
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 1m9s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 1m9s
- Refactored page.tsx (613→252 lines) with GameOverScreen and LeftPanel extracted - Refactored StatsTab.tsx (584→92 lines) with section components - Refactored SkillsTab.tsx (434→54 lines) with sub-components - Created modular structure for GameContext, LootInventory, and other components - All extracted components organized into feature directories
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
// ─── Equipment Helper Functions ─────────────────────────
|
||||
|
||||
import type { EquipmentType, EquipmentSlot, EquipmentCategory } from './types';
|
||||
import { EQUIPMENT_TYPES } from './index';
|
||||
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user