Adding world/room info for drops

master
Wynd 2025-07-07 21:16:53 +03:00
parent b76888ba7d
commit 7863a5519e
15 changed files with 131 additions and 25 deletions

View File

@ -2,7 +2,7 @@ name = "Bandit"
[[world]]
name = "Agrabah"
room = ["Desert: Cave", "Treasure Room", "Lamp Chamber"]
rooms = ["Desert: Cave", "Treasure Room", "Lamp Chamber"]
[[world]]
name = "Monstro"

View File

@ -5,7 +5,7 @@ name = "Deep Jungle"
[[world]]
name = "Monstro"
room = ["Bowels", "Stomach"]
rooms = ["Bowels", "Stomach"]
[[world]]
name = "End of the World"

View File

@ -2,11 +2,11 @@ name = "Darkball"
[[world]]
name = "Traverse Town"
room = ["3rd District", "Gizmo Shop"]
rooms = ["3rd District", "Gizmo Shop"]
[[world]]
name = "Agrabah"
room = ["Bazaar", "Palace Gates"]
rooms = ["Bazaar", "Palace Gates"]
[[world]]
name = "Hollow Bastion"
@ -16,7 +16,7 @@ name = "End of the World"
[[world]]
name = "Neverland"
room = ["Ship: Freezer", "Captain's Cabin"]
rooms = ["Ship: Freezer", "Captain's Cabin"]
[[drops]]
name = "Hi-Potion"

View File

@ -2,7 +2,7 @@ name = "Defender"
[[world]]
name = "Traverse Town"
room = ["3rd District", "Hotel Hallway", "Gizmo Shop"]
rooms = ["3rd District", "Hotel Hallway", "Gizmo Shop"]
[[world]]
name = "Hollow Bastion"

View File

@ -11,7 +11,7 @@ name = "Monstro"
[[world]]
name = "Deep Jungle"
room = ["Jungle: Cliff"]
rooms = ["Jungle: Cliff"]
[[world]]
name = "Hollow Bastion"

View File

@ -2,7 +2,7 @@ name = "Pirate"
[[world]]
name = "Neverland"
room = ["Captain's Cabin"]
rooms = ["Captain's Cabin"]
[[world]]
name = "Monstro"

View File

@ -5,7 +5,7 @@ name = "Deep Jungle"
[[world]]
name = "Monstro"
room = ["Chamber 5", "Chamber 6"]
rooms = ["Chamber 5", "Chamber 6"]
[[world]]
name = "End of the World"

View File

@ -2,7 +2,7 @@ name = "Red Nocturne"
[[world]]
name = "Monstro"
room = ["Chamber 6"]
rooms = ["Chamber 6"]
[[world]]
name = "End of the World"

View File

@ -2,7 +2,7 @@ name = "Soldier"
[[world]]
name = "Agrabah"
room = ["Main Street"]
rooms = ["Main Street"]
[[drops]]
name = "Spirit Shard"

View File

@ -1,4 +1,5 @@
name = "Air Soldier"
icon = "air_soldier_kh3"
[[world]]
name = "Olympus"

View File

@ -0,0 +1,40 @@
export function init() {
const enemies = document.querySelectorAll(".enemy");
for (const enemyWrapper of enemies) {
toggleWorldDisplay(enemyWrapper);
enemyWrapper.addEventListener("click", function () {
toggleWorldDisplay(this);
});
}
}
function toggleWorldDisplay(display) {
const showWorlds = display.dataset["showWorlds"] === "true";
const enemyWorlds = display.querySelector(".worlds");
const worldsWrapper = display.querySelectorAll(".worlds > div");
const worldsIcons = display.querySelectorAll(".worlds > div > img");
if (!showWorlds) {
enemyWorlds.style.width = "32px";
for (const wrapper of worldsWrapper) {
wrapper.style.height = "32px";
}
for (const icon of worldsIcons) {
icon.width = "32";
icon.height = "32";
}
} else {
enemyWorlds.style.width = "256px";
for (const wrapper of worldsWrapper) {
wrapper.style.height = "auto";
}
for (const icon of worldsIcons) {
icon.width = "64";
icon.height = "64";
}
}
display.dataset["showWorlds"] = !showWorlds;
}

