local S = minetest.get_translator("rampage_sword")

local broken_color = "#FF9090"

local repair_helpstr = "\n" .. S("Use an anvil to repair")

minetest.register_craftitem("rampage_sword:sword_broken",
	{
		description = minetest.colorize(broken_color,
			S("Broken Dwarven Sword") .. repair_helpstr),
		inventory_image = "rampage_sword_sword_broken.png",
		wield_scale = {x = 2, y = 2, z = 1},
		_anvil_result = "rampage_sword:sword",
	})

weapon_api.register_weapon("rampage_sword:sword",
	{
		description = S("Dwarven Sword"),
		inventory_image = "rampage_sword_sword.png",
		wield_scale = {x = 2, y = 2, z = 1},
		_proc = true,
	})
give_initial_stuff.add("rampage_sword:sword", 2)


local function repair(itemstack)
	local wear = itemstack:get_wear()
	wear = wear - 0x4000
	if wear <= 0
	then
		itemstack:set_wear(0)
	else
		itemstack:set_wear(wear)
	end
	return ItemStack(nil)
end

repairing_anvils.register_recipe("rampage_sword:sword_broken", "rampage_sword:sword 1 65535")
repairing_anvils.register_recipe("rampage_sword:sword", repair)
