From ec825d990cc8907cc2999ff3a31db40977ee1bd8 Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 17 Oct 2024 14:14:17 +0100 Subject: [PATCH] Moved function to better location --- project/src/generators/WeatherGenerator.ts | 12 +++++++----- project/src/helpers/WeatherHelper.ts | 4 ++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/project/src/generators/WeatherGenerator.ts b/project/src/generators/WeatherGenerator.ts index e8c83fac..3579ba04 100644 --- a/project/src/generators/WeatherGenerator.ts +++ b/project/src/generators/WeatherGenerator.ts @@ -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 diff --git a/project/src/helpers/WeatherHelper.ts b/project/src/helpers/WeatherHelper.ts index 902d6ce1..10d008b1 100644 --- a/project/src/helpers/WeatherHelper.ts +++ b/project/src/helpers/WeatherHelper.ts @@ -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; + } }