Fixed melding menu not using the common css and its sorting

master
Wynd 2026-03-04 02:04:24 +02:00
parent b606c3b095
commit ba906ec966
7 changed files with 64 additions and 14 deletions

View File

@ -1,3 +1,5 @@
@import url("./common.css");
table {
thead {
position: sticky;

View File

@ -1,12 +1,12 @@
use std::{
collections::HashMap,
fmt::{self, Display},
fmt::{self},
str::FromStr,
string::ParseError,
};
use ability::Abilities;
use askama::{FastWritable, Template, filters::HtmlSafe};
use askama::Template;
use command::Command;
use finisher::Finisher;
use itertools::Itertools;
@ -23,7 +23,7 @@ pub const ABILITIES_PATH: &str = "./input/bbs/abilities.toml";
const FINISHERS_PATH: &str = "./input/bbs/finishers.toml";
pub const COMMANDS_PATH: &str = "./input/bbs/commands";
#[derive(Debug, Deserialize, PartialEq, Eq)]
#[derive(Debug, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
enum Character {
#[serde(alias = "A")]
Aqua,
@ -100,7 +100,6 @@ impl RuntimeModule for Module {
tracing::info!("Loading BBS commands data from {}", ABILITIES_PATH);
let mut commands = Command::import();
commands.sort_by(|a, b| a.order.cmp(&b.order));
// Create a vec with all the crystal variants found in abilities
let crystals = abilities

View File

@ -1,14 +1,35 @@
use std::path::PathBuf;
use core::fmt;
use std::{cmp, path::PathBuf};
use serde::Deserialize;
use super::{COMMANDS_PATH, melding::CommandRecipe};
#[derive(Debug, Deserialize)]
#[derive(Debug, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
#[serde(rename_all = "lowercase")]
pub enum CommandCategory {
Attack,
Magic,
Action,
Shotlock,
}
impl fmt::Display for CommandCategory {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
CommandCategory::Attack => f.write_str("attack"),
CommandCategory::Magic => f.write_str("magic"),
CommandCategory::Action => f.write_str("action"),
CommandCategory::Shotlock => f.write_str("shotlock"),
}
}
}
#[derive(Debug, Deserialize, PartialEq, Eq)]
pub struct Command {
pub name: String,
pub order: u32,
pub category: String,
pub category: CommandCategory,
pub char: Vec<char>,
#[serde(default)]
pub info: Option<String>,
@ -16,6 +37,35 @@ pub struct Command {
pub recipes: Vec<CommandRecipe>,
}
impl PartialOrd for Command {
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Ord for Command {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
let self_mod = match self.category {
CommandCategory::Attack => 0,
CommandCategory::Magic => 100,
CommandCategory::Action => 200,
CommandCategory::Shotlock => 300,
};
let other_mod = match other.category {
CommandCategory::Attack => 0,
CommandCategory::Magic => 100,
CommandCategory::Action => 200,
CommandCategory::Shotlock => 300,
};
let o1 = self.order + self_mod;
let o2 = other.order + other_mod;
Ord::cmp(&o1, &o2)
}
}
impl Command {
pub fn import() -> Vec<Command> {
let mut commands = vec![];
@ -36,6 +86,8 @@ impl Command {
commands.push(cmd);
}
commands.sort();
commands
}
}

View File

@ -2,7 +2,7 @@ use serde::Deserialize;
use super::{Character, ability::Ability};
#[derive(Debug, Deserialize)]
#[derive(Debug, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub struct CommandRecipe {
pub char: Vec<Character>,
pub r#type: char,

View File

@ -15,10 +15,7 @@ pub struct GameProps {
impl GameProps {
pub fn final_mix() -> Self {
Self {
is_final_mix: true,
..Default::default()
}
Self { is_final_mix: true }
}
}

View File

@ -5,7 +5,7 @@ use serde::Deserialize;
use crate::ASSETS_FOLDER_PATH;
use super::{
Game, GameProps,
Game,
enemy::{Enemy, EnemyDrop},
};

View File

@ -2,7 +2,7 @@ use askama::Template;
use crate::{
RuntimeModule,
common::{Game, drops::Drops, enemy::Enemy, synthesis::Synthesis},
common::{drops::Drops, synthesis::Synthesis},
create_file,
};