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]] [[world]]
name = "Agrabah" name = "Agrabah"
room = ["Desert: Cave", "Treasure Room", "Lamp Chamber"] rooms = ["Desert: Cave", "Treasure Room", "Lamp Chamber"]
[[world]] [[world]]
name = "Monstro" name = "Monstro"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,5 @@
name = "Air Soldier" name = "Air Soldier"
icon = "air_soldier_kh3"
[[world]] [[world]]
name = "Olympus" 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 { import {
init, init as matFilterInit,
kindFilter, kindFilter,
showOnlyTracked, showOnlyTracked,
track, track,
} from "../common/mat-kind-filter.js"; } from "../common/mat-kind-filter.js";
import { init as worldInit } from "../common/enemy-worlds.js";
document.addEventListener("DOMContentLoaded", (event) => { document.addEventListener("DOMContentLoaded", (event) => {
init(); matFilterInit();
worldInit();
}); });
Object.assign(window, { track }); Object.assign(window, { track });

View File

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

View File

@ -17,6 +17,7 @@
</div> </div>
<div class="enemies"> <div class="enemies">
{% for drop in drops %} {% for drop in drops %}
<div class="enemy">
<div class="drop"> <div class="drop">
<div <div
style="background-image: url('../public/assets/enemies/{{ drop.texture() }}.webp');" style="background-image: url('../public/assets/enemies/{{ drop.texture() }}.webp');"
@ -24,6 +25,34 @@
<span>{{ drop.from +}}</span> <span>{{ drop.from +}}</span>
<span>{{+ drop.chance }}</span> <span>{{+ drop.chance }}</span>
</div> </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 %} {% endfor %}
</div> </div>
</div> </div>