FEATURE: Bone Tools crafting recipes - pickaxe, axe, hoe, sword (Bone + Wood)

This commit is contained in:
2025-12-11 13:07:18 +01:00
parent 92c88d5c2d
commit 47a170ccb8
2 changed files with 190 additions and 0 deletions

View File

@@ -71,6 +71,9 @@
<script src="src/utils/Pathfinding.js"></script>
<script src="src/utils/Compression.js"></script>
<!-- Data -->
<script src="src/data/CraftingRecipes.js"></script>
<!-- Systems -->
<script src="src/systems/TerrainSystem.js"></script>
<script src="src/systems/Antigravity.js"></script>

187
src/data/CraftingRecipes.js Normal file
View File

@@ -0,0 +1,187 @@
/**
* CRAFTING RECIPES
* Defines all crafting recipes for basic items and tools
* Format: { id, name, ingredients: [{item, amount}], result: {item, amount}, category }
*/
const CRAFTING_RECIPES = {
// ==================================
// BONE TOOLS (New!)
// ==================================
'bone_pickaxe': {
id: 'bone_pickaxe',
name: 'Bone Pickaxe',
ingredients: [
{ item: 'bone', amount: 3 },
{ item: 'wood', amount: 2 }
],
result: { item: 'bone_pickaxe', amount: 1 },
category: 'tools',
description: 'Weak pickaxe made from bones. Better than nothing!'
},
'bone_axe': {
id: 'bone_axe',
name: 'Bone Axe',
ingredients: [
{ item: 'bone', amount: 3 },
{ item: 'wood', amount: 2 }
],
result: { item: 'bone_axe', amount: 1 },
category: 'tools',
description: 'Crude axe for chopping wood.'
},
'bone_hoe': {
id: 'bone_hoe',
name: 'Bone Hoe',
ingredients: [
{ item: 'bone', amount: 2 },
{ item: 'wood', amount: 2 }
],
result: { item: 'bone_hoe', amount: 1 },
category: 'tools',
description: 'Farming tool for tilling soil.'
},
'bone_sword': {
id: 'bone_sword',
name: 'Bone Sword',
ingredients: [
{ item: 'bone', amount: 2 },
{ item: 'wood', amount: 1 }
],
result: { item: 'bone_sword', amount: 1 },
category: 'weapons',
description: 'Sharp bone weapon. +5 damage.'
},
// ==================================
// BASIC TOOLS (Existing)
// ==================================
'wooden_pickaxe': {
id: 'wooden_pickaxe',
name: 'Wooden Pickaxe',
ingredients: [
{ item: 'wood', amount: 3 },
{ item: 'stick', amount: 2 }
],
result: { item: 'wooden_pickaxe', amount: 1 },
category: 'tools',
description: 'Basic mining tool.'
},
'stone_pickaxe': {
id: 'stone_pickaxe',
name: 'Stone Pickaxe',
ingredients: [
{ item: 'stone', amount: 3 },
{ item: 'stick', amount: 2 }
],
result: { item: 'stone_pickaxe', amount: 1 },
category: 'tools',
description: 'Improved mining tool.'
},
// ==================================
// BASIC ITEMS
// ==================================
'stick': {
id: 'stick',
name: 'Stick',
ingredients: [
{ item: 'wood', amount: 1 }
],
result: { item: 'stick', amount: 4 },
category: 'materials',
description: 'Basic crafting material.'
},
'torch': {
id: 'torch',
name: 'Torch',
ingredients: [
{ item: 'stick', amount: 1 },
{ item: 'coal', amount: 1 }
],
result: { item: 'torch', amount: 4 },
category: 'lighting',
description: 'Provides light in darkness.'
},
// ==================================
// BUILDINGS
// ==================================
'chest': {
id: 'chest',
name: 'Chest',
ingredients: [
{ item: 'wood', amount: 8 }
],
result: { item: 'chest', amount: 1 },
category: 'storage',
description: 'Storage container.'
},
'furnace': {
id: 'furnace',
name: 'Furnace',
ingredients: [
{ item: 'stone', amount: 8 },
{ item: 'coal', amount: 4 }
],
result: { item: 'furnace', amount: 1 },
category: 'workstation',
description: 'Smelts ores into bars.'
}
};
/**
* Helper function to get recipe by ID
*/
function getCraftingRecipe(recipeId) {
return CRAFTING_RECIPES[recipeId] || null;
}
/**
* Helper function to check if player has ingredients
*/
function canCraft(recipeId, playerInventory) {
const recipe = getCraftingRecipe(recipeId);
if (!recipe) return false;
for (const ingredient of recipe.ingredients) {
const playerAmount = playerInventory.getItemCount(ingredient.item);
if (playerAmount < ingredient.amount) {
return false; // Missing ingredient
}
}
return true;
}
/**
* Helper function to craft item (consumes ingredients)
*/
function craftItem(recipeId, playerInventory) {
if (!canCraft(recipeId, playerInventory)) {
console.warn('⚠️ Cannot craft - missing ingredients!');
return false;
}
const recipe = getCraftingRecipe(recipeId);
// Consume ingredients
for (const ingredient of recipe.ingredients) {
playerInventory.removeItem(ingredient.item, ingredient.amount);
}
// Add result
playerInventory.addItem(recipe.result.item, recipe.result.amount);
console.log(`✅ Crafted ${recipe.result.amount}x ${recipe.name}`);
return true;
}
// Export for use in other systems
if (typeof module !== 'undefined' && module.exports) {
module.exports = {
CRAFTING_RECIPES,
getCraftingRecipe,
canCraft,
craftItem
};
}