import {miningToolTemplate} from './mining-tool-policy.mjs'; import {equipmentTemplate,maximumEquipmentEnchantments} from './equipment-template-policy.mjs'; export const TOOL_POLICY='s1-tools-v1'; export const TOOL_KINDS=Object.freeze(['shovel','pickaxe','axe','hoe','sword','bow','crossbow','trident','hammer']); const fixed={bow:'bow',crossbow:'crossbow',trident:'trident',hammer:'mace'}; const label=value=>value.replaceAll('_',' ').replace(/\b[a-z]/g,c=>c.toUpperCase()); const level=(cap,mark)=>Math.floor(cap*(mark-1)/13); export function toolTemplate(kind,mark){ if(!TOOL_KINDS.includes(kind))throw TypeError('Choose a supported tool.'); const mining=miningToolTemplate(mark);if(['trident','hammer'].includes(kind)&&mark<7)throw TypeError('Tridents and hammers start at MK VII.'); if(kind==='shovel')return mining; let enchantments={...mining.enchantments}; const durability={...(level(4,mark)?{unbreaking:level(4,mark)}:{}),...(mark>=9?{mending:1}:{})}; if(kind==='sword')enchantments={...durability,...(level(7,mark)?{sharpness:level(7,mark)}:{}),...(level(4,mark)?{looting:level(4,mark),sweeping_edge:level(4,mark)}:{})}; if(kind==='bow')enchantments={...(durability.unbreaking?{unbreaking:durability.unbreaking}:{}),...(level(7,mark)?{power:level(7,mark)}:{}),...(level(3,mark)?{punch:level(3,mark)}:{}),...(mark>=8?{flame:1}:{}),...(mark>=12?{infinity:1}:{})}; if(kind==='crossbow')enchantments={...durability,...(level(4,mark)?{quick_charge:level(4,mark)}:{}),...(level(6,mark)?{piercing:level(6,mark)}:{})}; if(kind==='trident')enchantments={...durability,impaling:level(7,mark),loyalty:Math.max(1,level(4,mark)),...(mark>=10?{channeling:1}:{})}; if(kind==='hammer')enchantments={...durability,density:level(7,mark),...(mark>=12?{wind_burst:level(4,mark)}:{})}; return {policy:TOOL_POLICY,season:'S1',id:`dr_s1_${kind}_mk${mark}`,name:kind==='hammer'?'Imperial Hammer':label(kind),material:fixed[kind]||mining.material.replace(/shovel$/,kind),quality:mining.quality,equipmentMark:mark,itemClass:['pickaxe','axe','hoe'].includes(kind)?'mining-tool':'weapon',enchantments}; } export function elytraTemplate(variant){ if(!['basic','merged'].includes(variant))throw TypeError('Choose basic or merged Elytra.'); const merged=variant==='merged',quality=merged?'mythic':'legendary',mark=merged?14:13; return {policy:TOOL_POLICY,season:'S1',id:`dr_s1_elytra_${variant}`,name:merged?'Merged Elytra':'Basic Elytra',material:merged?'netherite_chestplate':'elytra',quality,equipmentMark:mark,itemClass:'flight-equipment',glider:merged,enchantments:merged?maximumEquipmentEnchantments(equipmentTemplate({quality,mark}),'chestplate'):{unbreaking:4,mending:1}}; } // Versioned crafting template preserves immutable original basic Elytra designs. export const CRAFTED_ELYTRA_TEMPLATE=Object.freeze({...elytraTemplate('basic'),id:'dr_s1_elytra_crafted_v2',quality:'very_rare',equipmentMark:11,enchantments:{unbreaking:3,mending:1}}); // Distinct instruments: ordinary spice and refined spice are never interchangeable. export const ROCKET_TEMPLATES=Object.freeze([ Object.freeze({policy:TOOL_POLICY,season:'S1',id:'dr_s1_spice_rocket_mk1',name:'Spice Rocket',material:'firework_rocket',quality:'uncommon',equipmentMark:1,itemClass:'flight-consumable',effectMultiplier:1,spiceItemId:'spice'}), Object.freeze({policy:TOOL_POLICY,season:'S1',id:'dr_s1_refined_rocket_mk2',name:'Refined Spice Rocket',material:'firework_rocket',quality:'uncommon',equipmentMark:2,itemClass:'flight-consumable',effectMultiplier:2,spiceItemId:'refined_spice'}), Object.freeze({policy:TOOL_POLICY,season:'S1',id:'dr_s1_polluted_rocket_mk3',name:'Polluted Spice Rocket',material:'firework_rocket',quality:'rare',equipmentMark:3,itemClass:'flight-consumable',effectMultiplier:4,spiceItemId:'polluted_refined_spice'}) ]); export const TOOL_TEMPLATES=Object.freeze(TOOL_KINDS.flatMap(kind=>{ const first=['trident','hammer'].includes(kind)?7:1; return Array.from({length:15-first},(_,i)=>Object.freeze(toolTemplate(kind,i+first))); }));