Updated getRaidTemperature()
to take into account the current raid time when choosing temps
This commit is contained in:
parent
0b729fba11
commit
953acb47a0
@ -1,7 +1,7 @@
|
||||
{
|
||||
"acceleration": 7,
|
||||
"weather": {
|
||||
"generateWeatherAmountHours": 24,
|
||||
"generateWeatherAmountHours": 24,
|
||||
"clouds": {
|
||||
"values": [-1, 0, 0.5, 1, 1.5],
|
||||
"weights": [100, 15, 5, 4, 3]
|
||||
@ -31,78 +31,102 @@
|
||||
"weights": [25, 8, 5, 5, 1]
|
||||
},
|
||||
"temp": {
|
||||
"0": {
|
||||
"min": 17,
|
||||
"max": 32
|
||||
},
|
||||
"0": {
|
||||
"day": {
|
||||
"min": 17,
|
||||
"max": 32
|
||||
},
|
||||
"night": {
|
||||
"min": 14,
|
||||
"max": 24
|
||||
}
|
||||
},
|
||||
"1": {
|
||||
"min": 7,
|
||||
"max": 15
|
||||
},
|
||||
"day": {
|
||||
"min": 7,
|
||||
"max": 15
|
||||
},
|
||||
"night": {
|
||||
"min": 2,
|
||||
"max": 12
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"min": -10,
|
||||
"max": 5
|
||||
},
|
||||
"day": {
|
||||
"min": -10,
|
||||
"max": 5
|
||||
},
|
||||
"night": {
|
||||
"min": -20,
|
||||
"max": 0
|
||||
}
|
||||
},
|
||||
"3": {
|
||||
"min": 1,
|
||||
"max": 15
|
||||
},
|
||||
"day": {
|
||||
"min": 1,
|
||||
"max": 15
|
||||
},
|
||||
"night": {
|
||||
"min": -10,
|
||||
"max": 5
|
||||
}
|
||||
},
|
||||
"4": {
|
||||
"min": 0,
|
||||
"max": 24
|
||||
}
|
||||
"day": {
|
||||
"min": 0,
|
||||
"max": 24
|
||||
},
|
||||
"night": {
|
||||
"min": -10,
|
||||
"max": 8
|
||||
}
|
||||
}
|
||||
},
|
||||
"pressure": {
|
||||
"min": 760,
|
||||
"max": 780
|
||||
},
|
||||
"timePeriod": {
|
||||
"values": [15, 30],
|
||||
"timePeriod": {
|
||||
"values": [15, 30],
|
||||
"weights": [1, 2]
|
||||
}
|
||||
}
|
||||
},
|
||||
"seasonDates": [
|
||||
{
|
||||
"seasonDates": [{
|
||||
"seasonType": 0,
|
||||
"name": "SUMMER",
|
||||
"startDay": "2",
|
||||
"startMonth": "6",
|
||||
"endDay": "15",
|
||||
"endMonth": "10"
|
||||
},
|
||||
{
|
||||
}, {
|
||||
"seasonType": 1,
|
||||
"name": "AUTUMN",
|
||||
"startDay": "15",
|
||||
"startMonth": "10",
|
||||
"endDay": "1",
|
||||
"endMonth": "11"
|
||||
},
|
||||
{
|
||||
}, {
|
||||
"seasonType": 2,
|
||||
"name": "WINTER_END",
|
||||
"startDay": "1",
|
||||
"startMonth": "11",
|
||||
"endDay": "31",
|
||||
"endMonth": "12"
|
||||
},
|
||||
{
|
||||
}, {
|
||||
"seasonType": 2,
|
||||
"name": "WINTER_START",
|
||||
"startDay": "1",
|
||||
"startMonth": "1",
|
||||
"endDay": "24",
|
||||
"endMonth": "3"
|
||||
},
|
||||
{
|
||||
}, {
|
||||
"seasonType": 3,
|
||||
"name": "SPRING",
|
||||
"startDay": "25",
|
||||
"startMonth": "3",
|
||||
"endDay": "2",
|
||||
"endMonth": "6"
|
||||
},
|
||||
{
|
||||
}, {
|
||||
"seasonType": 4,
|
||||
"name": "STORM",
|
||||
"startDay": "24",
|
||||
|
@ -96,21 +96,31 @@ export class WeatherGenerator {
|
||||
time: "",
|
||||
date: "",
|
||||
timestamp: 0, // Added below
|
||||
sptInRaidTimestamp: 0, // Added below
|
||||
};
|
||||
|
||||
this.setCurrentDateTime(result, timestamp);
|
||||
|
||||
result.temp = this.getRaidTemperature(currentSeason, result.time);
|
||||
result.temp = this.getRaidTemperature(currentSeason, result.sptInRaidTimestamp);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected getRaidTemperature(currentSeason: Season, currentTimeBsgFormatted: string): number {
|
||||
// TODO, take into account time of day
|
||||
const minMax = this.weatherConfig.weather.temp[currentSeason];
|
||||
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())
|
||||
? 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
|
||||
@ -125,6 +135,7 @@ export class WeatherGenerator {
|
||||
weather.timestamp = Math.floor(timestamp ? timestamp : inRaidTime.getTime() / 1000); // matches weather.date
|
||||
weather.date = formattedDate; // matches weather.timestamp
|
||||
weather.time = datetimeBsgFormat; // matches weather.timestamp
|
||||
weather.sptInRaidTimestamp = inRaidTime.getTime();
|
||||
}
|
||||
|
||||
protected getWeightedWindDirection(): WindDirection {
|
||||
|
@ -24,4 +24,5 @@ export interface IWeather {
|
||||
time: string;
|
||||
date: string;
|
||||
timestamp: number;
|
||||
sptInRaidTimestamp: number;
|
||||
}
|
||||
|
@ -30,12 +30,17 @@ export interface IWeatherValues {
|
||||
rain: WeatherSettings<number>;
|
||||
rainIntensity: MinMax;
|
||||
fog: WeatherSettings<string>;
|
||||
temp: Record<Season, MinMax>;
|
||||
temp: Record<Season, ITempDayNight>;
|
||||
pressure: MinMax;
|
||||
/** Length of each weather period */
|
||||
timePeriod: WeatherSettings<number>;
|
||||
}
|
||||
|
||||
export interface ITempDayNight {
|
||||
day: MinMax;
|
||||
night: MinMax;
|
||||
}
|
||||
|
||||
export interface WeatherSettings<T> {
|
||||
values: T[];
|
||||
weights: number[];
|
||||
|
Loading…
Reference in New Issue
Block a user