class CollectionSystem { constructor(scene) { this.scene = scene; this.unlockedItems = new Set(); // Database of Collectables this.items = { // Resources 'wood': { name: 'Wood', desc: 'Basic building material.', category: 'Resource' }, 'stone': { name: 'Stone', desc: 'Hard rock for walls.', category: 'Resource' }, 'ore_gold': { name: 'Gold Ore', desc: 'Shiny ore found underground.', category: 'Resource' }, 'gold_bar': { name: 'Gold Bar', desc: 'Refined gold ingot.', category: 'Resource' }, // Crops 'seeds': { name: 'Seeds', desc: 'Mystery seeds.', category: 'Farming' }, 'wheat': { name: 'Wheat', desc: 'Staple grain.', category: 'Farming' }, 'corn': { name: 'Corn', desc: 'Tall growing crop.', category: 'Farming' }, // Rare 'item_bone': { name: 'Bone', desc: 'Remains of a zombie.', category: 'Rare' }, 'item_scrap': { name: 'Scrap Metal', desc: 'Old machinery parts.', category: 'Rare' }, 'item_chip': { name: 'Microchip', desc: 'High-tech component.', category: 'Rare' }, 'coin_gold': { name: 'Gold Coin', desc: 'Currency of the new world.', category: 'Rare' }, 'artefact_old': { name: 'Ancient Pot', desc: 'A relict from the past.', category: 'Archaeology' }, // Nature 'flower_red': { name: 'Red Flower', desc: 'Beautiful bloom.', category: 'Nature' }, 'flower_yellow': { name: 'Yellow Flower', desc: 'Bright bloom.', category: 'Nature' }, 'flower_blue': { name: 'Blue Flower', desc: 'Rare blue bloom.', category: 'Nature' }, 'mushroom_red': { name: 'Red Mushroom', desc: 'Looks poisonous.', category: 'Nature' }, 'mushroom_brown': { name: 'Brown Mushroom', desc: 'Edible fungus.', category: 'Nature' } }; } unlock(itemId) { if (!this.items[itemId]) return; // Not a collectable if (!this.unlockedItems.has(itemId)) { this.unlockedItems.add(itemId); console.log(`📖 Collection Unlocked: ${itemId}`); // Notification this.scene.events.emit('show-floating-text', { x: this.scene.player.sprite.x, y: this.scene.player.sprite.y - 80, text: `New Collection Entry!`, color: '#FFD700' }); if (this.scene.soundManager && typeof this.scene.soundManager.playSuccess === 'function') { this.scene.soundManager.playSuccess(); } else if (this.scene.soundManager && typeof this.scene.soundManager.playHarvest === 'function') { this.scene.soundManager.playHarvest(); // Fallback to harvest sound } } } has(itemId) { return this.unlockedItems.has(itemId); } getProgress() { const total = Object.keys(this.items).length; const unlocked = this.unlockedItems.size; return { unlocked, total, percent: (unlocked / total) * 100 }; } // Save/Load Logic toJSON() { return Array.from(this.unlockedItems); } load(data) { if (Array.isArray(data)) { this.unlockedItems = new Set(data); } } }