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