export class Equipment { constructor(game) { this.game = game; // Слоты экипировки this.slots = { head: null, body: null, feet: null, hands: null }; // Все предметы экипировки this.allItems = { // Голова old_hat: { slot: 'head', name: 'Старая шапка', icon: '🧢', warmth: 5, protection: 0, mood: 0, tier: 1 }, hood: { slot: 'head', name: 'Капюшон', icon: '🪖', warmth: 8, protection: 2, mood: 0, tier: 2 }, warm_hat: { slot: 'head', name: 'Тёплая шапка', icon: '🎩', warmth: 15, protection: 0, mood: 3, tier: 3 }, helmet: { slot: 'head', name: 'Каска', icon: '⛑️', warmth: 3, protection: 8, mood: -2, tier: 3 }, // Тело old_jacket: { slot: 'body', name: 'Драная куртка', icon: '🧥', warmth: 10, protection: 2, mood: 0, tier: 1 }, coat: { slot: 'body', name: 'Пальто', icon: '🧥', warmth: 18, protection: 3, mood: 2, tier: 2 }, warm_jacket:{ slot: 'body', name: 'Тёплая куртка', icon: '🧥', warmth: 25, protection: 5, mood: 3, tier: 3 }, vest: { slot: 'body', name: 'Жилетка', icon: '🦺', warmth: 8, protection: 10, mood: 0, tier: 3 }, // Ноги old_boots: { slot: 'feet', name: 'Рваные ботинки', icon: '👞', warmth: 5, protection: 1, mood: 0, tier: 1 }, boots: { slot: 'feet', name: 'Ботинки', icon: '🥾', warmth: 10, protection: 3, mood: 1, tier: 2 }, warm_boots: { slot: 'feet', name: 'Тёплые сапоги', icon: '🥾', warmth: 18, protection: 4, mood: 2, tier: 3 }, // Руки old_gloves: { slot: 'hands', name: 'Дырявые перчатки', icon: '🧤', warmth: 3, protection: 0, mood: 0, tier: 1 }, gloves: { slot: 'hands', name: 'Перчатки', icon: '🧤', warmth: 8, protection: 2, mood: 1, tier: 2 }, warm_gloves:{ slot: 'hands', name: 'Тёплые перчатки', icon: '🧤', warmth: 14, protection: 3, mood: 2, tier: 3 }, }; } equip(itemKey) { const item = this.allItems[itemKey]; if (!item) return false; const prevItem = this.slots[item.slot]; this.slots[item.slot] = itemKey; if (prevItem) { this.game.notify(`Снято: ${this.allItems[prevItem].name}`); // Возвращаем в инвентарь this.game.inventory.addItem('eq_' + prevItem, 1); } this.game.notify(`Экипировано: ${item.name}`, 'good'); this.game.sound.playPickup(); // Проверка полной экипировки if (this.getFilledSlots() === 4) { this.game.questSystem.onEvent('full_equipment'); } return true; } unequip(slot) { const itemKey = this.slots[slot]; if (!itemKey) return false; this.slots[slot] = null; this.game.inventory.addItem('eq_' + itemKey, 1); this.game.notify(`Снято: ${this.allItems[itemKey].name}`); return true; } getEquipped(slot) { const key = this.slots[slot]; if (!key) return null; return { key, ...this.allItems[key] }; } // Общий бонус тепла от экипировки getWarmthBonus() { let total = 0; for (const key of Object.values(this.slots)) { if (key && this.allItems[key]) { total += this.allItems[key].warmth; } } return total; } // Общий бонус защиты (снижение урона в %) getProtectionBonus() { let total = 0; for (const key of Object.values(this.slots)) { if (key && this.allItems[key]) { total += this.allItems[key].protection; } } return Math.min(50, total); // Максимум 50% снижения } // Общий бонус настроения getMoodBonus() { let total = 0; for (const key of Object.values(this.slots)) { if (key && this.allItems[key]) { total += this.allItems[key].mood; } } return total; } // Количество слотов заполнено getFilledSlots() { return Object.values(this.slots).filter(v => v !== null).length; } getSaveData() { return { slots: { ...this.slots } }; } loadSaveData(data) { if (data && data.slots) { this.slots = { ...data.slots }; } } reset() { this.slots = { head: null, body: null, feet: null, hands: null }; } }