about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorana <ana@ana.st>2021-08-08 18:42:35 +0200
committerana <ana@ana.st>2021-08-08 18:42:35 +0200
commit4c8be07bea13c2c8935c1c7869270e96d9221501 (patch)
tree158c1d991bec32f1b6cf7406d53f963dacd6a3a7 /src
parent0ec30df7de63281d6e9e6465309994df555cff85 (diff)
downloadeureka-marks-4c8be07bea13c2c8935c1c7869270e96d9221501.tar.gz
feat: don't load data from other zones
Diffstat (limited to 'src')
-rw-r--r--src/App.svelte34
-rw-r--r--src/bestiary.js16
-rw-r--r--src/ew.js3
-rw-r--r--src/pagos.bestiary.json5
-rw-r--r--src/stores.js2
5 files changed, 39 insertions, 21 deletions
diff --git a/src/App.svelte b/src/App.svelte
index 0e50479..b24bc30 100644
--- a/src/App.svelte
+++ b/src/App.svelte
@@ -30,16 +30,9 @@
   setInterval(() => {
     newForecasts();
     newMatches();
-  }, 300000); // 5 minutes
+  }, 10000); // 10 seconds
   $: currentEzTime = formatUtc(date);
 
-  function updateWeatherStores() {
-    paWeather.set(ew.forecast(ew.PAGOS_WEATHER));
-    pyWeather.set(ew.forecast(ew.PYROS_WEATHER));
-    hWeather.set(ew.forecast(ew.HYDATOS_WEATHER));
-    aWeather.set(ew.forecast(ew.ANEMOS_WEATHER));
-  }
-
   function formatWeathers(weathers) {
     if (weathers.length === 1) {
       return ew.getWeatherName(weathers[0]);
@@ -55,10 +48,10 @@
   }
 
   function newForecasts() {
-    anemosForecast = ew.forecast(ew.ANEMOS_WEATHER);
-    pagosForecast = ew.forecast(ew.PAGOS_WEATHER);
-    pyrosForecast = ew.forecast(ew.PYROS_WEATHER);
-    hydatosForecast = ew.forecast(ew.HYDATOS_WEATHER);
+    anemosForecast = ew.forecast(ew.ANEMOS_WEATHER, "anemos");
+    pagosForecast = ew.forecast(ew.PAGOS_WEATHER, "pagos");
+    pyrosForecast = ew.forecast(ew.PYROS_WEATHER, "pyros");
+    hydatosForecast = ew.forecast(ew.HYDATOS_WEATHER, "hydatos");
     paWeather.set(pagosForecast);
     pyWeather.set(pyrosForecast);
     hWeather.set(hydatosForecast);
@@ -83,6 +76,15 @@
     otherMatches = matches.filter((m) => m.special && !m.uptime.isUp);
   }
 
+  function formatLevel(m) {
+    if (m.level) {
+      return m.level;
+    } else if (m.levelRange) {
+      return `${m.levelRange[0]}-${m.levelRange[1]}`;
+    }
+    return "??";
+  }
+
   function formatNextUptime(futures) {
     let i;
     futures.find((f, idx) => {
@@ -113,7 +115,7 @@
     <div class="pure-u-3-4">
       <h2>
         Level: <input
-          bind:value={$level}
+          :value={$level}
           on:change={levelChanged}
           type="number"
           min="1"
@@ -125,7 +127,7 @@
       <ul>
         {#each upMatches as m (m.name + m.level)}
           <li>
-            <em>(Lv{m.level})</em> <strong>{m.name}</strong>
+            <em>(Lv{formatLevel(m)})</em> <strong>{m.name}</strong>
             ({#if m.mutating}mutates{/if}{#if m.augmenting}augments{/if} in {formatWeathers(
               m.uptime.weathers
             )})
@@ -136,7 +138,7 @@
       <h5>regular enemies</h5>
       <ul>
         {#each normalMatches as m (m.name + m.level)}
-          <li><em>(Lv{m.level})</em> <strong>{m.name}</strong></li>
+          <li><em>(Lv{formatLevel(m)})</em> <strong>{m.name}</strong></li>
         {/each}
       </ul>
 
@@ -144,7 +146,7 @@
       <ul>
         {#each otherMatches as m (m.name + m.level)}
           <li>
-            <em>(Lv{m.level})</em> <strong>{m.name}</strong>
+            <em>(Lv{formatLevel(m)})</em> <strong>{m.name}</strong>
             ({#if m.mutating}mutates{/if}{#if m.augmenting}augments{/if}
             {formatNextUptime(m.uptime.futureUptime)})
           </li>
diff --git a/src/bestiary.js b/src/bestiary.js
index 12b35b7..b09a613 100644
--- a/src/bestiary.js
+++ b/src/bestiary.js
@@ -6,14 +6,24 @@ import day from "dayjs";
 import isBetween from "dayjs/plugin/isBetween";
 day.extend(isBetween);
 
+const bestiaries = {
+  pagos: pagosB,
+  anemos: anemosB,
+  pyros: pyrosB,
+  hydatos: hydatosB,
+};
+
 export function getMatches(forecast, level) {
-  const amalgam = hydatosB.concat(pyrosB.concat(pagosB.concat(anemosB)));
   let res = [];
-  amalgam.forEach((b) => {
-    if (b.level >= level && b.level - 2 <= level) {
+  bestiaries[forecast[0].zone].forEach((b) => {
+    if (
+      (b.level >= level && b.level - 2 <= level) ||
+      (b.levelRange && b.levelRange[0] - 2 <= level && b.levelRange[1] >= level)
+    ) {
       res.push({
         name: b.name,
         level: b.level,
+        levelRange: b.levelRange,
         elem: b.elem,
         special: b.type > 0,
         mutating: b.type === 1,
diff --git a/src/ew.js b/src/ew.js
index 3519be1..d4922f6 100644
--- a/src/ew.js
+++ b/src/ew.js
@@ -106,7 +106,7 @@ function getWeather(rates, hash = hashSeed()) {
   return WEATHER.FAIR;
 }
 
-function forecast(rates, seed = getSeed(), count = 10) {
+function forecast(rates, name, seed = getSeed(), count = 10) {
   const res = [];
   let prevHash = hash(seed - 1);
   let prevWeather = getWeather(rates, prevHash);
@@ -115,6 +115,7 @@ function forecast(rates, seed = getSeed(), count = 10) {
     const currHash = hash(seed);
     const currWeather = getWeather(rates, currHash);
     res.push({
+      zone: name,
       prevWeather,
       currWeather,
       weatherName: getWeatherName(currWeather),
diff --git a/src/pagos.bestiary.json b/src/pagos.bestiary.json
index c31b700..af65266 100644
--- a/src/pagos.bestiary.json
+++ b/src/pagos.bestiary.json
@@ -57,6 +57,7 @@
   },
   {
     "level": null,
+    "levelRange": [20, 23],
     "name": "Zombie Brobinyak",
     "type": 2,
     "elem": "Earth",
@@ -127,6 +128,7 @@
   },
   {
     "level": null,
+    "levelRange": [24, 27],
     "name": "Demon of the Incunable",
     "type": 2,
     "elem": "Wind",
@@ -232,6 +234,7 @@
   },
   {
     "level": null,
+    "levelRange": [28, 31],
     "name": "Geshunpest",
     "type": 2,
     "elem": "Thunder",
@@ -295,6 +298,7 @@
   },
   {
     "level": null,
+    "levelRange": [32, 35],
     "name": "Haunt",
     "type": 2,
     "elem": "Water",
@@ -337,6 +341,7 @@
   },
   {
     "level": null,
+    "levelRange": [36, 39],
     "name": "Val Corpse",
     "type": 2,
     "elem": "Ice",
diff --git a/src/stores.js b/src/stores.js
index 65b3a79..2dbaca9 100644
--- a/src/stores.js
+++ b/src/stores.js
@@ -2,7 +2,7 @@ import { writable } from "svelte/store";
 
 const localStorage = window.localStorage;
 
-export const level = localStorageStore(0);
+export const level = localStorageStore(1);
 export const aWeather = writable();
 export const paWeather = writable();
 export const pyWeather = writable();