View File

@ -1,12 +1,15 @@
import {
init,
init as matFilterInit,
kindFilter,
showOnlyTracked,
track,
} from "../common/mat-kind-filter.js";
import { init as worldInit } from "../common/enemy-worlds.js";
document.addEventListener("DOMContentLoaded", (event) => {
init();
matFilterInit();
worldInit();
});
Object.assign(window, { track });

View File

@ -7,6 +7,11 @@
display: flex;
width: 100%;
flex-wrap: wrap;
gap: 32px;
.enemy {
display: flex;
}
.drop {
display: flex;
@ -40,4 +45,24 @@
/* } */
/* } */
}
.worlds {
display: flex;
flex-direction: column;
width: 256px;
height: 316px;
overflow-x: hidden;
overflow-y: auto;
div {
display: inline-flex;
margin-bottom: 16px;
font-size: 14px;
align-items: center;
p {
margin-left: 8px;
}
}
}
}

View File

@ -4,7 +4,7 @@ use serde::Deserialize;
use super::materials::MaterialDetails;
#[derive(Debug, Deserialize, PartialEq, Eq)]
#[derive(Default, Debug, Deserialize, PartialEq, Eq, PartialOrd, Ord, Clone)]
pub struct Enemy {
pub name: String,
pub icon: Option<String>,
@ -32,10 +32,10 @@ impl Enemy {
for path in paths {
let enemy_str = std::fs::read_to_string(path).unwrap();
let mut enemy = toml::from_str::<Enemy>(&enemy_str).unwrap();
enemy
.drops
.iter_mut()
.for_each(|d| d.from = enemy.name.clone());
enemy.drops.iter_mut().for_each(|d| {
d.from = enemy.name.clone();
d.spawns = enemy.world.clone();
});
enemies.push(enemy);
}
@ -48,6 +48,8 @@ pub struct EnemyDrop {
pub name: String,
#[serde(skip)]
pub from: String,
#[serde(skip)]
pub spawns: Vec<SpawnLocation>,
pub chance: EnemyDropChance,
pub kind: EnemyDropKind,
pub info: Option<String>,
@ -84,9 +86,15 @@ impl Display for EnemyDropChance {
}
}
#[derive(Debug, Deserialize, PartialEq, Eq)]
#[derive(Debug, Deserialize, PartialEq, Eq, PartialOrd, Ord, Clone)]
pub struct SpawnLocation {
pub name: String,
#[serde(default)]
pub rooms: Vec<String>,
}
impl SpawnLocation {
pub fn texture(&self) -> String {
self.name.replace(" ", "-").to_lowercase()
}
}

View File

@ -17,6 +17,7 @@
</div>
<div class="enemies">
{% for drop in drops %}
<div class="enemy">
<div class="drop">
<div
style="background-image: url('../public/assets/enemies/{{ drop.texture() }}.webp');"
@ -24,6 +25,34 @@
<span>{{ drop.from +}}</span>
<span>{{+ drop.chance }}</span>
</div>
<div class="worlds">
{% for spawn in drop.spawns %}
{% if spawn.rooms.len() > 0 %}
{% for room in spawn.rooms %}
<div>
<img
src="../public/assets/worlds/{{ spawn.texture() }}.webp"
width="64"
height="64"
/>
<p>
{{ spawn.name +}} - {{+ room }}
</p>
</div>
{% endfor %}
{% else %}
<div>
<img
src="../public/assets/worlds/{{ spawn.texture() }}.webp"
width="64"
height="64"
/>
<p>{{ spawn.name }}</p>
</div>
{% endif %}
{% endfor %}
</div>
</div>
{% endfor %}
</div>
</div>