Files
Hommie_RPG_Game/js/game/Seasons.js
Maxim Dolgolyov fb5f09212b Initial commit: 3D Hommie RPG game
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-25 01:04:09 +03:00

114 lines
3.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export class Seasons {
constructor(game) {
this.game = game;
this.current = 'autumn';
this.dayInSeason = 0;
this.daysPerSeason = 7;
this.seasonIndex = 2; // autumn
this.lastDay = 0;
}
update() {
if (this.game.gameDay !== this.lastDay) {
this.lastDay = this.game.gameDay;
this.dayInSeason++;
if (this.dayInSeason > this.daysPerSeason) {
const prevSeason = this.current;
this.dayInSeason = 1;
this.seasonIndex = (this.seasonIndex + 1) % 4;
this.current = Seasons.SEASONS[this.seasonIndex];
this.game.notify(`Наступила ${this.getName()}! ${this.getIcon()}`, 'good');
// Пережили зиму
if (prevSeason === 'winter') {
this.game.questSystem.onEvent('survive_winter');
}
}
}
}
// Модификатор базовой температуры
getTemperatureModifier() {
switch (this.current) {
case 'winter': return -15;
case 'spring': return -2;
case 'summer': return 10;
case 'autumn': return -5;
default: return 0;
}
}
// Множитель потери тепла
getWarmthDrain() {
switch (this.current) {
case 'winter': return 1.5;
case 'spring': return 0.8;
case 'summer': return 0.3;
case 'autumn': return 1.0;
default: return 1;
}
}
// Множитель потери голода
getHungerDrain() {
switch (this.current) {
case 'winter': return 1.3;
case 'summer': return 0.8;
default: return 1;
}
}
// Веса погодных типов для каждого сезона
getWeatherWeights() {
switch (this.current) {
case 'winter': return { clear: 1, rain: 1, snow: 5, fog: 3 };
case 'spring': return { clear: 3, rain: 4, snow: 0, fog: 2 };
case 'summer': return { clear: 5, rain: 2, snow: 0, fog: 1 };
case 'autumn': return { clear: 2, rain: 4, snow: 1, fog: 3 };
default: return { clear: 3, rain: 2, snow: 1, fog: 1 };
}
}
getName() {
return Seasons.NAMES[this.current];
}
getIcon() {
return Seasons.ICONS[this.current];
}
getDaysLeft() {
return this.daysPerSeason - this.dayInSeason;
}
getSaveData() {
return {
current: this.current,
dayInSeason: this.dayInSeason,
seasonIndex: this.seasonIndex,
lastDay: this.lastDay
};
}
loadSaveData(data) {
if (data) {
this.current = data.current || 'autumn';
this.dayInSeason = data.dayInSeason || 0;
this.seasonIndex = data.seasonIndex || 2;
this.lastDay = data.lastDay || 0;
}
}
reset() {
this.current = 'autumn';
this.dayInSeason = 0;
this.seasonIndex = 2;
this.lastDay = 0;
}
}
Seasons.SEASONS = ['spring', 'summer', 'autumn', 'winter'];
Seasons.NAMES = { spring: 'Весна', summer: 'Лето', autumn: 'Осень', winter: 'Зима' };
Seasons.ICONS = { spring: '🌱', summer: '☀️', autumn: '🍂', winter: '❄️' };