Popup info system for board ability unlock requirements

master
Wynd 2025-01-28 01:00:50 +02:00
parent dffaafcd40
commit 35748d099c
7 changed files with 73 additions and 2 deletions

View File

@ -154,6 +154,7 @@ type = "Checkpoint"
price = "Level 20" price = "Level 20"
route = 100 route = 100
path = ["N", "S"] path = ["N", "S"]
tip = "Unlocks with Secret panel at B5"
[[abilities]] [[abilities]]
name = "Zero Gravira" name = "Zero Gravira"
@ -162,6 +163,7 @@ type = "Magic"
price = "100 LP" price = "100 LP"
route = 100 route = 100
path = ["N", "S"] path = ["N", "S"]
tip = "Unlocks with Secret panel at B5"
[[abilities]] [[abilities]]
name = "Checkpoint" name = "Checkpoint"
@ -170,6 +172,7 @@ type = "Checkpoint"
price = "Level 25" price = "Level 25"
route = 100 route = 100
path = ["N", "E"] path = ["N", "E"]
tip = "Unlocks with Secret panel at B5"
[[abilities]] [[abilities]]
name = "Sleep Block" name = "Sleep Block"
@ -206,6 +209,7 @@ type = "Magic"
price = "150 LP" price = "150 LP"
route = 100 route = 100
path = ["W"] path = ["W"]
tip = "Unlocks with Secret panel at B5"
[[abilities]] [[abilities]]
name = "Support Boost" name = "Support Boost"

View File

@ -96,6 +96,7 @@ type = "Stat"
price = "50 LP" price = "50 LP"
route = 100 route = 100
path = ["E"] path = ["E"]
tip = "Unlocks with Secret panel at B7"
[[abilities]] [[abilities]]
name = "Start" name = "Start"
@ -146,6 +147,7 @@ type = "Stat"
price = "30 LP" price = "30 LP"
route = 100 route = 100
path = ["N", "S"] path = ["N", "S"]
tip = "Unlocks with Secret panel at B7"
[[abilities]] [[abilities]]
name = "Circle Raid" name = "Circle Raid"
@ -154,6 +156,7 @@ type = "Attack"
price = "100 LP" price = "100 LP"
route = 100 route = 100
path = ["N"] path = ["N"]
tip = "Unlocks with Secret panel at B7"
[[abilities]] [[abilities]]
name = "Stop Block" name = "Stop Block"
@ -191,6 +194,7 @@ type = "Stat"
price = "50 LP" price = "50 LP"
route = 100 route = 100
path = ["W"] path = ["W"]
tip = "Unlocks with Secret panel at B7"
[[abilities]] [[abilities]]
name = "Attack Haste" name = "Attack Haste"

View File

@ -145,6 +145,7 @@ type = "Magic"
price = "50 LP" price = "50 LP"
route = 100 route = 100
path = ["N", "E"] path = ["N", "E"]
tip = "Unlocks with Secret panel at D2"
[[abilities]] [[abilities]]
name = "Checkpoint" name = "Checkpoint"
@ -160,6 +161,7 @@ type = "Stat"
price = "30 LP" price = "30 LP"
route = 100 route = 100
path = ["S", "E"] path = ["S", "E"]
tip = "Unlocks with Secret panel at D2"
[[abilities]] [[abilities]]
name = "HP Boost" name = "HP Boost"
@ -168,6 +170,7 @@ type = "Stat"
price = "30 LP" price = "30 LP"
route = 100 route = 100
path = ["W", "N"] path = ["W", "N"]
tip = "Unlocks with Secret panel at D2"
[[abilities]] [[abilities]]
name = "Sleepra" name = "Sleepra"
@ -183,6 +186,7 @@ type = "Stat"
price = "50 LP" price = "50 LP"
route = 100 route = 100
path = ["E", "W", "S"] path = ["E", "W", "S"]
tip = "Unlocks with Secret panel at D2"
[[abilities]] [[abilities]]
name = "Water Screen" name = "Water Screen"
@ -206,6 +210,7 @@ type = "Stat"
price = "100 LP" price = "100 LP"
route = 100 route = 100
path = ["W"] path = ["W"]
tip = "Unlocks with Secret panel at D2"
[[abilities]] [[abilities]]
name = "Support Boost" name = "Support Boost"

