diff options
author | ana <ana@ana.st> | 2021-08-08 19:17:02 +0200 |
---|---|---|
committer | ana <ana@ana.st> | 2021-08-08 19:17:02 +0200 |
commit | e74892159c53d29281fc24cf01dd87528d223dc9 (patch) | |
tree | 4a92fb8fd6f14cb42565b1b7d54f5c55415f91e5 /src | |
parent | cc0ef3e4f905f5c3c6441069bdb3bf8a78ac1314 (diff) | |
download | eureka-marks-e74892159c53d29281fc24cf01dd87528d223dc9.tar.gz |
fix: account for d/n when predicting future stuff
Diffstat (limited to 'src')
-rw-r--r-- | src/App.svelte | 14 | ||||
-rw-r--r-- | src/bestiary.js | 11 |
2 files changed, 10 insertions, 15 deletions
diff --git a/src/App.svelte b/src/App.svelte index 4cc445f..502f465 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -28,20 +28,6 @@ }, 10000); // 10 seconds $: currentEzTime = formatUtc(date); - function formatWeathers(weathers) { - if (weathers.length === 1) { - return ew.getWeatherName(weathers[0]); - } - return weathers - .map((w, i) => { - if (i + 1 === weathers.length) { - return `and ${ew.getWeatherName(w)}`; - } - return `${ew.getWeatherName(w)}, `; - }) - .join(""); - } - function newForecasts() { anemosForecast = ew.forecast(ew.ANEMOS_WEATHER, "anemos"); pagosForecast = ew.forecast(ew.PAGOS_WEATHER, "pagos"); diff --git a/src/bestiary.js b/src/bestiary.js index b09a613..6eac997 100644 --- a/src/bestiary.js +++ b/src/bestiary.js @@ -46,7 +46,7 @@ function findForecastMatch(forecast, conditions) { isUp: forecastMatches(forecast, conditions[dn], 0), weathers: conditions[dn], futureUptime: [1, 2, 3, 4].map((i) => { - return forecastMatches(forecast, conditions[dn], i); + return futureForecastMatches(forecast, conditions, i); }), }; } @@ -55,3 +55,12 @@ function forecastMatches(forecast, condition, index) { const currWeather = forecast[index].currWeather; return condition.some((c) => c === currWeather); } + +function futureForecastMatches(forecast, conditions, index) { + const fc = forecast[index]; + const fcTime = day((fc.date.getTime() * 1440) / 70); + const dn = day(fcTime).isBetween(fcTime.hour(8), fcTime.hour(18)) + ? "day" + : "night"; + return conditions[dn].some((c) => c === fc.currWeather); +} |