From 1825e5c64b4dae65f4cc6c216ad9903d96e514e5 Mon Sep 17 00:00:00 2001 From: Wynd Date: Sun, 6 Oct 2024 01:01:04 +0300 Subject: [PATCH] Split the spirits data into multiple json files and added dispositions --- Cargo.toml | 2 +- input/ddd/abilities.json | 457 --------------------- input/ddd/abilities/komory-bat.json | 221 ++++++++++ input/ddd/abilities/meow-wow.json | 221 ++++++++++ input/ddd/abilities/necho-cat.json | 214 ++++++++++ src/ddd.rs | 102 ++++- templates/components/ddd/abilities.html | 33 ++ templates/components/ddd/board-row.html | 23 ++ templates/components/ddd/board.html | 15 + templates/components/ddd/dispositions.html | 18 + templates/layouts/base.html | 4 + templates/pages/ddd-abilities.html | 131 +++--- 12 files changed, 907 insertions(+), 534 deletions(-) delete mode 100644 input/ddd/abilities.json create mode 100644 input/ddd/abilities/komory-bat.json create mode 100644 input/ddd/abilities/meow-wow.json create mode 100644 input/ddd/abilities/necho-cat.json create mode 100644 templates/components/ddd/abilities.html create mode 100644 templates/components/ddd/board-row.html create mode 100644 templates/components/ddd/board.html create mode 100644 templates/components/ddd/dispositions.html diff --git a/Cargo.toml b/Cargo.toml index 430b3f4..558b378 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "khguide" -version = "1.0.2" +version = "1.1.0" edition = "2021" [dependencies] diff --git a/input/ddd/abilities.json b/input/ddd/abilities.json deleted file mode 100644 index 1189427..0000000 --- a/input/ddd/abilities.json +++ /dev/null @@ -1,457 +0,0 @@ -[ - { - "spirit": "Meow Wow", - "routes": [ - { - "id": 0, - "name": "Stray", - "color": "cyan" - }, - { - "id": 1, - "name": "Smart Cookie", - "color": "purple" - } - ], - "abilities": [ - { - "name": "Start", - "pos": "A2", - "type": "Start", - "price": "", - "path": ["E"] - }, - { - "name": "Link Critical", - "pos": "B2", - "type": "Spirit", - "price": "10 LP", - "path": ["W", "E"] - }, - { - "name": "Magic Haste", - "pos": "C1", - "type": "Stat", - "price": "30 LP", - "path": ["S", "E"] - }, - { - "name": "Cure", - "pos": "C2", - "type": "Magic", - "price": "50 LP", - "path": ["N", "W", "E", "S"] - }, - { - "name": "Item Boost", - "pos": "C3", - "type": "Stat", - "price": "30 LP", - "path": ["E", "N"] - }, - { - "name": "Light Screen", - "pos": "D1", - "type": "Stat", - "price": "20 LP", - "path": ["E", "W"] - }, - { - "name": "Checkpoint", - "pos": "D2", - "type": "Checkpoint", - "price": "Level 10", - "path": ["E", "W"] - }, - { - "name": "Slow", - "pos": "D3", - "type": "Magic", - "price": "50 LP", - "path": ["E", "W"] - }, - { - "name": "Defense Boost", - "pos": "E1", - "type": "Stat", - "price": "100 LP", - "path": ["E", "W"] - }, - { - "name": "Cura", - "pos": "E2", - "type": "Magic", - "price": "100 LP", - "path": ["E", "W"] - }, - { - "name": "Poison Block", - "pos": "E3", - "type": "Stat", - "price": "30 LP", - "path": ["E", "S", "W"] - }, - { - "name": "Spark", - "pos": "E4", - "type": "Magic", - "price": "50 LP", - "path": ["N"] - }, - { - "name": "Confusion Block", - "pos": "F1", - "type": "Stat", - "price": "30 LP", - "route": 0, - "path": ["E", "W"] - }, - { - "name": "Leaf Bracer", - "pos": "F2", - "type": "Support", - "price": "300 LP", - "path": ["E", "W"] - }, - { - "name": "Attack Haste", - "pos": "F3", - "type": "Stat", - "price": "30 LP", - "route": 1, - "path": ["E", "W"] - }, - { - "name": "HP Boost", - "pos": "G1", - "type": "Stat", - "price": "30 LP", - "route": 0, - "path": ["W"] - }, - { - "name": "Checkpoint", - "pos": "G2", - "type": "Checkpoint", - "price": "Level 25", - "path": ["E", "W"] - }, - { - "name": "Magic Boost", - "pos": "G3", - "type": "Stat", - "price": "100 LP", - "route": 1, - "path": ["W"] - }, - { - "name": "Curaga", - "pos": "H2", - "type": "Magic", - "price": "150 LP", - "path": ["W"] - } - ] - }, - { - "spirit": "Komory Bat", - "routes": [ - { - "id": 0, - "name": "Rescuer", - "color": "cyan" - }, - { - "id": 1, - "name": "Aggro", - "color": "purple" - } - ], - "abilities": [ - { - "name": "Start", - "pos": "A3", - "type": "Start", - "price": "", - "path": ["E"] - }, - { - "name": "Waking Dream", - "pos": "B3", - "type": "Spirit", - "price": "10 LP", - "path": ["W", "E"] - }, - { - "name": "Checkpoint", - "pos": "C1", - "type": "Checkpoint", - "price": "Link x2", - "path": ["E", "S"] - }, - { - "name": "Zero Gravity", - "pos": "C2", - "type": "Magic", - "price": "50 LP", - "path": ["N", "E", "S"] - }, - { - "name": "Confuse", - "pos": "C3", - "type": "Magic", - "price": "50 LP", - "path": ["S", "N", "W", "E"] - }, - { - "name": "Dark Screen", - "pos": "C4", - "type": "Stat", - "price": "20 LP", - "path": ["N", "E", "S"] - }, - { - "name": "Magic Haste", - "pos": "C5", - "type": "Stat", - "price": "50 LP", - "route": 0, - "path": ["N", "E"] - }, - { - "name": "Zero Gravira", - "pos": "D1", - "type": "Magic", - "price": "100 LP", - "path": ["W"] - }, - { - "name": "Confusion Block", - "pos": "D2", - "type": "Stat", - "price": "30 LP", - "path": ["W", "S"] - }, - { - "name": "Drain Dive", - "pos": "D3", - "type": "Attack", - "price": "50 LP", - "path": ["N", "S", "W", "E"] - }, - { - "name": "Magic Boost", - "pos": "D4", - "type": "Stat", - "price": "100 LP", - "path": ["W", "N", "E"] - }, - { - "name": "Magic Haste", - "pos": "D5", - "type": "Stat", - "price": "100 LP", - "route": 0, - "path": ["W"] - }, - { - "name": "Attack Boost", - "pos": "E2", - "type": "Stat", - "price": "100 LP", - "path": ["S"] - }, - { - "name": "Magic Haste", - "pos": "E3", - "type": "Stat", - "price": "30 LP", - "path": ["W", "E", "N"] - }, - { - "name": "Attack Haste", - "pos": "E4", - "type": "Stat", - "price": "30 LP", - "route": 1, - "path": ["W", "E"] - }, - { - "name": "Dark Screen", - "pos": "F3", - "type": "Stat", - "price": "40 LP", - "path": ["W", "E"] - }, - { - "name": "Attack Haste", - "pos": "F4", - "type": "Stat", - "price": "50 LP", - "route": 1, - "path": ["W"] - }, - { - "name": "Checkpoint", - "pos": "G3", - "type": "Checkpoint", - "price": "Link x2", - "path": ["W", "E"] - }, - { - "name": "Confusing Strike", - "pos": "H3", - "type": "Attack", - "price": "100 LP", - "path": ["W"] - } - ] - }, - { - "spirit": "Necho Cat", - "routes": [ - { - "id": 0, - "name": "Diva", - "color": "cyan" - }, - { - "id": 1, - "name": "Artist", - "color": "green" - } - ], - "abilities": [ - { - "name": "Magic Boost", - "pos": "A4", - "type": "Stat", - "price": "200 LP", - "route": 0, - "path": ["E"] - }, - { - "name": "Support Boost", - "pos": "B1", - "type": "Spirit", - "price": "200 LP", - "path": ["E"] - }, - { - "name": "HP Boost", - "pos": "B3", - "type": "Stat", - "price": "30 LP", - "path": ["E"] - }, - { - "name": "Confusion Block", - "pos": "B4", - "type": "Stat", - "price": "30 LP", - "route": 0, - "path": ["W", "E"] - }, - { - "name": "Thunder Boost", - "pos": "B5", - "type": "Stat", - "price": "50 LP", - "path": ["E", "S"] - }, - { - "name": "Magic Haste", - "pos": "B6", - "type": "Stat", - "price": "50 LP", - "path": ["E", "N"] - }, - { - "name": "Checkpoint", - "pos": "C1", - "type": "Checkpoint", - "price": "Link x3", - "path": ["W", "S"] - }, - { - "name": "Magic Boost", - "pos": "C2", - "type": "Stat", - "price": "100 LP", - "path": ["E", "N", "S"] - }, - { - "name": "Sleepra", - "pos": "C3", - "type": "Magic", - "price": "100 LP", - "path": ["W", "E", "N", "S"] - }, - { - "name": "Magic Haste", - "pos": "C4", - "type": "Stat", - "price": "50 LP", - "path": ["W", "E", "N", "S"] - }, - { - "name": "Thunder Boost", - "pos": "C5", - "type": "Stat", - "price": "30 LP", - "path": ["W", "E", "N", "S"] - }, - { - "name": "Thunder", - "pos": "C6", - "type": "Magic", - "price": "10 LP", - "path": ["W", "N", "S"] - }, - { - "name": "Start", - "pos": "C7", - "type": "Start", - "price": "", - "path": ["N"] - }, - { - "name": "Thunder Boost", - "pos": "D2", - "type": "Stat", - "price": "100 LP", - "route": 1, - "path": ["W", "E"] - }, - { - "name": "Magic Haste", - "pos": "D3", - "type": "Stat", - "price": "100 LP", - "path": ["W", "S"] - }, - { - "name": "Time Bomb", - "pos": "D4", - "type": "Magic", - "price": "50 LP", - "path": ["W", "N"] - }, - { - "name": "Sleep Block", - "pos": "D5", - "type": "Stat", - "price": "30 LP", - "path": ["W"] - }, - { - "name": "Magic Haste", - "pos": "E2", - "type": "Stat", - "price": "150 LP", - "route": 1, - "path": ["W"] - } - ] - } -] diff --git a/input/ddd/abilities/komory-bat.json b/input/ddd/abilities/komory-bat.json new file mode 100644 index 0000000..d76b831 --- /dev/null +++ b/input/ddd/abilities/komory-bat.json @@ -0,0 +1,221 @@ +{ + "spirit": "Komory Bat", + "order": 4, + "routes": [ + { + "id": 0, + "name": "Rescuer", + "color": "blue", + "tips": [ + { + "to": "Aggro", + "tip": "Face" + }, + { + "to": "Wingman", + "tip": "Face" + }, + { + "to": "Saboteur", + "tip": "Ears" + } + ] + }, + { + "id": 1, + "name": "Aggro", + "color": "purple", + "tips": [ + { + "to": "Rescuer", + "tip": "Face" + }, + { + "to": "Wingman", + "tip": "Wings" + }, + { + "to": "Saboteur", + "tip": "Face" + } + ] + }, + { + "id": 2, + "name": "Wingman", + "color": "yellow", + "tips": [ + { + "to": "Rescuer", + "tip": "Face" + }, + { + "to": "Aggro", + "tip": "Ears" + }, + { + "to": "Saboteur", + "tip": "Wings" + } + ] + }, + { + "id": 3, + "name": "Saboteur", + "color": "green", + "tips": [ + { + "to": "Rescuer", + "tip": "Face" + }, + { + "to": "Aggro", + "tip": "Ears" + }, + { + "to": "Wingman", + "tip": "Ears" + } + ] + } + ], + "abilities": [ + { + "name": "Start", + "pos": "A3", + "type": "Start", + "price": "", + "path": ["E"] + }, + { + "name": "Waking Dream", + "pos": "B3", + "type": "Spirit", + "price": "10 LP", + "path": ["W", "E"] + }, + { + "name": "Checkpoint", + "pos": "C1", + "type": "Checkpoint", + "price": "Link x2", + "path": ["E", "S"] + }, + { + "name": "Zero Gravity", + "pos": "C2", + "type": "Magic", + "price": "50 LP", + "path": ["N", "E", "S"] + }, + { + "name": "Confuse", + "pos": "C3", + "type": "Magic", + "price": "50 LP", + "path": ["S", "N", "W", "E"] + }, + { + "name": "Dark Screen", + "pos": "C4", + "type": "Stat", + "price": "20 LP", + "path": ["N", "E", "S"] + }, + { + "name": "Magic Haste", + "pos": "C5", + "type": "Stat", + "price": "50 LP", + "route": 0, + "path": ["N", "E"] + }, + { + "name": "Zero Gravira", + "pos": "D1", + "type": "Magic", + "price": "100 LP", + "path": ["W"] + }, + { + "name": "Confusion Block", + "pos": "D2", + "type": "Stat", + "price": "30 LP", + "path": ["W", "S"] + }, + { + "name": "Drain Dive", + "pos": "D3", + "type": "Attack", + "price": "50 LP", + "path": ["N", "S", "W", "E"] + }, + { + "name": "Magic Boost", + "pos": "D4", + "type": "Stat", + "price": "100 LP", + "path": ["W", "N", "E"] + }, + { + "name": "Magic Haste", + "pos": "D5", + "type": "Stat", + "price": "100 LP", + "route": 0, + "path": ["W"] + }, + { + "name": "Attack Boost", + "pos": "E2", + "type": "Stat", + "price": "100 LP", + "path": ["S"] + }, + { + "name": "Magic Haste", + "pos": "E3", + "type": "Stat", + "price": "30 LP", + "path": ["W", "E", "N"] + }, + { + "name": "Attack Haste", + "pos": "E4", + "type": "Stat", + "price": "30 LP", + "route": 1, + "path": ["W", "E"] + }, + { + "name": "Dark Screen", + "pos": "F3", + "type": "Stat", + "price": "40 LP", + "path": ["W", "E"] + }, + { + "name": "Attack Haste", + "pos": "F4", + "type": "Stat", + "price": "50 LP", + "route": 1, + "path": ["W"] + }, + { + "name": "Checkpoint", + "pos": "G3", + "type": "Checkpoint", + "price": "Link x2", + "path": ["W", "E"] + }, + { + "name": "Confusing Strike", + "pos": "H3", + "type": "Attack", + "price": "100 LP", + "path": ["W"] + } + ] +} diff --git a/input/ddd/abilities/meow-wow.json b/input/ddd/abilities/meow-wow.json new file mode 100644 index 0000000..6f1b526 --- /dev/null +++ b/input/ddd/abilities/meow-wow.json @@ -0,0 +1,221 @@ +{ + "spirit": "Meow Wow", + "order": 1, + "routes": [ + { + "id": 0, + "name": "Stray", + "color": "purple", + "tips": [ + { + "to": "Smart Cookie", + "tip": "Tail" + }, + { + "to": "Rascal", + "tip": "Face" + }, + { + "to": "Sidekick", + "tip": "Legs" + } + ] + }, + { + "id": 1, + "name": "Smart Cookie", + "color": "blue", + "tips": [ + { + "to": "Stray", + "tip": "Tail" + }, + { + "to": "Rascal", + "tip": "Tail" + }, + { + "to": "Sidekick", + "tip": "Face" + } + ] + }, + { + "id": 3, + "name": "Rascal", + "color": "yellow", + "tips": [ + { + "to": "Stray", + "tip": "Legs" + }, + { + "to": "Smart Cookie", + "tip": "Face" + }, + { + "to": "Sidekick", + "tip": "Tail" + } + ] + }, + { + "id": 4, + "name": "Sidekick", + "color": "green", + "tips": [ + { + "to": "Stray", + "tip": "Legs" + }, + { + "to": "Smart Cookie", + "tip": "Face" + }, + { + "to": "Rascal", + "tip": "Tail" + } + ] + } + ], + "abilities": [ + { + "name": "Start", + "pos": "A2", + "type": "Start", + "price": "", + "path": ["E"] + }, + { + "name": "Link Critical", + "pos": "B2", + "type": "Spirit", + "price": "10 LP", + "path": ["W", "E"] + }, + { + "name": "Magic Haste", + "pos": "C1", + "type": "Stat", + "price": "30 LP", + "path": ["S", "E"] + }, + { + "name": "Cure", + "pos": "C2", + "type": "Magic", + "price": "50 LP", + "path": ["N", "W", "E", "S"] + }, + { + "name": "Item Boost", + "pos": "C3", + "type": "Stat", + "price": "30 LP", + "path": ["E", "N"] + }, + { + "name": "Light Screen", + "pos": "D1", + "type": "Stat", + "price": "20 LP", + "path": ["E", "W"] + }, + { + "name": "Checkpoint", + "pos": "D2", + "type": "Checkpoint", + "price": "Level 10", + "path": ["E", "W"] + }, + { + "name": "Slow", + "pos": "D3", + "type": "Magic", + "price": "50 LP", + "path": ["E", "W"] + }, + { + "name": "Defense Boost", + "pos": "E1", + "type": "Stat", + "price": "100 LP", + "path": ["E", "W"] + }, + { + "name": "Cura", + "pos": "E2", + "type": "Magic", + "price": "100 LP", + "path": ["E", "W"] + }, + { + "name": "Poison Block", + "pos": "E3", + "type": "Stat", + "price": "30 LP", + "path": ["E", "S", "W"] + }, + { + "name": "Spark", + "pos": "E4", + "type": "Magic", + "price": "50 LP", + "path": ["N"] + }, + { + "name": "Confusion Block", + "pos": "F1", + "type": "Stat", + "price": "30 LP", + "route": 0, + "path": ["E", "W"] + }, + { + "name": "Leaf Bracer", + "pos": "F2", + "type": "Support", + "price": "300 LP", + "path": ["E", "W"] + }, + { + "name": "Attack Haste", + "pos": "F3", + "type": "Stat", + "price": "30 LP", + "route": 1, + "path": ["E", "W"] + }, + { + "name": "HP Boost", + "pos": "G1", + "type": "Stat", + "price": "30 LP", + "route": 0, + "path": ["W"] + }, + { + "name": "Checkpoint", + "pos": "G2", + "type": "Checkpoint", + "price": "Level 25", + "path": ["E", "W"] + }, + { + "name": "Magic Boost", + "pos": "G3", + "type": "Stat", + "price": "100 LP", + "route": 1, + "path": ["W"] + }, + { + "name": "Curaga", + "pos": "H2", + "type": "Magic", + "price": "150 LP", + "path": ["W"] + } + ] +} diff --git a/input/ddd/abilities/necho-cat.json b/input/ddd/abilities/necho-cat.json new file mode 100644 index 0000000..1f6c31a --- /dev/null +++ b/input/ddd/abilities/necho-cat.json @@ -0,0 +1,214 @@ +{ + "spirit": "Necho Cat", + "order": 11, + "routes": [ + { + "id": 0, + "name": "Diva", + "color": "blue", + "tips": [ + { + "to": "Multi-Talent", + "tip": "Face" + }, + { + "to": "Dancer", + "tip": "Face" + }, + { + "to": "Artist", + "tip": "Body" + } + ] + }, + { + "id": 1, + "name": "Artist", + "color": "green", + "tips": [ + { + "to": "Dancer", + "tip": "Face" + }, + { + "to": "Multi-Talent", + "tip": "Face" + }, + { + "to": "Diva", + "tip": "Legs" + } + ] + }, + { + "id": 2, + "name": "Multi-Talent", + "color": "purple", + "tips": [ + { + "to": "Diva", + "tip": "Face" + }, + { + "to": "Artist", + "tip": "Face" + }, + { + "to": "Dancer", + "tip": "Legs" + } + ] + }, + { + "id": 3, + "name": "Dancer", + "color": "yellow", + "tips": [ + { + "to": "Artist", + "tip": "Legs" + }, + { + "to": "Multi-Talent", + "tip": "Face" + }, + { + "to": "Diva", + "tip": "Legs" + } + ] + } + ], + "abilities": [ + { + "name": "Magic Boost", + "pos": "A4", + "type": "Stat", + "price": "200 LP", + "route": 0, + "path": ["E"] + }, + { + "name": "Support Boost", + "pos": "B1", + "type": "Spirit", + "price": "200 LP", + "path": ["E"] + }, + { + "name": "HP Boost", + "pos": "B3", + "type": "Stat", + "price": "30 LP", + "path": ["E"] + }, + { + "name": "Confusion Block", + "pos": "B4", + "type": "Stat", + "price": "30 LP", + "route": 0, + "path": ["W", "E"] + }, + { + "name": "Thunder Boost", + "pos": "B5", + "type": "Stat", + "price": "50 LP", + "path": ["E", "S"] + }, + { + "name": "Magic Haste", + "pos": "B6", + "type": "Stat", + "price": "50 LP", + "path": ["E", "N"] + }, + { + "name": "Checkpoint", + "pos": "C1", + "type": "Checkpoint", + "price": "Link x3", + "path": ["W", "S"] + }, + { + "name": "Magic Boost", + "pos": "C2", + "type": "Stat", + "price": "100 LP", + "path": ["E", "N", "S"] + }, + { + "name": "Sleepra", + "pos": "C3", + "type": "Magic", + "price": "100 LP", + "path": ["W", "E", "N", "S"] + }, + { + "name": "Magic Haste", + "pos": "C4", + "type": "Stat", + "price": "50 LP", + "path": ["W", "E", "N", "S"] + }, + { + "name": "Thunder Boost", + "pos": "C5", + "type": "Stat", + "price": "30 LP", + "path": ["W", "E", "N", "S"] + }, + { + "name": "Thunder", + "pos": "C6", + "type": "Magic", + "price": "10 LP", + "path": ["W", "N", "S"] + }, + { + "name": "Start", + "pos": "C7", + "type": "Start", + "price": "", + "path": ["N"] + }, + { + "name": "Thunder Boost", + "pos": "D2", + "type": "Stat", + "price": "100 LP", + "route": 1, + "path": ["W", "E"] + }, + { + "name": "Magic Haste", + "pos": "D3", + "type": "Stat", + "price": "100 LP", + "path": ["W", "S"] + }, + { + "name": "Time Bomb", + "pos": "D4", + "type": "Magic", + "price": "50 LP", + "path": ["W", "N"] + }, + { + "name": "Sleep Block", + "pos": "D5", + "type": "Stat", + "price": "30 LP", + "path": ["W"] + }, + { + "name": "Magic Haste", + "pos": "E2", + "type": "Stat", + "price": "150 LP", + "route": 1, + "path": ["W"] + } + ] +} diff --git a/src/ddd.rs b/src/ddd.rs index af48aed..6fcb1ae 100644 --- a/src/ddd.rs +++ b/src/ddd.rs @@ -1,4 +1,4 @@ -use std::panic; +use std::{fmt::Display, panic}; use askama::Template; use itertools::Itertools; @@ -6,6 +6,7 @@ use serde::{Deserialize, Deserializer}; #[derive(Debug, Deserialize, PartialEq, Eq)] struct Board { + order: u32, spirit: String, routes: Vec, abilities: Vec, @@ -20,6 +21,29 @@ struct Board { } impl Board { + pub fn init_routes(&mut self) { + self.routes.iter_mut().for_each(|r| { + r.interaction = match r.color { + DispositionColor::Blue => Interaction::Poke, + DispositionColor::Purple => Interaction::Poke, + DispositionColor::Yellow => Interaction::Rub, + DispositionColor::Green => Interaction::Rub, + } + }); + + let routes = self.routes.clone(); + + self.routes.iter_mut().for_each(|r| { + r.tips.iter_mut().for_each(|t| { + let route = routes.iter().find(|r| r.name == t.to); + if let Some(route) = route { + t.to_color = route.color.clone(); + t.tip = format!("{} {}", route.interaction, t.tip); + } + }); + }); + } + pub fn init_stats(&mut self) { let v = self .abilities @@ -105,7 +129,7 @@ impl Board { .collect_vec() } - pub fn get_spirit(&self) -> Vec<&Ability> { + pub fn get_spirits(&self) -> Vec<&Ability> { self.abilities .iter() .filter(|&ability| ability.r#type == AbilityType::Spirit) @@ -113,11 +137,49 @@ impl Board { } } -#[derive(Debug, Deserialize, PartialEq, Eq)] +#[derive(Debug, Deserialize, PartialEq, Eq, Clone)] struct Route { id: u32, name: String, - color: String, + color: DispositionColor, + tips: Vec, + #[serde(skip_deserializing)] + interaction: Interaction, +} + +#[derive(Debug, Deserialize, PartialEq, Eq, Clone)] +enum DispositionColor { + #[serde(alias = "blue")] + Blue, + #[serde(alias = "purple")] + Purple, + #[serde(alias = "yellow")] + Yellow, + #[serde(alias = "green")] + Green, +} + +impl Display for DispositionColor { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + DispositionColor::Blue => f.write_str("blue"), + DispositionColor::Purple => f.write_str("purple"), + DispositionColor::Yellow => f.write_str("yellow"), + DispositionColor::Green => f.write_str("green"), + } + } +} + +#[derive(Debug, Deserialize, PartialEq, Eq, Clone)] +struct Tip { + to: String, + #[serde(skip_deserializing, default = "default_disposition_color")] + to_color: DispositionColor, + tip: String, +} + +fn default_disposition_color() -> DispositionColor { + DispositionColor::Blue } #[derive(Debug, Deserialize, PartialEq, Eq)] @@ -216,24 +278,48 @@ enum Direction { West, } +#[derive(Debug, Default, Deserialize, PartialEq, Eq, Clone)] +enum Interaction { + #[default] + Poke, + Rub, +} + +impl Display for Interaction { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Interaction::Poke => f.write_str("Poke"), + Interaction::Rub => f.write_str("Rub"), + } + } +} + #[derive(Template)] #[template(path = "pages/ddd-abilities.html", whitespace = "suppress")] struct AbilitiesTemplate { pub boards: Vec, } -const ABILITIES_PATH: &str = "./input/ddd/abilities.json"; +const ABILITIES_PATH: &str = "./input/ddd/abilities"; pub fn init() { tracing::info!("Loading ability links json data from {}", ABILITIES_PATH); - let boards_str = std::fs::read_to_string(ABILITIES_PATH).unwrap(); - let mut boards = serde_json::from_str::>(&boards_str).unwrap(); + let mut boards: Vec = vec![]; + // Loading multiple files into one vector due to the size of each board + let paths = std::fs::read_dir(ABILITIES_PATH).unwrap(); + for path in paths.flatten() { + let board_str = std::fs::read_to_string(path.path()).unwrap(); + let mut board = serde_json::from_str::(&board_str).unwrap(); - for board in &mut boards { + board.init_routes(); board.init_total_lp(); board.init_max_level(); board.init_stats(); + + // dbg!(&board); + boards.push(board); } + boards.sort_by(|a, b| a.order.cmp(&b.order)); tracing::info!("Generating the DDD ability boards template"); let template = AbilitiesTemplate { boards }; diff --git a/templates/components/ddd/abilities.html b/templates/components/ddd/abilities.html new file mode 100644 index 0000000..176af36 --- /dev/null +++ b/templates/components/ddd/abilities.html @@ -0,0 +1,33 @@ +
+
+

