phase 11 part1

This commit is contained in:
2025-12-08 12:30:15 +01:00
parent 3336b59e7d
commit 07f0752d81
15 changed files with 1383 additions and 133 deletions

View File

@@ -1,32 +1,95 @@
/**
* BLUEPRINT SYSTEM
* Manages unlocking crafting recipes via Blueprint items.
*/
class BlueprintSystem {
constructor(scene) {
this.scene = scene;
this.knownRecipes = ['axe', 'pickaxe', 'hoe']; // Default known
this.blueprintsFound = []; // Items found but not learned? Or just list
console.log('📜 BlueprintSystem: Initialized');
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'
};
}
// Called when digging/mining
tryDropBlueprint() {
if (Math.random() < 0.05) { // 5% chance
const newBp = 'blueprint_barn'; // Randomize this
console.log('✨ BLUEPRINT FOUND:', newBp);
return newBp;
/**
* Unlock a recipe
*/
unlockRecipe(recipeId) {
if (this.unlockedRecipes.has(recipeId)) {
console.log(` Recipe ${recipeId} already unlocked.`);
return false;
}
return null;
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;
}
learnBlueprint(id) {
if (!this.knownRecipes.includes(id)) {
this.knownRecipes.push(id);
console.log('🧠 Learned Recipe:', id);
// TODO: Add to Crafting Menu
/**
* 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;
}
hasRecipe(id) {
return this.knownRecipes.includes(id);
/**
* 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}`);
}
}
}
}