about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorana <ana@ana.st>2021-08-08 18:51:22 +0200
committerana <ana@ana.st>2021-08-08 18:51:22 +0200
commit16ac6113b10382278538bf379643eb13cd40e9af (patch)
tree80f6ce7a179376502e31612b343e3947c0b06a27 /src
parent3466921a669662ad2476fbad715893aefd626eb2 (diff)
downloadeureka-marks-16ac6113b10382278538bf379643eb13cd40e9af.tar.gz
feat: say when mutation/augmentation expires
Diffstat (limited to 'src')
-rw-r--r--src/App.svelte49
1 files changed, 30 insertions, 19 deletions
diff --git a/src/App.svelte b/src/App.svelte
index ec260ff..618d850 100644
--- a/src/App.svelte
+++ b/src/App.svelte
@@ -1,17 +1,12 @@
 <script>
   import { level, paWeather, aWeather, hWeather, pyWeather } from "./stores";
   import ew from "./ew";
-  import { onMount } from "svelte";
   import { formatUtc } from "./times";
   import { getMatches } from "./bestiary";
   import day from "dayjs";
   import relativeTime from "dayjs/plugin/relativeTime";
   day.extend(relativeTime);
 
-  onMount(async () => {
-    updateWeatherStores();
-  });
-
   let date = new Date().getTime() * (1440 / 70);
   let matches,
     upMatches,
@@ -59,16 +54,7 @@
   }
 
   function newMatches() {
-    let forecast;
-    if ($level >= 20 && $level < 35) {
-      forecast = pagosForecast;
-    } else if ($level >= 35 && $level < 50) {
-      forecast = pyrosForecast;
-    } else if ($level >= 50) {
-      forecast = hydatosForecast;
-    } else {
-      forecast = anemosForecast;
-    }
+    let forecast = getZoneForecast();
     matches = getMatches(forecast, $level).sort((a, b) => a.level < b.level);
 
     upMatches = matches.filter((m) => m.uptime.isUp);
@@ -76,6 +62,18 @@
     otherMatches = matches.filter((m) => m.special && !m.uptime.isUp);
   }
 
+  function getZoneForecast() {
+    if ($level >= 20 && $level < 35) {
+      return pagosForecast;
+    } else if ($level >= 35 && $level < 50) {
+      return pyrosForecast;
+    } else if ($level >= 50) {
+      return hydatosForecast;
+    } else {
+      return anemosForecast;
+    }
+  }
+
   function getWeatherChangeTime() {
     // Doesn't matter which forecast
     return day(anemosForecast[1].date).fromNow();
@@ -98,11 +96,25 @@
     });
 
     if (i) {
-      return `in ${day(pagosForecast[i + 1].date).fromNow()}`;
+      return `in ${day(getZoneForecast()[i + 1].date).fromNow()}`;
     }
     return "in the far future";
   }
 
+  function formatUptimeUntil(futures) {
+    let i;
+    futures.find((f, idx) => {
+      if (!f) i = idx;
+      return !f;
+    });
+
+    if (i) {
+      return `until ${day(getZoneForecast()[i + 1].date).fromNow()}`;
+    }
+
+    return "for a long time";
+  }
+
   function levelChanged(evt) {
     level.set(Number(evt.target.value));
     newMatches();
@@ -134,9 +146,8 @@
         {#each upMatches as m (m.name + m.level)}
           <li>
             <em>(Lv{formatLevel(m)})</em> <strong>{m.name}</strong>
-            ({#if m.mutating}mutates{/if}{#if m.augmenting}augments{/if} in {formatWeathers(
-              m.uptime.weathers
-            )})
+            ({#if m.mutating}mutates{/if}{#if m.augmenting}augments{/if}
+            {formatUptimeUntil(m.uptime.futureUptime)})
           </li>
         {/each}
       </ul>