Moved function to better location

This commit is contained in:
Dev 2024-10-17 14:14:17 +01:00
parent 953acb47a0
commit ec825d990c
2 changed files with 11 additions and 5 deletions

View File

@ -106,21 +106,23 @@ export class WeatherGenerator {
return result;
}
/**
* Choose a temprature for the raid based on time of day and current season
* @param currentSeason What season tarkov is currently in
* @param inRaidTimestamp What time is the raid running at
* @returns Timestamp
*/
protected getRaidTemperature(currentSeason: Season, inRaidTimestamp: number): number {
// Convert timestamp to date so we can get current hour and check if its day or night
const currentRaidTime = new Date(inRaidTimestamp);
const seasonDayNightTempValues = this.weatherConfig.weather.temp[currentSeason];
const minMax = this.isNightTime(currentRaidTime.getHours())
const minMax = this.weatherHelper.isHourAtNightTime(currentRaidTime.getHours())
? seasonDayNightTempValues.night
: seasonDayNightTempValues.day;
return Number.parseFloat(this.randomUtil.getFloat(minMax.min, minMax.max).toPrecision(2));
}
protected isNightTime(currentHour: number) {
return currentHour > 21 && currentHour <= 5;
}
/**
* Set IWeather date/time/timestamp values to now
* @param weather Object to update

View File

@ -52,4 +52,8 @@ export class WeatherHelper {
// Night if after 9pm or before 5am
return time.getHours() > 21 || time.getHours() < 5;
}
public isHourAtNightTime(currentHour: number) {
return currentHour > 21 && currentHour <= 5;
}
}