// Инициализация игры class RealityOS { constructor() { this.player = { name: "Влад", age: 20, profession: "Системный инженер АПС и СОУЭ", location: "Москва, Дорогобужская 9", financialGoal: 1000000, currentPortfolio: 4726, currentIncome: 165000, credits: 300000, characteristics: { sw: 450, // Сила воли hp: 750, // Энергия disc: 600, // Дисциплина fg: 350, // Финансовая грамотность tech: 550, // Техническая экспертиза sys: 500, // Системное мышление ldr: 250, // Лидерство str: 400 // Стрессоустойчивость }, levels: { engineering: { level: 4, exp: 650000, maxExp: 1000000, title: "Бригадир монтажников" }, investing: { level: 1, exp: 4726, maxExp: 150000, title: "Финансовый новичок" }, personal: { level: 2, exp: 112500, maxExp: 250000, title: "Самопознающий" } } }; this.init(); } init() { this.renderStats(); this.renderLevels(); this.initCharts(); this.setupEventListeners(); } renderStats() { // Обновляем характеристики const stats = this.player.characteristics; document.querySelector('.stat-value:nth-child(1)').textContent = `${stats.sw}/1000`; document.querySelector('.progress-fill:nth-child(1)').style.width = `${stats.sw/10}%`; document.querySelector('.stat-value:nth-child(2)').textContent = `${stats.hp}/1000`; document.querySelector('.progress-fill:nth-child(2)').style.width = `${stats.hp/10}%`; document.querySelector('.stat-value:nth-child(3)').textContent = `${stats.disc}/1000`; document.querySelector('.progress-fill:nth-child(3)').style.width = `${stats.disc/10}%`; document.querySelector('.stat-value:nth-child(4)').textContent = `${stats.fg}/1000`; document.querySelector('.progress-fill:nth-child(4)').style.width = `${stats.fg/10}%`; document.querySelector('.stat-value:nth-child(5)').textContent = `${stats.tech}/1000`; document.querySelector('.progress-fill:nth-child(5)').style.width = `${stats.tech/10}%`; document.querySelector('.stat-value:nth-child(6)').textContent = `${stats.sys}/1000`; document.querySelector('.progress-fill:nth-child(6)').style.width = `${stats.sys/10}%`; document.querySelector('.stat-value:nth-child(7)').textContent = `${stats.ldr}/1000`; document.querySelector('.progress-fill:nth-child(7)').style.width = `${stats.ldr/10}%`; document.querySelector('.stat-value:nth-child(8)').textContent = `${stats.str}/1000`; document.querySelector('.progress-fill:nth-child(8)').style.width = `${stats.str/10}%`; // Обновляем финансовый прогресс const progressPercent = (this.player.currentPortfolio / this.player.financialGoal) * 100; document.querySelector('.financial-stats span:first-child').textContent = `Текущий портфель: ${this.player.currentPortfolio.toLocaleString()} ₽`; document.querySelector('.financial-stats span:last-child').textContent = `Цель: ${this.player.financialGoal.toLocaleString()} ₽`; document.querySelector('.financial-goal .progress-fill').style.width = `${progressPercent}%`; } renderLevels() { // Обновляем уровни const engLevel = this.player.levels.engineering; const invLevel = this.player.levels.investing; const perLevel = this.player.levels.personal; document.querySelectorAll('.level-card')[0].innerHTML = `
Уровень ${engLevel.level}: ${engLevel.title}
${engLevel.exp.toLocaleString()}/${engLevel.maxExp.toLocaleString()} EXP `; document.querySelectorAll('.level-card')[1].innerHTML = `Уровень ${invLevel.level}: ${invLevel.title}
${invLevel.exp.toLocaleString()}/${invLevel.maxExp.toLocaleString()} EXP `; document.querySelectorAll('.level-card')[2].innerHTML = `Уровень ${perLevel.level}: ${perLevel.title}
${perLevel.exp.toLocaleString()}/${perLevel.maxExp.toLocaleString()} EXP `; } initCharts() { const ctx = document.getElementById('progressChart').getContext('2d'); this.chart = new Chart(ctx, { type: 'line', data: { labels: ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'], datasets: [{ label: 'Прогресс по характеристикам', data: [ this.player.characteristics.sw, this.player.characteristics.hp, this.player.characteristics.disc, this.player.characteristics.fg, this.player.characteristics.tech, this.player.characteristics.sys, this.player.characteristics.ldr ], borderColor: '#3498db', backgroundColor: 'rgba(52, 152, 219, 0.1)', tension: 0.4, fill: true }] }, options: { responsive: true, maintainAspectRatio: false, scales: { y: { beginAtZero: true, max: 1000 } } } }); } setupEventListeners() { // Кнопки быстрого ввода document.querySelectorAll('.action-btn').forEach(button => { button.addEventListener('click', (e) => { const action = e.target.textContent; this.handleQuickAction(action); }); }); // Форма ручного ввода document.querySelector('.manual-input').addEventListener('submit', (e) => { e.preventDefault(); this.handleManualInput(); }); // Вкладки отчетов document.querySelectorAll('.tab-btn').forEach(button => { button.addEventListener('click', (e) => { document.querySelectorAll('.tab-btn').forEach(btn => btn.classList.remove('active')); e.target.classList.add('active'); this.updateReportContent(e.target.textContent); }); }); // Кнопки футера document.querySelectorAll('.footer-btn').forEach(button => { button.addEventListener('click', (e) => { const action = e.target.textContent.trim(); this.handleFooterAction(action); }); }); } handleQuickAction(action) { let expGain = 0; let characteristic = ''; switch(action) { case '💼 Работа': expGain = 50; characteristic = 'tech'; break; case '💰 Инвестиции': expGain = 30; characteristic = 'fg'; break; case '🧘 Тренировка': expGain = 40; characteristic = 'hp'; break; case '📚 Обучение': expGain = 35; characteristic = 'sys'; break; case '📝 Медитация': expGain = 25; characteristic = 'sw'; break; case '🏖️ Отдых': expGain = 20; characteristic = 'hp'; break; } if (characteristic) { this.player.characteristics[characteristic] += expGain; if (this.player.characteristics[characteristic] > 1000) { this.player.characteristics[characteristic] = 1000; } // Также добавляем EXP в соответствующую ветку if (characteristic === 'tech') { this.player.levels.engineering.exp += expGain * 100; if (this.player.levels.engineering.exp >= this.player.levels.engineering.maxExp) { this.levelUp('engineering'); } } else if (characteristic === 'fg') { this.player.levels.investing.exp += expGain * 100; if (this.player.levels.investing.exp >= this.player.levels.investing.maxExp) { this.levelUp('investing'); } } else { this.player.levels.personal.exp += expGain * 100; if (this.player.levels.personal.exp >= this.player.levels.personal.maxExp) { this.levelUp('personal'); } } this.renderStats(); this.renderLevels(); this.showNotification(`Получено ${expGain} EXP за ${action}`); } } handleManualInput() { const activityType = document.getElementById('activity-type').value; const description = document.getElementById('activity-description').value; const expAmount = parseInt(document.getElementById('exp-amount').value) || 0; if (!description || expAmount <= 0) { this.showNotification('Пожалуйста, заполните все поля корректно', 'error'); return; } // Добавляем EXP в зависимости от типа активности switch(activityType) { case 'career': this.player.levels.engineering.exp += expAmount; if (this.player.levels.engineering.exp >= this.player.levels.engineering.maxExp) { this.levelUp('engineering'); } break; case 'finance': this.player.levels.investing.exp += expAmount; if (this.player.levels.investing.exp >= this.player.levels.investing.maxExp) { this.levelUp('investing'); } this.player.currentPortfolio += expAmount; // Упрощение для демонстрации break; case 'personal': this.player.levels.personal.exp += expAmount; if (this.player.levels.personal.exp >= this.player.levels.personal.maxExp) { this.levelUp('personal'); } break; } this.renderStats(); this.renderLevels(); this.showNotification(`Добавлено ${expAmount} EXP: ${description}`); // Очищаем форму document.getElementById('activity-description').value = ''; document.getElementById('exp-amount').value = ''; } levelUp(branch) { this.player.levels[branch].level++; this.player.levels[branch].exp = 0; // Увеличиваем максимальный EXP для следующего уровня const nextLevel = this.player.levels[branch].level; switch(branch) { case 'engineering': this.player.levels[branch].maxExp = nextLevel < 15 ? Math.pow(2, nextLevel) * 50000 : 180000000; this.player.levels[branch].title = this.getEngineeringTitle(nextLevel); break; case 'investing': this.player.levels[branch].maxExp = nextLevel < 12 ? nextLevel * 150000 : 50000000; this.player.levels[branch].title = this.getInvestingTitle(nextLevel); break; case 'personal': this.player.levels[branch].maxExp = nextLevel < 10 ? nextLevel * 100000 : 16000000; this.player.levels[branch].title = this.getPersonalTitle(nextLevel); break; } this.showNotification(`🎉 Повышение уровня! Теперь вы: ${this.player.levels[branch].title}`, 'success'); } getEngineeringTitle(level) { const titles = [ "", "Монтажник-стажер", "Монтажник", "Старший монтажник", "Бригадир монтажников", "Младший наладчик", "Наладчик", "Старший наладчик", "Инженер-проектировщик", "Старший инженер-проектировщик", "Lead инженер", "Руководитель проектов", "Начальник отдела", "Технический директор", "Директор по развитию", "Основатель технологической компании" ]; return titles[level] || "Неизвестный уровень"; } getInvestingTitle(level) { const titles = [ "", "Финансовый новичок", "Начинающий инвестор", "Активный инвестор", "Опытный инвестор", "Специалист по ВДО", "Портфельный менеджер", "Профессиональный инвестор", "Инвестиционный аналитик", "Старший инвестор", "Инвестиционный стратег", "Управляющий активами", "Капитан рынка" ]; return titles[level] || "Неизвестный уровень"; } getPersonalTitle(level) { const titles = [ "", "Искатель", "Самопознающий", "Практик", "Осознанный", "Дисциплинированный", "Сбалансированный", "Мастер привычек", "Лидер", "Мудрец", "Просветленный" ]; return titles[level] || "Неизвестный уровень"; } updateReportContent(period) { const reportContent = document.querySelector('.report-content'); switch(period) { case 'Ежедневно': reportContent.innerHTML = `