import { ItemCategory } from "./itemCategories.js"; import { EquipmentKind } from "./equipmentKinds.js"; import { equipImageName } from "./tileSprites.js"; import { ClothTier, CLOTH_TIER_ORDER, CLOTH_DISPLAY_NAME, tierMinSkillLevel } from "./materialTiers.js"; /** * Cloth family: raw fibre (wool sprite), yarn, woven cloth — shared magenta * sprites under items/cloth/{wool,yarn,cloth}.png with per-tier tint. * Cotton raw reuses CraftingItemId.wool (11); yarn/cloth reuse 12/25. */ export const ClothItemId = Object.freeze({ cotton: 11, cottonYarn: 12, cottonCloth: 25, wool: 133, woolYarn: 134, woolCloth: 135, linen: 136, linenYarn: 137, linenCloth: 138, cashmere: 139, cashmereYarn: 140, cashmereCloth: 141, silk: 142, silkYarn: 143, silkCloth: 144, fairySilk: 145, fairySilkYarn: 146, fairySilkCloth: 147, dragonweave: 148, dragonweaveYarn: 149, dragonweaveCloth: 150, cottonSweater: 151, woolSweater: 152, linenSweater: 153, cashmereSweater: 154, silkSweater: 155, fairySilkSweater: 156, dragonweaveSweater: 157 }); const RAW_ID = Object.freeze({ [ClothTier.cotton]: ClothItemId.cotton, [ClothTier.wool]: ClothItemId.wool, [ClothTier.linen]: ClothItemId.linen, [ClothTier.cashmere]: ClothItemId.cashmere, [ClothTier.silk]: ClothItemId.silk, [ClothTier.fairySilk]: ClothItemId.fairySilk, [ClothTier.dragonweave]: ClothItemId.dragonweave }); const YARN_ID = Object.freeze({ [ClothTier.cotton]: ClothItemId.cottonYarn, [ClothTier.wool]: ClothItemId.woolYarn, [ClothTier.linen]: ClothItemId.linenYarn, [ClothTier.cashmere]: ClothItemId.cashmereYarn, [ClothTier.silk]: ClothItemId.silkYarn, [ClothTier.fairySilk]: ClothItemId.fairySilkYarn, [ClothTier.dragonweave]: ClothItemId.dragonweaveYarn }); const CLOTH_ID = Object.freeze({ [ClothTier.cotton]: ClothItemId.cottonCloth, [ClothTier.wool]: ClothItemId.woolCloth, [ClothTier.linen]: ClothItemId.linenCloth, [ClothTier.cashmere]: ClothItemId.cashmereCloth, [ClothTier.silk]: ClothItemId.silkCloth, [ClothTier.fairySilk]: ClothItemId.fairySilkCloth, [ClothTier.dragonweave]: ClothItemId.dragonweaveCloth }); const SWEATER_ID = Object.freeze({ [ClothTier.cotton]: ClothItemId.cottonSweater, [ClothTier.wool]: ClothItemId.woolSweater, [ClothTier.linen]: ClothItemId.linenSweater, [ClothTier.cashmere]: ClothItemId.cashmereSweater, [ClothTier.silk]: ClothItemId.silkSweater, [ClothTier.fairySilk]: ClothItemId.fairySilkSweater, [ClothTier.dragonweave]: ClothItemId.dragonweaveSweater }); const DEFAULT_STACK = 99; function rawLabel (tier) { if (tier === ClothTier.cotton) { return "Cotton"; } return CLOTH_DISPLAY_NAME[tier] ?? tier; } function fibreDef (itemId, tier, key) { const name = rawLabel(tier); return Object.freeze({ itemId, key, displayName: name, description: `Raw ${name.toLowerCase()} fibre. Spin into yarn at a spinning wheel.`, seedValue: 2, stackable: true, maxStackSize: DEFAULT_STACK, uniqueInstance: false, category: ItemCategory.ingredient, iconKey: "cloth", defaultState: "wool", tier, tintFromTier: true }); } function yarnDef (itemId, tier, key) { const name = CLOTH_DISPLAY_NAME[tier] ?? tier; return Object.freeze({ itemId, key, displayName: `${name} yarn`, description: `Spun ${name.toLowerCase()} yarn. Weave into cloth at a loom, or knit garments at a tailor's bench.`, seedValue: 3, stackable: true, maxStackSize: DEFAULT_STACK, uniqueInstance: false, category: ItemCategory.intermediate, iconKey: "cloth", defaultState: "yarn", tier, tintFromTier: true }); } function clothDef (itemId, tier, key) { const name = CLOTH_DISPLAY_NAME[tier] ?? tier; return Object.freeze({ itemId, key, displayName: `${name} cloth`, description: `Woven ${name.toLowerCase()} cloth for tailored garments.`, seedValue: 4, stackable: true, maxStackSize: DEFAULT_STACK, uniqueInstance: false, category: ItemCategory.intermediate, iconKey: "cloth", defaultState: "cloth", tier, tintFromTier: true }); } function sweaterDef (itemId, tier, key) { const name = CLOTH_DISPLAY_NAME[tier] ?? tier; return Object.freeze({ itemId, key, displayName: `${name} sweater`, description: `A warm ${name.toLowerCase()} sweater, soft enough for travel.`, seedValue: 10, stackable: false, maxStackSize: 1, uniqueInstance: false, category: ItemCategory.finished, iconKey: "clothing", defaultState: "sweater", tier, tintFromTier: true, dyeable: true, clothing: Object.freeze({ warm: true, style: true }), equipment: Object.freeze({ slot: "chest", tier, kind: EquipmentKind.clothArmour, bonus: 0, minSkillLevel: tierMinSkillLevel(tier), tintFromTier: true, equipSprite: equipImageName("item", "clothing", "sweater") }) }); } function buildClothDefinitions () { const defs = {}; for (const tier of CLOTH_TIER_ORDER) { const label = String(tier); defs[RAW_ID[tier]] = fibreDef(RAW_ID[tier], tier, label === "fairySilk" ? "fairy-silk" : label); defs[YARN_ID[tier]] = yarnDef( YARN_ID[tier], tier, `${label === "fairySilk" ? "fairy-silk" : label}-yarn` ); defs[CLOTH_ID[tier]] = clothDef( CLOTH_ID[tier], tier, `${label === "fairySilk" ? "fairy-silk" : label}-cloth` ); defs[SWEATER_ID[tier]] = sweaterDef( SWEATER_ID[tier], tier, `${label === "fairySilk" ? "fairy-silk" : label}-sweater` ); } // Prefer display key "cotton" for the plant fibre. defs[ClothItemId.cotton] = fibreDef(ClothItemId.cotton, ClothTier.cotton, "cotton"); return Object.freeze(defs); } export const CLOTH_ITEM_DEFINITIONS = buildClothDefinitions(); export function rawClothItemId (tier) { return RAW_ID[tier] ?? null; } export function yarnItemId (tier) { return YARN_ID[tier] ?? null; } export function wovenClothItemId (tier) { return CLOTH_ID[tier] ?? null; } export function sweaterItemId (tier) { return SWEATER_ID[tier] ?? null; } export function clothTierForItemId (itemId) { for (const tier of CLOTH_TIER_ORDER) { if (RAW_ID[tier] === itemId || YARN_ID[tier] === itemId || CLOTH_ID[tier] === itemId || SWEATER_ID[tier] === itemId) { return tier; } } return null; } /** Tailor garment templates (UI + recipes). */ export const CLOTHING_TEMPLATES = Object.freeze({ sweater: Object.freeze({ templateId: "sweater", displayName: "Sweater", slot: "chest", warm: true, inputs: Object.freeze([{ kind: "yarn", quantity: 3 }]), outputItemIdForTier: sweaterItemId, minSkillLevel: 1 }) }); export function clothingTemplate (templateId) { return CLOTHING_TEMPLATES[templateId] ?? null; } export function listClothingTemplates () { return Object.values(CLOTHING_TEMPLATES); } export { tierMinSkillLevel };