From 4c8be07bea13c2c8935c1c7869270e96d9221501 Mon Sep 17 00:00:00 2001 From: ana Date: Sun, 8 Aug 2021 18:42:35 +0200 Subject: feat: don't load data from other zones --- src/App.svelte | 34 ++++++++++++++++++---------------- src/bestiary.js | 16 +++++++++++++--- src/ew.js | 3 ++- src/pagos.bestiary.json | 5 +++++ src/stores.js | 2 +- 5 files changed, 39 insertions(+), 21 deletions(-) (limited to 'src') 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 @@

Level: {#each upMatches as m (m.name + m.level)}
  • - (Lv{m.level}) {m.name} + (Lv{formatLevel(m)}) {m.name} ({#if m.mutating}mutates{/if}{#if m.augmenting}augments{/if} in {formatWeathers( m.uptime.weathers )}) @@ -136,7 +138,7 @@
    regular enemies
      {#each normalMatches as m (m.name + m.level)} -
    • (Lv{m.level}) {m.name}
    • +
    • (Lv{formatLevel(m)}) {m.name}
    • {/each}
    @@ -144,7 +146,7 @@
      {#each otherMatches as m (m.name + m.level)}
    • - (Lv{m.level}) {m.name} + (Lv{formatLevel(m)}) {m.name} ({#if m.mutating}mutates{/if}{#if m.augmenting}augments{/if} {formatNextUptime(m.uptime.futureUptime)})
    • 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(); -- cgit 1.4.1-2-gfad0