/** * BLUEPRINT SYSTEM * Manages unlocking crafting recipes via Blueprint items. */ class BlueprintSystem { constructor(scene) { this.scene = scene; this.unlockedRecipes = new Set(); // Stores IDs of unlocked recipes // Default unlocked recipes (Basic tools & structures) this.unlockedRecipes.add('stick'); this.unlockedRecipes.add('plank'); this.unlockedRecipes.add('chest'); this.unlockedRecipes.add('fence'); // Blueprint Definitions (Item ID -> Recipe ID) this.blueprints = { 'blueprint_furnace': 'furnace', 'blueprint_anvil': 'anvil', 'blueprint_scooter_part': 'scooter_engine', // Example special part 'blueprint_grave': 'gravestone' }; } /** * Unlock a recipe */ unlockRecipe(recipeId) { if (this.unlockedRecipes.has(recipeId)) { console.log(`â„šī¸ Recipe ${recipeId} already unlocked.`); return false; } this.unlockedRecipes.add(recipeId); console.log(`📜 UNLOCKED RECIPE: ${recipeId}`); // Notification this.scene.events.emit('show-floating-text', { x: this.scene.player.sprite.x, y: this.scene.player.sprite.y - 100, text: `NEW RECIPE: ${recipeId.toUpperCase()}!`, color: '#00FFFF' }); if (this.scene.soundManager) this.scene.soundManager.playSuccess(); return true; } /** * Check if unlocked */ isUnlocked(recipeId) { return this.unlockedRecipes.has(recipeId); } /** * Use a blueprint item from inventory */ useBlueprint(itemId) { const recipeId = this.blueprints[itemId]; if (!recipeId) return false; const success = this.unlockRecipe(recipeId); if (success) { // Consume item this.scene.inventorySystem.removeItem(itemId, 1); return true; } return false; } /** * Try to get a blueprint drop from mining/killing * @param {string} source 'mining', 'combat', 'chest' */ tryDropBlueprint(x, y, source) { let chance = 0.05; // 5% base chance if (source === 'boss') chance = 1.0; if (source === 'chest') chance = 0.3; if (Math.random() < chance) { // Select random locked blueprint const allBlueprints = Object.keys(this.blueprints); const dropItem = allBlueprints[Math.floor(Math.random() * allBlueprints.length)]; // Check if user already has it unlocked? Maybe drop anyway for trading? // For now, simple drop. if (this.scene.interactionSystem) { this.scene.interactionSystem.spawnLoot(x, y, dropItem, 1); console.log(`📜 Dropped Blueprint: ${dropItem}`); } } } }