fixed part role mapping to categories. set a const for categories
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import type { CategoryId } from "@/types/gunbuilder";
|
||||
|
||||
// CategoryId -> partRoles
|
||||
export const CATEGORY_TO_PART_ROLES: Record<CategoryId, string[]> = {
|
||||
// CORE / EXISTING
|
||||
upper: ["upper-receiver"],
|
||||
barrel: ["barrel"],
|
||||
handguard: ["handguard"],
|
||||
chargingHandle: ["charging-handle"],
|
||||
buffer: ["buffer-kit"],
|
||||
lowerParts: ["lower-parts-kit"],
|
||||
sights: ["sight"],
|
||||
lower: ["lower-receiver"],
|
||||
optic: ["optic"],
|
||||
stock: ["stock"],
|
||||
|
||||
// NEW LOWER PARTS
|
||||
trigger: ["trigger", "trigger-kit"],
|
||||
grip: ["pistol-grip", "grip"],
|
||||
safety: ["safety", "safety-selector"],
|
||||
completeLower: ["complete-lower"],
|
||||
|
||||
// NEW UPPER PARTS
|
||||
completeUpper: ["complete-upper"],
|
||||
bcg: ["bcg", "bolt-carrier-group"],
|
||||
gasBlock: ["gas-block"],
|
||||
gasTube: ["gas-tube"],
|
||||
muzzleDevice: ["muzzle-device", "compensator", "brake"],
|
||||
suppressor: ["suppressor"],
|
||||
};
|
||||
|
||||
// Invert to get partRole -> CategoryId
|
||||
export const PART_ROLE_TO_CATEGORY: Record<string, CategoryId> = Object
|
||||
.entries(CATEGORY_TO_PART_ROLES)
|
||||
.reduce((acc, [categoryId, roles]) => {
|
||||
for (const role of roles) {
|
||||
acc[role] = categoryId as CategoryId;
|
||||
}
|
||||
return acc;
|
||||
}, {} as Record<string, CategoryId>);
|
||||
Reference in New Issue
Block a user