From 35748d099c17f0309dd036f3f03bed50afe7f1ec Mon Sep 17 00:00:00 2001 From: Wynd Date: Tue, 28 Jan 2025 01:00:50 +0200 Subject: [PATCH] Popup info system for board ability unlock requirements --- input/ddd/abilities/fin-fatale.toml | 4 ++++ input/ddd/abilities/pricklemane.toml | 4 ++++ input/ddd/abilities/tama-sheep.toml | 5 +++++ input/ddd/abilities/thunderaffe.toml | 1 + src/ddd.rs | 27 +++++++++++++++++++++++++ templates/components/ddd/board-row.html | 9 ++++++++- templates/pages/ddd-abilities.html | 25 ++++++++++++++++++++++- 7 files changed, 73 insertions(+), 2 deletions(-) diff --git a/input/ddd/abilities/fin-fatale.toml b/input/ddd/abilities/fin-fatale.toml index 0c0ff02..61e5648 100644 --- a/input/ddd/abilities/fin-fatale.toml +++ b/input/ddd/abilities/fin-fatale.toml @@ -154,6 +154,7 @@ type = "Checkpoint" price = "Level 20" route = 100 path = ["N", "S"] +tip = "Unlocks with Secret panel at B5" [[abilities]] name = "Zero Gravira" @@ -162,6 +163,7 @@ type = "Magic" price = "100 LP" route = 100 path = ["N", "S"] +tip = "Unlocks with Secret panel at B5" [[abilities]] name = "Checkpoint" @@ -170,6 +172,7 @@ type = "Checkpoint" price = "Level 25" route = 100 path = ["N", "E"] +tip = "Unlocks with Secret panel at B5" [[abilities]] name = "Sleep Block" @@ -206,6 +209,7 @@ type = "Magic" price = "150 LP" route = 100 path = ["W"] +tip = "Unlocks with Secret panel at B5" [[abilities]] name = "Support Boost" diff --git a/input/ddd/abilities/pricklemane.toml b/input/ddd/abilities/pricklemane.toml index 366e88d..79f45aa 100644 --- a/input/ddd/abilities/pricklemane.toml +++ b/input/ddd/abilities/pricklemane.toml @@ -96,6 +96,7 @@ type = "Stat" price = "50 LP" route = 100 path = ["E"] +tip = "Unlocks with Secret panel at B7" [[abilities]] name = "Start" @@ -146,6 +147,7 @@ type = "Stat" price = "30 LP" route = 100 path = ["N", "S"] +tip = "Unlocks with Secret panel at B7" [[abilities]] name = "Circle Raid" @@ -154,6 +156,7 @@ type = "Attack" price = "100 LP" route = 100 path = ["N"] +tip = "Unlocks with Secret panel at B7" [[abilities]] name = "Stop Block" @@ -191,6 +194,7 @@ type = "Stat" price = "50 LP" route = 100 path = ["W"] +tip = "Unlocks with Secret panel at B7" [[abilities]] name = "Attack Haste" diff --git a/input/ddd/abilities/tama-sheep.toml b/input/ddd/abilities/tama-sheep.toml index b4638d2..53626a4 100644 --- a/input/ddd/abilities/tama-sheep.toml +++ b/input/ddd/abilities/tama-sheep.toml @@ -145,6 +145,7 @@ type = "Magic" price = "50 LP" route = 100 path = ["N", "E"] +tip = "Unlocks with Secret panel at D2" [[abilities]] name = "Checkpoint" @@ -160,6 +161,7 @@ type = "Stat" price = "30 LP" route = 100 path = ["S", "E"] +tip = "Unlocks with Secret panel at D2" [[abilities]] name = "HP Boost" @@ -168,6 +170,7 @@ type = "Stat" price = "30 LP" route = 100 path = ["W", "N"] +tip = "Unlocks with Secret panel at D2" [[abilities]] name = "Sleepra" @@ -183,6 +186,7 @@ type = "Stat" price = "50 LP" route = 100 path = ["E", "W", "S"] +tip = "Unlocks with Secret panel at D2" [[abilities]] name = "Water Screen" @@ -206,6 +210,7 @@ type = "Stat" price = "100 LP" route = 100 path = ["W"] +tip = "Unlocks with Secret panel at D2" [[abilities]] name = "Support Boost" diff --git a/input/ddd/abilities/thunderaffe.toml b/input/ddd/abilities/thunderaffe.toml index d2c0b14..b9ffdca 100644 --- a/input/ddd/abilities/thunderaffe.toml +++ b/input/ddd/abilities/thunderaffe.toml @@ -146,6 +146,7 @@ type = "Magic" price = "150 LP" route = 100 path = ["W", "E", "N"] +tip = "Unlocks with Secret panel at E1" [[abilities]] name = "Thunder Boost" diff --git a/src/ddd.rs b/src/ddd.rs index 96714df..59b8fdb 100644 --- a/src/ddd.rs +++ b/src/ddd.rs @@ -21,6 +21,26 @@ struct 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) { self.routes.iter_mut().for_each(|r| { r.interaction = match r.color { @@ -261,9 +281,14 @@ struct Ability { price: String, route: Option, path: Vec, + tip: Option, } impl Ability { + pub fn tip(&self) -> String { + self.tip.clone().unwrap_or_default() + } + pub fn get_slot_details(&self, board: &Board) -> String { let mut details = String::new(); if let Some(route) = self.route { @@ -343,6 +368,7 @@ pub fn init() { false => None, }) .collect::>(); + for path in paths { let board_str = std::fs::read_to_string(path).unwrap(); let mut board = toml::from_str::(&board_str).unwrap(); @@ -351,6 +377,7 @@ pub fn init() { board.init_total_lp(); board.init_max_level(); board.init_stats(); + board.init_ability_help(); // dbg!(&board); boards.push(board); diff --git a/templates/components/ddd/board-row.html b/templates/components/ddd/board-row.html index 8cea6ec..b0be255 100644 --- a/templates/components/ddd/board-row.html +++ b/templates/components/ddd/board-row.html @@ -5,7 +5,10 @@ {% match ability %} {% when Some with (val) %} -
+
{{ val.name }} {% match val.type %} {% when AbilityType::Checkpoint %} @@ -13,6 +16,10 @@ {{ val.price }} {% when _ %} {% endmatch %} + + {% if val.tip.is_some() %} +
{{ val.tip() }}
+ {% endif %}
diff --git a/templates/pages/ddd-abilities.html b/templates/pages/ddd-abilities.html index 983ac2d..5c8df84 100644 --- a/templates/pages/ddd-abilities.html +++ b/templates/pages/ddd-abilities.html @@ -74,7 +74,6 @@ width: 120px; height: 100px; position: relative; - overflow: hidden; & span { position: inherit; @@ -94,6 +93,30 @@ 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 { height: 20px; }