feat: add guardians
This commit is contained in:
parent
3256fdd18a
commit
798ed39403
|
@ -29,6 +29,7 @@ worlds = []
|
|||
# Character-related
|
||||
races = []
|
||||
clans = []
|
||||
guardians = []
|
||||
|
||||
# Serde support
|
||||
with_serde = ["serde", "serde_derive"]
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
//! Guardian deity types
|
||||
|
||||
use errors::UnknownVariant;
|
||||
|
||||
use std::fmt::{Display, Formatter, Result as FmtResult};
|
||||
use std::str::FromStr;
|
||||
|
||||
/// The guardian deities in the game.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[cfg_attr(feature = "with_serde", derive(Serialize, Deserialize))]
|
||||
pub enum Guardian {
|
||||
Althyk,
|
||||
Azeyma,
|
||||
Byregot,
|
||||
Halone,
|
||||
Llymlaen,
|
||||
Menphina,
|
||||
NaldThal,
|
||||
Nophica,
|
||||
Nymeia,
|
||||
Oschon,
|
||||
Rhalgr,
|
||||
Thaliak,
|
||||
}
|
||||
|
||||
impl Guardian {
|
||||
#[cfg(feature = "all_const")]
|
||||
pub const ALL: [Guardian; 12] = [
|
||||
Guardian::Althyk,
|
||||
Guardian::Azeyma,
|
||||
Guardian::Byregot,
|
||||
Guardian::Halone,
|
||||
Guardian::Llymlaen,
|
||||
Guardian::Menphina,
|
||||
Guardian::NaldThal,
|
||||
Guardian::Nophica,
|
||||
Guardian::Nymeia,
|
||||
Guardian::Oschon,
|
||||
Guardian::Rhalgr,
|
||||
Guardian::Thaliak,
|
||||
];
|
||||
|
||||
/// Returns the string variant of this world.
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match *self {
|
||||
Guardian::Althyk => "Althyk",
|
||||
Guardian::Azeyma => "Azeyma",
|
||||
Guardian::Byregot => "Byregot",
|
||||
Guardian::Halone => "Halone",
|
||||
Guardian::Llymlaen => "Llymlaen",
|
||||
Guardian::Menphina => "Menphina",
|
||||
Guardian::NaldThal => "NaldThal",
|
||||
Guardian::Nophica => "Nophica",
|
||||
Guardian::Nymeia => "Nymeia",
|
||||
Guardian::Oschon => "Oschon",
|
||||
Guardian::Rhalgr => "Rhalgr",
|
||||
Guardian::Thaliak => "Thaliak",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &'static str {
|
||||
match *self {
|
||||
Guardian::Althyk => "Althyk",
|
||||
Guardian::Azeyma => "Azeyma",
|
||||
Guardian::Byregot => "Byregot",
|
||||
Guardian::Halone => "Halone",
|
||||
Guardian::Llymlaen => "Llymlaen",
|
||||
Guardian::Menphina => "Menphina",
|
||||
Guardian::NaldThal => "Nald'thal",
|
||||
Guardian::Nophica => "Nophica",
|
||||
Guardian::Nymeia => "Nymeia",
|
||||
Guardian::Oschon => "Oschon",
|
||||
Guardian::Rhalgr => "Rhalgr",
|
||||
Guardian::Thaliak => "Thaliak",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn epithet(&self) -> &'static str {
|
||||
match *self {
|
||||
Guardian::Althyk => "the Keeper",
|
||||
Guardian::Azeyma => "the Warden",
|
||||
Guardian::Byregot => "the Builder",
|
||||
Guardian::Halone => "the Fury",
|
||||
Guardian::Llymlaen => "the Navigator",
|
||||
Guardian::Menphina => "the Lover",
|
||||
Guardian::NaldThal => "the Traders",
|
||||
Guardian::Nophica => "the Matron",
|
||||
Guardian::Nymeia => "the Spinner",
|
||||
Guardian::Oschon => "the Wanderer",
|
||||
Guardian::Rhalgr => "the Destroyer",
|
||||
Guardian::Thaliak => "the Scholar",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for Guardian {
|
||||
type Err = UnknownVariant;
|
||||
|
||||
/// Parses a string `s` to return a value of this type.
|
||||
///
|
||||
/// This is case-insensitive.
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let guardian = match s.to_lowercase().as_str() {
|
||||
"althyk" => Guardian::Althyk,
|
||||
"azeyma" => Guardian::Azeyma,
|
||||
"byregot" => Guardian::Byregot,
|
||||
"halone" => Guardian::Halone,
|
||||
"llymlaen" => Guardian::Llymlaen,
|
||||
"menphina" => Guardian::Menphina,
|
||||
"naldthal" | "nald'thal" => Guardian::NaldThal,
|
||||
"nophica" => Guardian::Nophica,
|
||||
"nymeia" => Guardian::Nymeia,
|
||||
"oschon" => Guardian::Oschon,
|
||||
"rhalgr" => Guardian::Rhalgr,
|
||||
"thaliak" => Guardian::Thaliak,
|
||||
_ => return Err(UnknownVariant("Guardian", s.into()))
|
||||
};
|
||||
|
||||
Ok(guardian)
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Guardian {
|
||||
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
||||
write!(f, "{}", self.name())
|
||||
}
|
||||
}
|
|
@ -9,6 +9,8 @@ pub mod clans;
|
|||
#[cfg(feature = "data_centers")]
|
||||
pub mod data_centers;
|
||||
pub mod errors;
|
||||
#[cfg(feature = "guardians")]
|
||||
pub mod guardians;
|
||||
pub mod jobs;
|
||||
#[cfg(feature = "races")]
|
||||
pub mod races;
|
||||
|
@ -21,6 +23,8 @@ pub mod worlds;
|
|||
pub use self::clans::Clan;
|
||||
#[cfg(feature = "data_centers")]
|
||||
pub use self::data_centers::DataCenter;
|
||||
#[cfg(feature = "guardians")]
|
||||
pub use self::guardians::Guardian;
|
||||
#[cfg(feature = "combat_jobs")]
|
||||
pub use self::jobs::Job;
|
||||
#[cfg(feature = "non_combat_jobs")]
|
||||
|
|
Loading…
Reference in New Issue