Correcting some input data

master
Wynd 2025-02-08 19:09:16 +02:00
parent 7cfc5c41a1
commit 2464e440a3
5 changed files with 38 additions and 14 deletions

View File

@ -29,7 +29,7 @@ from = "Cannon Gun"
chance = 3 chance = 3
[[stone]] [[stone]]
from = "Drilelr Mole" from = "Driller Mole"
chance = 4 chance = 4
[[stone]] [[stone]]

View File

@ -5,7 +5,7 @@ from = "Hook Bat"
chance = 6 chance = 6
[[shard]] [[shard]]
from = "Lance Solider" from = "Lance Soldier"
chance = 10 chance = 10
[[stone]] [[stone]]

View File

@ -17,10 +17,10 @@ pub struct MaterialDrops {
impl MaterialDrops { impl MaterialDrops {
fn drops(&self, kind: &str) -> &[EnemyDrop] { fn drops(&self, kind: &str) -> &[EnemyDrop] {
match kind { match kind {
x if x == "shard" => &self.shard, "shard" => &self.shard,
x if x == "stone" => &self.stone, "stone" => &self.stone,
x if x == "gem" => &self.gem, "gem" => &self.gem,
x if x == "crystal" => &self.crystal, "crystal" => &self.crystal,
_ => &self.shard, _ => &self.shard,
} }
} }
@ -32,6 +32,12 @@ pub struct EnemyDrop {
chance: u8, chance: u8,
} }
impl EnemyDrop {
fn texture(&self) -> String {
self.from.replace(" ", "_").to_lowercase()
}
}
#[derive(Template)] #[derive(Template)]
#[template(path = "pages/kh2/drops.html")] #[template(path = "pages/kh2/drops.html")]
struct DropsTemplate { struct DropsTemplate {

View File

@ -10,12 +10,9 @@
<div class="enemies"> <div class="enemies">
{% for drop in category.drops(label) %} {% for drop in category.drops(label) %}
<div class="drop"> <div class="drop">
<img <div
src="../assets/enemies/{{ drop.from|lower }}.webp" style="background-image: url('../assets/enemies/{{ drop.texture() }}.webp');"
width="256" ></div>
height="256"
onerror="this.src = '../assets/enemies/unknown.webp'"
/>
<span>{{ drop.from +}}</span> <span>{{ drop.from +}}</span>
<span>{{+ drop.chance }}%</span> <span>{{+ drop.chance }}%</span>
</div> </div>

View File

@ -18,10 +18,31 @@
flex-direction: column; flex-direction: column;
text-align: center; text-align: center;
margin-right: 8px; margin-right: 8px;
line-height: 30px;
font-size: 18px;
text-shadow: black 2px 2px;
transition: all 0.2s ease;
span { div {
font-size: 18px; background-repeat: no-repeat;
background-position: center;
background-size: contain;
width: 256px;
height: 256px;
background-size: 384px;
transition: all 0.2s ease;
} }
/* &:hover { */
/* background-color: #333; */
/* box-shadow: 0 0 10px 1px rgba(0, 255, 0, 0.5); */
/* transform: scale(1.5); */
/**/
/* & > div { */
/* padding: 32px; */
/* margin: -32px; */
/* } */
/* } */
} }
} }
</style> </style>