Stats

+
    + {% for val in board.stats %} +
  • x{{+ val.0 +}} {{+ val.1 +}}
  • + {% endfor %} +
+
+ + {% let supports = board.get_supports() %} + {% if supports.len() > 0 %} +
+

Support

+
    + {% for ability in supports %} +
  • {{ ability.name }}
  • + {% endfor %} +
+
+ {% endif %} + {% let spirits = board.get_spirits() %} + {% if spirits.len() > 0 %} +
+

Spirit

+
    + {% for ability in spirits %} +
  • {{ ability.name }}
  • + {% endfor %} +
+
+ {% endif %} +
diff --git a/templates/components/ddd/board-row.html b/templates/components/ddd/board-row.html new file mode 100644 index 0000000..7581d53 --- /dev/null +++ b/templates/components/ddd/board-row.html @@ -0,0 +1,23 @@ + + {{ y }} + {% for x in 1..board.get_size().0 + 1 %} + {% let ability = board.get_ability_at(x, y) %} + {% match ability %} + {% when Some with (val) %} + +
+ {{ val.name }} + {% match val.type %} + {% when AbilityType::Checkpoint %} +
+ {{ val.price }} + {% when _ %} + {% endmatch %} +
+
+ + {% when None %} + + {% endmatch %} + {% endfor %} + diff --git a/templates/components/ddd/board.html b/templates/components/ddd/board.html new file mode 100644 index 0000000..8034afa --- /dev/null +++ b/templates/components/ddd/board.html @@ -0,0 +1,15 @@ +

