105 lines
2.7 KiB
Rust
105 lines
2.7 KiB
Rust
use log::warn;
|
|
use std::{collections::HashSet, str::FromStr};
|
|
#[derive(sqlx::Type, Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
|
pub enum Operator {
|
|
Chen,
|
|
Siege,
|
|
Shining,
|
|
Nightingale,
|
|
Ifrit,
|
|
Eyjafjalla,
|
|
Exusiai,
|
|
Angelina,
|
|
SilverAsh,
|
|
Hoshiguma,
|
|
Saria,
|
|
Skadi,
|
|
Schwarz,
|
|
Hellagur,
|
|
Magallan,
|
|
Mostima,
|
|
Blaze,
|
|
Aak,
|
|
Nian,
|
|
Ceobe,
|
|
Bagpipe,
|
|
Phantom,
|
|
W,
|
|
Weedy,
|
|
}
|
|
|
|
pub fn get_global_ops() -> HashSet<Operator> {
|
|
let global_ops = &[
|
|
Operator::Chen,
|
|
Operator::Siege,
|
|
Operator::Shining,
|
|
Operator::Nightingale,
|
|
Operator::Ifrit,
|
|
Operator::Eyjafjalla,
|
|
Operator::Exusiai,
|
|
Operator::Angelina,
|
|
Operator::SilverAsh,
|
|
Operator::Hoshiguma,
|
|
Operator::Saria,
|
|
Operator::Skadi,
|
|
Operator::Schwarz,
|
|
Operator::Hellagur,
|
|
Operator::Magallan,
|
|
];
|
|
let mut set = HashSet::with_capacity(global_ops.len());
|
|
set.extend(global_ops);
|
|
set
|
|
}
|
|
|
|
pub fn get_china_ops() -> HashSet<Operator> {
|
|
let mut global_ops = get_global_ops();
|
|
global_ops.extend(&[
|
|
Operator::Mostima,
|
|
Operator::Blaze,
|
|
Operator::Aak,
|
|
Operator::Nian,
|
|
Operator::Ceobe,
|
|
Operator::Bagpipe,
|
|
Operator::Phantom,
|
|
Operator::W,
|
|
Operator::Weedy,
|
|
]);
|
|
global_ops
|
|
}
|
|
|
|
impl FromStr for Operator {
|
|
type Err = ();
|
|
fn from_str(value: &str) -> Result<Self, Self::Err> {
|
|
match value.to_ascii_lowercase().as_ref() {
|
|
"chen" | "ch'en" => Ok(Self::Chen),
|
|
"siege" => Ok(Self::Siege),
|
|
"shining" => Ok(Self::Shining),
|
|
"nightingale" => Ok(Self::Nightingale),
|
|
"ifrit" => Ok(Self::Ifrit),
|
|
"effy" | "eyja" | "eyjafjalla" => Ok(Self::Eyjafjalla),
|
|
"exu" | "exusiai" | "apple pie" | "appuru pai" => Ok(Self::Exusiai),
|
|
"angelina" => Ok(Self::Angelina),
|
|
"sa" | "silver daddy" | "silverash" => Ok(Self::SilverAsh),
|
|
"hoshi" | "hoshiguma" => Ok(Self::Hoshiguma),
|
|
"saria" => Ok(Self::Saria),
|
|
"skadi" => Ok(Self::Skadi),
|
|
"schwarz" => Ok(Self::Schwarz),
|
|
"hellagur" => Ok(Self::Hellagur),
|
|
"penguin" | "magallan" => Ok(Self::Magallan),
|
|
"mostina" => Ok(Self::Mostima),
|
|
"blaze" => Ok(Self::Blaze),
|
|
"aak" => Ok(Self::Aak),
|
|
"nian" => Ok(Self::Nian),
|
|
"ceobe" => Ok(Self::Ceobe),
|
|
"bagpipe" => Ok(Self::Bagpipe),
|
|
"phantom" => Ok(Self::Phantom),
|
|
"w" => Ok(Self::W),
|
|
"weedy" => Ok(Self::Weedy),
|
|
_ => {
|
|
warn!("Failed to convert {}", value);
|
|
Err(())
|
|
}
|
|
}
|
|
}
|
|
}
|