From a06a3cfbfcbf021ce3c8b915e06e5d54593d7a30 Mon Sep 17 00:00:00 2001 From: Dev Date: Sun, 10 Nov 2024 22:54:11 +0000 Subject: [PATCH] Adjusted weather values Reduced chance of fog Reduced chance of constant cloud Adjusted when rain is allowed to occur relative to cloud cover Adding temp values for new seasons --- project/assets/configs/weather.json | 26 +++++++++++++++++++--- project/src/generators/WeatherGenerator.ts | 10 ++++----- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/project/assets/configs/weather.json b/project/assets/configs/weather.json index f24c073d..677685c7 100644 --- a/project/assets/configs/weather.json +++ b/project/assets/configs/weather.json @@ -3,8 +3,8 @@ "weather": { "generateWeatherAmountHours": 24, "clouds": { - "values": [-1, 0.03, 0, 0.5, 1], - "weights": [100, 22, 15, 5, 4] + "values": [-1, -0.8, -0.5, 0.1, 0, 0.15, 0.4, 1], + "weights": [100, 22, 22, 15, 15, 15, 5, 4] }, "windSpeed": { "values": [0, 1, 2, 3, 4], @@ -27,7 +27,7 @@ "max": 1 }, "fog": { - "values": [0.002, 0.004, 0.008, 0.012, 0.087], + "values": [0.0013, 0.0018, 0.002, 0.004, 0.006], "weights": [35, 6, 4, 3, 1] }, "temp": { @@ -72,6 +72,26 @@ } }, "4": { + "day": { + "min": 3, + "max": 11 + }, + "night": { + "min": -2, + "max": 8 + } + }, + "5": { + "day": { + "min": -4, + "max": 7 + }, + "night": { + "min": -10, + "max": 3 + } + }, + "6": { "day": { "min": 0, "max": 24 diff --git a/project/src/generators/WeatherGenerator.ts b/project/src/generators/WeatherGenerator.ts index f2b489fd..5f2cfecf 100644 --- a/project/src/generators/WeatherGenerator.ts +++ b/project/src/generators/WeatherGenerator.ts @@ -83,17 +83,17 @@ export class WeatherGenerator { const clouds = this.getWeightedClouds(); // Force rain to off if no clouds - const rain = clouds <= 2 ? 1 : this.getWeightedRain(); + const rain = clouds <= 0.6 ? 0 : this.getWeightedRain(); const result: IWeather = { cloud: clouds, wind_speed: this.getWeightedWindSpeed(), wind_direction: this.getWeightedWindDirection(), - wind_gustiness: this.getRandomFloat("windGustiness"), + wind_gustiness: this.getRandomFloat("windGustiness", 2), rain: rain, rain_intensity: rain > 1 ? this.getRandomFloat("rainIntensity") : 0, fog: this.getWeightedFog(), - temp: 0, // TODO - lower value at night / take into account season + temp: 0, pressure: this.getRandomFloat("pressure"), time: "", date: "", @@ -177,11 +177,11 @@ export class WeatherGenerator { ).item; } - protected getRandomFloat(node: string): number { + protected getRandomFloat(node: string, precision = 3): number { return Number.parseFloat( this.randomUtil .getFloat(this.weatherConfig.weather[node].min, this.weatherConfig.weather[node].max) - .toPrecision(3), + .toPrecision(precision), ); } }