View File

@ -146,6 +146,7 @@ type = "Magic"
price = "150 LP" price = "150 LP"
route = 100 route = 100
path = ["W", "E", "N"] path = ["W", "E", "N"]
tip = "Unlocks with Secret panel at E1"
[[abilities]] [[abilities]]
name = "Thunder Boost" name = "Thunder Boost"

View File

@ -21,6 +21,26 @@ struct Board {
} }
impl Board { impl Board {
pub fn init_ability_help(&mut self) {
for abl in &mut self.abilities {
if abl.tip.is_none() && abl.route.is_some() {
let route_id = abl.route.unwrap();
let mut route = None;
for r in &self.routes {
if r.id == route_id {
route = Some(r);
break;
}
}
if route_id < 10 && route.is_some() {
abl.tip = Some(format!("Unlocks with disposition {}", route.unwrap().name));
}
}
}
}
pub fn init_routes(&mut self) { pub fn init_routes(&mut self) {
self.routes.iter_mut().for_each(|r| { self.routes.iter_mut().for_each(|r| {
r.interaction = match r.color { r.interaction = match r.color {
@ -261,9 +281,14 @@ struct Ability {
price: String, price: String,
route: Option<u32>, route: Option<u32>,
path: Vec<Direction>, path: Vec<Direction>,
tip: Option<String>,
} }
impl Ability { impl Ability {
pub fn tip(&self) -> String {
self.tip.clone().unwrap_or_default()
}
pub fn get_slot_details(&self, board: &Board) -> String { pub fn get_slot_details(&self, board: &Board) -> String {
let mut details = String::new(); let mut details = String::new();
if let Some(route) = self.route { if let Some(route) = self.route {
@ -343,6 +368,7 @@ pub fn init() {
false => None, false => None,
}) })
.collect::<Vec<PathBuf>>(); .collect::<Vec<PathBuf>>();
for path in paths { for path in paths {
let board_str = std::fs::read_to_string(path).unwrap(); let board_str = std::fs::read_to_string(path).unwrap();
let mut board = toml::from_str::<Board>(&board_str).unwrap(); let mut board = toml::from_str::<Board>(&board_str).unwrap();
@ -351,6 +377,7 @@ pub fn init() {
board.init_total_lp(); board.init_total_lp();
board.init_max_level(); board.init_max_level();
board.init_stats(); board.init_stats();
board.init_ability_help();
// dbg!(&board); // dbg!(&board);
boards.push(board); boards.push(board);

View File

@ -5,7 +5,10 @@
{% match ability %} {% match ability %}
{% when Some with (val) %} {% when Some with (val) %}
<td colspan="1" class="{{ val.get_slot_details(board) }}"> <td colspan="1" class="{{ val.get_slot_details(board) }}">
<div class="slot"> <div
class="slot tooltip-wrapper"
{% if val.tip.is_some() %}style="cursor: help"{% endif %}
>
<span>{{ val.name }}</span> <span>{{ val.name }}</span>
{% match val.type %} {% match val.type %}
{% when AbilityType::Checkpoint %} {% when AbilityType::Checkpoint %}
@ -13,6 +16,10 @@
<span>{{ val.price }}</span> <span>{{ val.price }}</span>
{% when _ %} {% when _ %}
{% endmatch %} {% endmatch %}
{% if val.tip.is_some() %}
<div class="tooltip">{{ val.tip() }}</div>
{% endif %}
</div> </div>
<div class="path"></div> <div class="path"></div>

View File

@ -74,7 +74,6 @@
width: 120px; width: 120px;
height: 100px; height: 100px;
position: relative; position: relative;
overflow: hidden;
& span { & span {
position: inherit; position: inherit;
@ -94,6 +93,30 @@
box-shadow: 1px 1px 5px black; box-shadow: 1px 1px 5px black;
} }
.tooltip-wrapper {
.tooltip {
visibility: hidden;
background-color: #555;
max-width: 250px;
min-width: 150px;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 8px;
position: absolute;
z-index: 1;
bottom: 125%;
left: -50%;
opacity: 0;
transition: opacity 0.3s;
}
&:hover .tooltip {
visibility: visible;
opacity: 1;
}
}
&.slot-w { &.slot-w {
height: 20px; height: 20px;
} }