import { SkillId } from "./skills.js";

/** Placeable or fixed world stations that gate recipes (blocks / ground objects later). */
export const CraftingStationId = Object.freeze({
	furnace: "furnace",
	spinningWheel: "spinning-wheel",
	loom: "loom",
	anvil: "anvil",
	leatherworkingStation: "leatherworking-station",
	craftingBench: "crafting-bench",
	woodworkingBench: "woodworking-bench",
	tailorBench: "tailor-bench",
	oven: "oven",
	fireplace: "fireplace"
});

/** How long a player-lit campfire stays usable (ms). */
export const FIREPLACE_DURATION_MS = 10 * 60 * 1000;

/** Fixed craft action duration at any station (ms). */
export const CRAFT_DURATION_MS = 2000;

export const CRAFTING_STATION_DEFINITIONS = Object.freeze({
	[CraftingStationId.furnace]: Object.freeze({
		stationId: CraftingStationId.furnace,
		displayName: "Furnace",
		skillId: SkillId.smithing,
		description: "Smelt gathered ore into metal bars."
	}),
	[CraftingStationId.spinningWheel]: Object.freeze({
		stationId: CraftingStationId.spinningWheel,
		displayName: "Spinning wheel",
		skillId: SkillId.tailoring,
		description: "Spin raw fibre into yarn."
	}),
	[CraftingStationId.loom]: Object.freeze({
		stationId: CraftingStationId.loom,
		displayName: "Loom",
		skillId: SkillId.tailoring,
		description: "Weave yarn into cloth."
	}),
	[CraftingStationId.tailorBench]: Object.freeze({
		stationId: CraftingStationId.tailorBench,
		displayName: "Tailor's bench",
		skillId: SkillId.tailoring,
		description: "Sew garments from yarn or cloth; dyes may colour the cloth."
	}),
	[CraftingStationId.anvil]: Object.freeze({
		stationId: CraftingStationId.anvil,
		displayName: "Anvil",
		skillId: SkillId.smithing,
		description: "Smith metal items from bars."
	}),
	[CraftingStationId.leatherworkingStation]: Object.freeze({
		stationId: CraftingStationId.leatherworkingStation,
		displayName: "Leatherworking station",
		skillId: SkillId.leatherworking,
		description: "Craft leather armour and goods."
	}),
	[CraftingStationId.craftingBench]: Object.freeze({
		stationId: CraftingStationId.craftingBench,
		displayName: "Crafting bench",
		skillId: SkillId.crafting,
		description: "Fit handles to tool heads and finish assembled goods."
	}),
	[CraftingStationId.woodworkingBench]: Object.freeze({
		stationId: CraftingStationId.woodworkingBench,
		displayName: "Woodworking bench",
		skillId: SkillId.crafting,
		description: "Shape logs into handles and other wood components."
	}),
	[CraftingStationId.oven]: Object.freeze({
		stationId: CraftingStationId.oven,
		displayName: "Oven",
		skillId: SkillId.cooking,
		description: "Cook raw meat over steady heat."
	}),
	[CraftingStationId.fireplace]: Object.freeze({
		stationId: CraftingStationId.fireplace,
		displayName: "Campfire",
		skillId: SkillId.cooking,
		description: "An open fire for cooking on the road; food scorches more easily here.",
		portable: true,
		maxPerTile: 1,
		durationMs: FIREPLACE_DURATION_MS
	})
});

export function craftingStationDefinition (stationId)
{
	return CRAFTING_STATION_DEFINITIONS[stationId] ?? null;
}
