Fixed melding menu not using the common css and its sorting
parent
b606c3b095
commit
ba906ec966
|
|
@ -1,3 +1,5 @@
|
||||||
|
@import url("./common.css");
|
||||||
|
|
||||||
table {
|
table {
|
||||||
thead {
|
thead {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fmt::{self, Display},
|
fmt::{self},
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
string::ParseError,
|
string::ParseError,
|
||||||
};
|
};
|
||||||
|
|
||||||
use ability::Abilities;
|
use ability::Abilities;
|
||||||
use askama::{FastWritable, Template, filters::HtmlSafe};
|
use askama::Template;
|
||||||
use command::Command;
|
use command::Command;
|
||||||
use finisher::Finisher;
|
use finisher::Finisher;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
@ -23,7 +23,7 @@ pub const ABILITIES_PATH: &str = "./input/bbs/abilities.toml";
|
||||||
const FINISHERS_PATH: &str = "./input/bbs/finishers.toml";
|
const FINISHERS_PATH: &str = "./input/bbs/finishers.toml";
|
||||||
pub const COMMANDS_PATH: &str = "./input/bbs/commands";
|
pub const COMMANDS_PATH: &str = "./input/bbs/commands";
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, PartialEq, Eq)]
|
#[derive(Debug, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
enum Character {
|
enum Character {
|
||||||
#[serde(alias = "A")]
|
#[serde(alias = "A")]
|
||||||
Aqua,
|
Aqua,
|
||||||
|
|
@ -100,7 +100,6 @@ impl RuntimeModule for Module {
|
||||||
|
|
||||||
tracing::info!("Loading BBS commands data from {}", ABILITIES_PATH);
|
tracing::info!("Loading BBS commands data from {}", ABILITIES_PATH);
|
||||||
let mut commands = Command::import();
|
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
|
// Create a vec with all the crystal variants found in abilities
|
||||||
let crystals = abilities
|
let crystals = abilities
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,35 @@
|
||||||
use std::path::PathBuf;
|
use core::fmt;
|
||||||
|
use std::{cmp, path::PathBuf};
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use super::{COMMANDS_PATH, melding::CommandRecipe};
|
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 struct Command {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub order: u32,
|
pub order: u32,
|
||||||
pub category: String,
|
pub category: CommandCategory,
|
||||||
pub char: Vec<char>,
|
pub char: Vec<char>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub info: Option<String>,
|
pub info: Option<String>,
|
||||||
|
|
@ -16,6 +37,35 @@ pub struct Command {
|
||||||
pub recipes: Vec<CommandRecipe>,
|
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 {
|
impl Command {
|
||||||
pub fn import() -> Vec<Command> {
|
pub fn import() -> Vec<Command> {
|
||||||
let mut commands = vec![];
|
let mut commands = vec![];
|
||||||
|
|
@ -36,6 +86,8 @@ impl Command {
|
||||||
commands.push(cmd);
|
commands.push(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
commands.sort();
|
||||||
|
|
||||||
commands
|
commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use serde::Deserialize;
|
||||||
|
|
||||||
use super::{Character, ability::Ability};
|
use super::{Character, ability::Ability};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub struct CommandRecipe {
|
pub struct CommandRecipe {
|
||||||
pub char: Vec<Character>,
|
pub char: Vec<Character>,
|
||||||
pub r#type: char,
|
pub r#type: char,
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,7 @@ pub struct GameProps {
|
||||||
|
|
||||||
impl GameProps {
|
impl GameProps {
|
||||||
pub fn final_mix() -> Self {
|
pub fn final_mix() -> Self {
|
||||||
Self {
|
Self { is_final_mix: true }
|
||||||
is_final_mix: true,
|
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use serde::Deserialize;
|
||||||
use crate::ASSETS_FOLDER_PATH;
|
use crate::ASSETS_FOLDER_PATH;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
Game, GameProps,
|
Game,
|
||||||
enemy::{Enemy, EnemyDrop},
|
enemy::{Enemy, EnemyDrop},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use askama::Template;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
RuntimeModule,
|
RuntimeModule,
|
||||||
common::{Game, drops::Drops, enemy::Enemy, synthesis::Synthesis},
|
common::{drops::Drops, synthesis::Synthesis},
|
||||||
create_file,
|
create_file,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue