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 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
// Инициализация игры
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 = `
            <h4>Инженерная ветка</h4>
            <p>Уровень ${engLevel.level}: ${engLevel.title}</p>
            <div class="progress-bar">
                <div class="progress-fill" style="width: ${(engLevel.exp/engLevel.maxExp)*100}%"></div>
            </div>
            <span>${engLevel.exp.toLocaleString()}/${engLevel.maxExp.toLocaleString()} EXP</span>
        `;
        
        document.querySelectorAll('.level-card')[1].innerHTML = `
            <h4>Инвесторская ветка</h4>
            <p>Уровень ${invLevel.level}: ${invLevel.title}</p>
            <div class="progress-bar">
                <div class="progress-fill" style="width: ${(invLevel.exp/invLevel.maxExp)*100}%"></div>
            </div>
            <span>${invLevel.exp.toLocaleString()}/${invLevel.maxExp.toLocaleString()} EXP</span>
        `;
        
        document.querySelectorAll('.level-card')[2].innerHTML = `
            <h4>Личностная ветка</h4>
            <p>Уровень ${perLevel.level}: ${perLevel.title}</p>
            <div class="progress-bar">
                <div class="progress-fill" style="width: ${(perLevel.exp/perLevel.maxExp)*100}%"></div>
            </div>
            <span>${perLevel.exp.toLocaleString()}/${perLevel.maxExp.toLocaleString()} EXP</span>
        `;
    }
    
    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 = `
                    <h3>Ежедневная статистика</h3>
                    <ul>
                        <li>💼 Работа: 8 часов</li>
                        <li>💰 Инвестиции: 30 минут</li>
                        <li>🧘 Тренировка: 1 час</li>
                        <li>📚 Обучение: 2 часа</li>
                    </ul>
                `;
                break;
            case 'Еженедельно':
                reportContent.innerHTML = `
                    <h3>Еженедельный аудит</h3>
                    <ul>
                        <li>📈 Прогресс по всем веткам: +2.5%</li>
                        <li>💰 Финансовый портфель: +1,200 ₽</li>
                        <li>🎯 Выполнено 4 из 5 недельных квестов</li>
                        <li>🏆 Получено 2 достижения</li>
                    </ul>
                `;
                break;
            case 'Ежемесячно':
                reportContent.innerHTML = `
                    <h3>Ежемесячный отчет</h3>
                    <ul>
                        <li>📊 Общий прогресс: +12%</li>
                        <li>💰 Доход: 165,000 ₽</li>
                        <li>📈 Инвестиционная доходность: 1.8%</li>
                        <li>🎯 Достигнуты 2 цели из 5</li>
                    </ul>
                `;
                break;
            case 'Годовые цели':
                reportContent.innerHTML = `
                    <h3>Годовые цели</h3>
                    <ul>
                        <li>🚀 Достичь уровня 6 в инженерной ветке</li>
                        <li>💰 Накопить 150,000 ₽ в портфеле</li>
                        <li>🧠 Повысить все характеристики до 600+</li>
                        <li>🏆 Получить 10 достижений</li>
                    </ul>
                `;
                break;
        }
    }
    
    handleFooterAction(action) {
        switch(action) {
            case '💾 Сохранить':
                this.saveGame();
                break;
            case '📤 Экспорт данных':
                this.exportData();
                break;
            case '📥 Импорт данных':
                this.importData();
                break;
        }
    }
    
    saveGame() {
        localStorage.setItem('realityOS_save', JSON.stringify(this.player));
        this.showNotification('Игра сохранена успешно!', 'success');
    }
    
    exportData() {
        const dataStr = JSON.stringify(this.player);
        const dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(dataStr);
        
        const exportFileDefaultName = 'reality_os_save.json';
        
        const linkElement = document.createElement('a');
        linkElement.setAttribute('href', dataUri);
        linkElement.setAttribute('download', exportFileDefaultName);
        linkElement.click();
        
        this.showNotification('Данные экспортированы!', 'success');
    }
    
    importData() {
        const input = document.createElement('input');
        input.type = 'file';
        input.accept = '.json';
        
        input.onchange = e => {
            const file = e.target.files[0];
            const reader = new FileReader();
            reader.onload = event => {
                try {
                    const data = JSON.parse(event.target.result);
                    this.player = data;
                    this.renderStats();
                    this.renderLevels();
                    this.showNotification('Данные импортированы успешно!', 'success');
                } catch (error) {
                    this.showNotification('Ошибка при импорте данных', 'error');
                }
            };
            reader.readAsText(file);
        };
        
        input.click();
    }
    
    showNotification(message, type = 'info') {
        // Создаем элемент уведомления
        const notification = document.createElement('div');
        notification.className = `notification ${type}`;
        notification.textContent = message;
        
        // Стили для уведомления
        Object.assign(notification.style, {
            position: 'fixed',
            top: '20px',
            right: '20px',
            padding: '15px 25px',
            borderRadius: '8px',
            color: 'white',
            fontWeight: 'bold',
            zIndex: '1000',
            boxShadow: '0 5px 15px rgba(0,0,0,0.3)',
            transform: 'translateX(100%)',
            transition: 'transform 0.3s ease'
        });
        
        // Цвета для разных типов уведомлений
        if (type === 'success') {
            notification.style.background = 'linear-gradient(135deg, #2ecc71, #27ae60)';
        } else if (type === 'error') {
            notification.style.background = 'linear-gradient(135deg, #e74c3c, #c0392b)';
        } else {
            notification.style.background = 'linear-gradient(135deg, #3498db, #2980b9)';
        }
        
        document.body.appendChild(notification);
        
        // Анимация появления
        setTimeout(() => {
            notification.style.transform = 'translateX(0)';
        }, 100);
        
        // Удаление через 3 секунды
        setTimeout(() => {
            notification.style.transform = 'translateX(100%)';
            setTimeout(() => {
                document.body.removeChild(notification);
            }, 300);
        }, 3000);
    }
}

// Инициализация игры при загрузке страницы
document.addEventListener('DOMContentLoaded', () => {
    window.game = new RealityOS();
});