Board

+ + + + + + {% for x in 1..board.get_size().0 + 1 %} + + {% endfor %} + + {% for y in 1..board.get_size().1 + 1 %} + {% include "components/ddd/board-row.html" %} + {% endfor %} + +
{{ board.get_char(x) }}
diff --git a/templates/components/ddd/dispositions.html b/templates/components/ddd/dispositions.html new file mode 100644 index 0000000..ead0cd3 --- /dev/null +++ b/templates/components/ddd/dispositions.html @@ -0,0 +1,18 @@ +

Dispositions

+ +{% for route in board.routes %} +
+
+
+ {{ route.name }} +
+
    + {% for tip in route.tips %} +
  • +
    + {{+ tip.to +}}: {{+ tip.tip +}} +
  • + {% endfor %} +
+
+{% endfor %} diff --git a/templates/layouts/base.html b/templates/layouts/base.html index edf1ca2..8872066 100644 --- a/templates/layouts/base.html +++ b/templates/layouts/base.html @@ -36,6 +36,10 @@ background-color: #252525; } } + + ul { + line-height: 1.5; + } {% block head %}{% endblock %} diff --git a/templates/pages/ddd-abilities.html b/templates/pages/ddd-abilities.html index bc36c1c..32842d2 100644 --- a/templates/pages/ddd-abilities.html +++ b/templates/pages/ddd-abilities.html @@ -4,7 +4,62 @@ {% block head %}