import { ItemCategory } from "./itemCategories.js"; import { EquipmentKind } from "./equipmentKinds.js"; import { equipImageName } from "./tileSprites.js"; import { ClothTier, CLOTH_TIER_ORDER, CLOTH_DISPLAY_NAME, leatherTierForCloth, tierMinSkillLevel } from "./materialTiers.js"; export const WIZARD_PIECES = Object.freeze([ Object.freeze({ templateId: "wizard-hat", suffix: "hat", slot: "head", label: "hat", idKey: "Hat", pieceKey: "hat", clothQty: 2, leatherQty: 1, dualTint: true }), Object.freeze({ templateId: "wizard-robetop", suffix: "robetop", slot: "chest", label: "robe top", idKey: "RobeTop", pieceKey: "robetop", clothQty: 5, leatherQty: 1, dualTint: true }), Object.freeze({ templateId: "wizard-robebottoms", suffix: "robebottoms", slot: "legs", label: "robe bottoms", idKey: "RobeBottoms", pieceKey: "robebottoms", clothQty: 4, leatherQty: 0, dualTint: false }), Object.freeze({ templateId: "wizard-shoes", suffix: "shoes", slot: "boots", label: "shoes", idKey: "Shoes", pieceKey: "shoes", clothQty: 1, leatherQty: 1, dualTint: true }) ]); function buildWizardItemIds () { const ids = {}; let nextId = 533; for (const tier of CLOTH_TIER_ORDER) { for (const piece of WIZARD_PIECES) { ids[`${tier}${piece.idKey}`] = nextId++; } } return Object.freeze(ids); } export const WizardItemId = buildWizardItemIds(); export function wizardItemIdForTier (clothTier, idKey) { return WizardItemId[`${clothTier}${idKey}`] ?? null; } function wizardPieceDef (itemId, clothTier, piece) { const name = CLOTH_DISPLAY_NAME[clothTier] ?? clothTier; const leatherTier = leatherTierForCloth(clothTier); const tierSlug = clothTier === ClothTier.cotton ? "cotton" : clothTier.replace(/([A-Z])/g, "-$1").toLowerCase(); const def = { itemId, key: `${tierSlug}-wizard-${piece.suffix}`, displayName: `${name} ${piece.label}`, description: piece.suffix === "hat" ? `A pointed ${name.toLowerCase()} hat, cut for study and spellcraft.` : piece.suffix === "robetop" ? `A long ${name.toLowerCase()} robe top, loose enough for gestures and runes.` : piece.suffix === "robebottoms" ? `Flowing ${name.toLowerCase()} robe bottoms that brush the ground when you walk.` : `Soft ${name.toLowerCase()} shoes, quiet on stone floors.`, seedValue: 8, stackable: false, maxStackSize: 1, uniqueInstance: false, category: ItemCategory.finished, iconKey: "magicrobes", defaultState: piece.suffix, tier: clothTier, dyeable: true, equipment: Object.freeze({ slot: piece.slot, tier: clothTier, kind: EquipmentKind.wizardCloth, minSkillLevel: tierMinSkillLevel(clothTier), equipSprite: equipImageName("item", "magicrobes", piece.suffix) }) }; if (piece.dualTint) { def.leatherTier = leatherTier; def.clothTier = clothTier; def.dualTintLeatherCloth = true; def.dualTintFromTier = true; def.equipment = Object.freeze({ ...def.equipment, dualTintFromTier: true }); } else { def.tintFromTier = true; def.equipment = Object.freeze({ ...def.equipment, tintFromTier: true }); } return Object.freeze(def); } function buildWizardDefinitions () { const defs = {}; for (const tier of CLOTH_TIER_ORDER) { for (const piece of WIZARD_PIECES) { const prop = `${tier}${piece.idKey}`; const itemId = WizardItemId[prop]; if (itemId == null) { throw new Error(`Missing WizardItemId for ${prop}`); } defs[itemId] = wizardPieceDef(itemId, tier, piece); } } return Object.freeze(defs); } export const WIZARD_ITEM_DEFINITIONS = buildWizardDefinitions(); /** Tailor bench templates for wizard robes. */ export const WIZARD_TEMPLATES = Object.freeze( Object.fromEntries(WIZARD_PIECES.map((piece) => { const inputs = [{ kind: "cloth", quantity: piece.clothQty }]; if (piece.leatherQty > 0) { inputs.push({ kind: "leather", quantity: piece.leatherQty }); } return [piece.templateId, Object.freeze({ templateId: piece.templateId, displayName: piece.label.charAt(0).toUpperCase() + piece.label.slice(1), slot: piece.slot, inputs: Object.freeze(inputs), outputItemIdForTier: (tier) => wizardItemIdForTier(tier, piece.idKey), minSkillLevel: 1 })]; })) ); export function wizardTemplate (templateId) { return WIZARD_TEMPLATES[templateId] ?? null; } export function listWizardTemplates () { return Object.values(WIZARD_TEMPLATES); } export function wizardHatItemId (tier) { return wizardItemIdForTier(tier, "Hat"); } export function wizardRobeTopItemId (tier) { return wizardItemIdForTier(tier, "RobeTop"); } export function wizardRobeBottomsItemId (tier) { return wizardItemIdForTier(tier, "RobeBottoms"); } export function wizardShoesItemId (tier) { return wizardItemIdForTier(tier, "Shoes"); }