import { ItemCategory } from "./itemCategories.js"; import { EquipmentKind } from "./equipmentKinds.js"; import { equipImageName } from "./tileSprites.js"; import { leatherMaterialItemId } from "./leatherItems.js"; import { wovenClothItemId } from "./clothItems.js"; import { CraftingStationId } from "./craftingStations.js"; import { LeatherTier, LEATHER_TIER_ORDER, LEATHER_DISPLAY_NAME, clothTierForLeather, tierMinSkillLevel, tierCraftSkillLevel } from "./materialTiers.js"; /** Leather chestguard, chausses, and helmet — dual tint (red leather, blue cloth trim). */ export const LEATHER_ARMOUR_PIECES = Object.freeze([ Object.freeze({ suffix: "chestguard", slot: "chest", label: "chestguard", idKey: "Chestguard", leatherQty: 4, clothQty: 2, pieceKey: "chestguard" }), Object.freeze({ suffix: "chausses", slot: "legs", label: "chausses", idKey: "Chausses", leatherQty: 3, clothQty: 1, pieceKey: "chausses" }), Object.freeze({ suffix: "helmet", slot: "head", label: "helmet", idKey: "Helmet", leatherQty: 2, clothQty: 0, pieceKey: "helmet" }) ]); function buildLeatherArmourItemIds () { const ids = {}; let nextId = 512; for (const tier of LEATHER_TIER_ORDER) { for (const piece of LEATHER_ARMOUR_PIECES) { ids[`${tier}${piece.idKey}`] = nextId++; } } return Object.freeze(ids); } export const LeatherArmourItemId = buildLeatherArmourItemIds(); export function leatherArmourItemIdForTier (tier, idKey) { return LeatherArmourItemId[`${tier}${idKey}`] ?? null; } function leatherArmourDef (itemId, tier, piece) { const name = LEATHER_DISPLAY_NAME[tier] ?? tier; const clothTier = clothTierForLeather(tier); const prefix = tier === LeatherTier.softLeather ? "soft-leather" : tier.replace(/([A-Z])/g, "-$1").toLowerCase(); const tightFit = piece.suffix === "chestguard" || piece.suffix === "chausses"; return Object.freeze({ itemId, key: `${prefix}-${piece.suffix}`, displayName: `${name} ${piece.label}`, description: `Sturdy ${name.toLowerCase()} ${piece.label}, lined for long marches.`, seedValue: 10, stackable: false, maxStackSize: 1, uniqueInstance: false, category: ItemCategory.finished, iconKey: "leatherarmour", defaultState: piece.suffix, tier, leatherTier: tier, clothTier, dualTintLeatherCloth: true, dualTintFromTier: true, ...(tightFit ? { tightFit: true } : {}), equipment: Object.freeze({ slot: piece.slot, tier, kind: EquipmentKind.leatherArmour, minSkillLevel: tierMinSkillLevel(tier), dualTintFromTier: true, equipSprite: equipImageName("item", "leatherarmour", piece.suffix) }) }); } function buildLeatherArmourDefinitions () { const defs = {}; for (const tier of LEATHER_TIER_ORDER) { for (const piece of LEATHER_ARMOUR_PIECES) { const prop = `${tier}${piece.idKey}`; const itemId = LeatherArmourItemId[prop]; if (itemId == null) { throw new Error(`Missing LeatherArmourItemId for ${prop}`); } defs[itemId] = leatherArmourDef(itemId, tier, piece); } } return Object.freeze(defs); } export const LEATHER_ARMOUR_ITEM_DEFINITIONS = buildLeatherArmourDefinitions(); /** Leatherworking station recipes for chestguard, chausses, and helmet. */ export function leatherArmourRecipes () { return LEATHER_TIER_ORDER.flatMap((leatherTier) => LEATHER_ARMOUR_PIECES.map((piece) => { const leatherId = leatherMaterialItemId(leatherTier); const outputId = leatherArmourItemIdForTier(leatherTier, piece.idKey); if (leatherId == null || outputId == null) { throw new Error(`Missing leather armour recipe ids for ${leatherTier} ${piece.suffix}`); } const inputs = [{ itemId: leatherId, quantity: piece.leatherQty }]; if (piece.clothQty > 0) { const clothId = wovenClothItemId(clothTierForLeather(leatherTier)); if (clothId == null) { throw new Error(`Missing cloth for ${leatherTier} ${piece.suffix}`); } inputs.push({ itemId: clothId, quantity: piece.clothQty }); } const label = piece.label.charAt(0).toUpperCase() + piece.label.slice(1); return Object.freeze({ recipeId: `leather-${piece.suffix}-${leatherTier}`, craftGroup: `leather-${piece.suffix}`, craftGroupLabel: label, stationId: CraftingStationId.leatherworkingStation, output: { itemId: outputId, quantity: 1 }, inputs, minSkillLevel: tierCraftSkillLevel(leatherTier), skillId: "leatherworking", xpMaterial: leatherTier }); })); } export { tierMinSkillLevel, tierCraftSkillLevel };