Skip to content

Commit

Permalink
add support for a second ruleset
Browse files Browse the repository at this point in the history
  • Loading branch information
gmjosack committed May 4, 2022
1 parent ee29553 commit 415ca81
Show file tree
Hide file tree
Showing 8 changed files with 251 additions and 95 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ Tracker for All Stats Entry runs in Spelunky Classic

This tracker is meant to be used as a browser source in OBS to avoid the need to worry about chroma keys and ugly masking. To setup this up select a `Browser` under sources and fill in `http://127.0.0.1:4224` for the URL. Setting a height of `1600` allowed the full window to be displayed for me.

We also support multiple rulesets in the tracker.

Ruleset 1 - Requires getting all enemy deaths and kills
Ruleset 2 - Requires getting a death OR kill for each enemy

The default ruleset currently is 1 however you can choose an explicit ruleset by adding a `ruleset` query parameter. For example to use ruleset 2 use the URL `http://127.0.0.1:4224?ruleset=2`.

![unknown](https://user-images.githubusercontent.com/231118/166628232-703a7bf7-170c-4863-9bbb-2212dd746442.png)![image](https://user-images.githubusercontent.com/231118/166628340-3edaac5a-901e-4a89-8f61-206d0f08bbd7.png)

## Development
Expand Down
83 changes: 15 additions & 68 deletions frontend/src/App.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<script lang="ts">
import EnemyIcon from "./EnemyIcon.svelte";
import EnemyList1 from "./EnemyList1.svelte";
import EnemyList2 from "./EnemyList2.svelte";
import MiscDeaths1 from "./MiscDeaths1.svelte";
import MiscDeaths2 from "./MiscDeaths2.svelte";
import StatIcon from "./StatIcon.svelte";
import store from "./stores";
Expand Down Expand Up @@ -59,74 +62,18 @@
<StatIcon collection="level_deaths" name="level_16" />
</div>
<div>&nbsp;</div>
<div>
<StatIcon collection="misc_deaths" name="rock" />
<StatIcon collection="misc_deaths" name="explosion" />
<StatIcon collection="misc_deaths" name="crushed" />
<StatIcon collection="misc_deaths" name="long_fall" />
<StatIcon collection="misc_deaths" name="spikes" />
<!-- <StatIcon collection="misc_deaths" name="boulder" /> -->
</div>
<div>
<StatIcon collection="misc_deaths" name="arrow_trap" />
<StatIcon collection="misc_deaths" name="spear_trap" />
<StatIcon collection="misc_deaths" name="smash_trap" />
<StatIcon collection="misc_deaths" name="ceiling_trap" />
<StatIcon collection="misc_deaths" name="pit" />
<StatIcon collection="misc_deaths" name="lava" />
</div>
{#if store.ruleset === 1}
<MiscDeaths1 />
{:else}
<MiscDeaths2 />
{/if}

<div>&nbsp;</div>
<div>
<EnemyIcon name="bat" showDeaths={false} />
<EnemyIcon name="snake" />
</div>
<div>
<EnemyIcon name="spider" />
<EnemyIcon name="giant_spider" />
</div>
<div>
<EnemyIcon name="caveman" />
<EnemyIcon name="skeleton" />
</div>
<div>
<EnemyIcon name="zombie" showDeaths={false} />
<EnemyIcon name="vampire" showDeaths={false} />
</div>
<div>
<EnemyIcon name="frog" />
<EnemyIcon name="monkey" showDeaths={false} />
</div>
<div>
<EnemyIcon name="fire_frog" />
<EnemyIcon name="mantrap" />
</div>
<div>
<EnemyIcon name="piranha" />
<EnemyIcon name="megamouth" showDeaths={false} />
</div>
<div>
<EnemyIcon name="yeti" />
<EnemyIcon name="yeti_king" />
</div>
<div>
<EnemyIcon name="alien" />
<EnemyIcon name="ufo" />
</div>
<div>
<EnemyIcon name="alien_boss" />
<EnemyIcon name="hawkman" />
</div>
<div>
<EnemyIcon name="tomb_lord" />
<EnemyIcon name="shopkeeper" />
</div>
<div>
<EnemyIcon name="magma_man" showKills={false} />
<EnemyIcon name="olmec" />
</div>
<div>
<EnemyIcon name="ghost" showKills={false} />
</div>
{#if store.ruleset === 1}
<EnemyList1 />
{:else}
<EnemyList2 />
{/if}
{:else}
<div class="connecting">Connecting...</div>
{/if}
Expand Down
65 changes: 39 additions & 26 deletions frontend/src/EnemyIcon.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,36 @@
let collectedDeath = false;
let collectedKill = false;
let collectedBoth = false;
let collected = false;
// Default value for for an enemy
let default_count = 1;
let default_collect_state = true;
if (store.ruleset === 2) {
default_count = 0;
default_collect_state = false;
}
store.stats.subscribe((value) => {
// Treat undefined as collected
collectedDeath = (value.enemy_deaths[name] ?? 1) > 0;
collectedKill = (value.enemy_kills[name] ?? 1) > 0;
collectedDeath = (value.enemy_deaths[name] ?? default_count) > 0;
collectedKill = (value.enemy_kills[name] ?? default_count) > 0;
if (!showKills) {
collectedKill = true;
collectedKill = default_collect_state;
}
if (!showDeaths) {
collectedDeath = true;
collectedDeath = default_collect_state;
}
if (collectedDeath && collectedKill) {
collectedBoth = true;
if (store.ruleset === 1 && collectedDeath && collectedKill) {
collected = true;
} else if (store.ruleset === 2 && (collectedDeath || collectedKill)) {
collected = true;
} else {
collectedBoth = false;
collected = false;
}
});
</script>
Expand All @@ -34,26 +45,28 @@
<img
src="images/stats-icons/enemy_{name}.png"
alt=""
class={collectedBoth ? "collected" : ""}
class={collected ? "collected" : ""}
/>
{#if showDeaths}
<img
src="images/stats-icons/skull.png"
alt=""
class={collectedDeath ? "collected" : ""}
/>
{:else}
<img src="images/stats-icons/empty.png" alt="" />
{/if}
{#if store.ruleset == 1}
{#if showDeaths}
<img
src="images/stats-icons/skull.png"
alt=""
class={collectedDeath ? "collected" : ""}
/>
{:else}
<img src="images/stats-icons/empty.png" alt="" />
{/if}

{#if showKills}
<img
src="images/stats-icons/whip.png"
alt=""
class={collectedKill ? "collected" : ""}
/>
{:else}
<img src="images/stats-icons/empty.png" alt="" />
{#if showKills}
<img
src="images/stats-icons/whip.png"
alt=""
class={collectedKill ? "collected" : ""}
/>
{:else}
<img src="images/stats-icons/empty.png" alt="" />
{/if}
{/if}
</main>

Expand Down
64 changes: 64 additions & 0 deletions frontend/src/EnemyList1.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<script lang="ts">
import EnemyIcon from "./EnemyIcon.svelte";
</script>

<main>
<div>
<EnemyIcon name="bat" showDeaths={false} />
<EnemyIcon name="snake" />
</div>
<div>
<EnemyIcon name="spider" />
<EnemyIcon name="giant_spider" />
</div>
<div>
<EnemyIcon name="caveman" />
<EnemyIcon name="skeleton" />
</div>
<div>
<EnemyIcon name="zombie" showDeaths={false} />
<EnemyIcon name="vampire" showDeaths={false} />
</div>
<div>
<EnemyIcon name="frog" />
<EnemyIcon name="monkey" showDeaths={false} />
</div>
<div>
<EnemyIcon name="fire_frog" />
<EnemyIcon name="mantrap" />
</div>
<div>
<EnemyIcon name="piranha" />
<EnemyIcon name="megamouth" showDeaths={false} />
</div>
<div>
<EnemyIcon name="yeti" />
<EnemyIcon name="yeti_king" />
</div>
<div>
<EnemyIcon name="alien" />
<EnemyIcon name="ufo" />
</div>
<div>
<EnemyIcon name="alien_boss" />
<EnemyIcon name="hawkman" />
</div>
<div>
<EnemyIcon name="tomb_lord" />
<EnemyIcon name="shopkeeper" />
</div>
<div>
<EnemyIcon name="magma_man" showKills={false} />
<EnemyIcon name="olmec" />
</div>
<div>
<EnemyIcon name="ghost" showKills={false} />
</div>
</main>

<style>
main {
padding: 0.1em;
margin: 0 auto;
}
</style>
51 changes: 51 additions & 0 deletions frontend/src/EnemyList2.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<script lang="ts">
import EnemyIcon from "./EnemyIcon.svelte";
</script>

<main>
<div>
<EnemyIcon name="bat" showDeaths={false} />
<EnemyIcon name="snake" />
<EnemyIcon name="spider" />
<EnemyIcon name="giant_spider" />
<EnemyIcon name="caveman" />
</div>
<div />
<div>
<EnemyIcon name="zombie" showDeaths={false} />
<EnemyIcon name="vampire" showDeaths={false} />
<EnemyIcon name="frog" />
<EnemyIcon name="fire_frog" />
</div>
<div>
<EnemyIcon name="monkey" showDeaths={false} />
<EnemyIcon name="mantrap" />
<EnemyIcon name="piranha" />
<EnemyIcon name="megamouth" showDeaths={false} />
</div>
<div>
<EnemyIcon name="yeti" />
<EnemyIcon name="yeti_king" />
<EnemyIcon name="alien" />
<EnemyIcon name="ufo" />
<EnemyIcon name="alien_boss" />
</div>
<div>
<EnemyIcon name="hawkman" />
<EnemyIcon name="tomb_lord" />
<EnemyIcon name="shopkeeper" />
<EnemyIcon name="magma_man" showKills={false} />
<EnemyIcon name="olmec" />
</div>
<div>
<EnemyIcon name="skeleton" />
<EnemyIcon name="ghost" showKills={false} />
</div>
</main>

<style>
main {
padding: 0.1em;
margin: 0 auto;
}
</style>
29 changes: 29 additions & 0 deletions frontend/src/MiscDeaths1.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script lang="ts">
import StatIcon from "./StatIcon.svelte";
</script>

<main>
<div>
<StatIcon collection="misc_deaths" name="rock" />
<StatIcon collection="misc_deaths" name="explosion" />
<StatIcon collection="misc_deaths" name="crushed" />
<StatIcon collection="misc_deaths" name="long_fall" />
<StatIcon collection="misc_deaths" name="spikes" />
<!-- <StatIcon collection="misc_deaths" name="boulder" /> -->
</div>
<div>
<StatIcon collection="misc_deaths" name="arrow_trap" />
<StatIcon collection="misc_deaths" name="spear_trap" />
<StatIcon collection="misc_deaths" name="smash_trap" />
<StatIcon collection="misc_deaths" name="ceiling_trap" />
<StatIcon collection="misc_deaths" name="pit" />
<StatIcon collection="misc_deaths" name="lava" />
</div>
</main>

<style>
main {
padding: 0.1em;
margin: 0 auto;
}
</style>
31 changes: 31 additions & 0 deletions frontend/src/MiscDeaths2.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<script lang="ts">
import StatIcon from "./StatIcon.svelte";
</script>

<main>
<div>
<StatIcon collection="misc_deaths" name="rock" />
<StatIcon collection="misc_deaths" name="explosion" />
<StatIcon collection="misc_deaths" name="crushed" />
<StatIcon collection="misc_deaths" name="long_fall" />
</div>
<div>
<StatIcon collection="misc_deaths" name="spikes" />
<StatIcon collection="misc_deaths" name="arrow_trap" />
<StatIcon collection="misc_deaths" name="spear_trap" />
<StatIcon collection="misc_deaths" name="smash_trap" />
</div>
<div>
<!-- <StatIcon collection="misc_deaths" name="boulder" /> -->
<StatIcon collection="misc_deaths" name="ceiling_trap" />
<StatIcon collection="misc_deaths" name="pit" />
<StatIcon collection="misc_deaths" name="lava" />
</div>
</main>

<style>
main {
padding: 0.1em;
margin: 0 auto;
}
</style>
Loading

0 comments on commit 415ca81

Please sign in to comment.