feat: add classes and ClassJob
This commit is contained in:
parent
4b32480cf8
commit
5f7dd956ca
|
@ -93,7 +93,7 @@ impl Job {
|
|||
Job::Paladin => "Paladin",
|
||||
Job::Warrior => "Warrior",
|
||||
|
||||
Job::BlueMage => "Blue Mage",
|
||||
Job::BlueMage => "BlueMage",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,3 +254,107 @@ impl Display for Job {
|
|||
write!(f, "{}", self.name())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "with_serde", derive(Serialize, Deserialize))]
|
||||
pub enum Class {
|
||||
Arcanist,
|
||||
Archer,
|
||||
Lancer,
|
||||
Pugilist,
|
||||
Rogue,
|
||||
Thaumaturge,
|
||||
|
||||
Conjurer,
|
||||
|
||||
Gladiator,
|
||||
Marauder,
|
||||
}
|
||||
|
||||
impl Class {
|
||||
#[cfg(feature = "all_const")]
|
||||
pub const ALL: [Class; 9] = [
|
||||
Self::Arcanist,
|
||||
Self::Archer,
|
||||
Self::Lancer,
|
||||
Self::Pugilist,
|
||||
Self::Rogue,
|
||||
Self::Thaumaturge,
|
||||
Self::Conjurer,
|
||||
Self::Gladiator,
|
||||
Self::Marauder,
|
||||
];
|
||||
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Arcanist => "Arcanist",
|
||||
Self::Archer => "Archer",
|
||||
Self::Lancer => "Lancer",
|
||||
Self::Pugilist => "Pugilist",
|
||||
Self::Rogue => "Rogue",
|
||||
Self::Thaumaturge => "Thaumaturge",
|
||||
|
||||
Self::Conjurer => "Conjurer",
|
||||
|
||||
Self::Gladiator => "Gladiator",
|
||||
Self::Marauder => "Marauder",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &'static str {
|
||||
// all one word
|
||||
self.as_str()
|
||||
}
|
||||
|
||||
// code
|
||||
pub fn code(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Arcanist => "ACN",
|
||||
Self::Archer => "ARC",
|
||||
Self::Lancer => "LNC",
|
||||
Self::Pugilist => "PGL",
|
||||
Self::Rogue => "ROG",
|
||||
Self::Thaumaturge => "THM",
|
||||
|
||||
Self::Conjurer => "CNJ",
|
||||
|
||||
Self::Gladiator => "GLA",
|
||||
Self::Marauder => "MRD",
|
||||
}
|
||||
}
|
||||
|
||||
// role
|
||||
#[cfg(feature = "roles")]
|
||||
pub fn role(&self) -> Role {
|
||||
match self {
|
||||
Self::Arcanist
|
||||
| Self::Archer
|
||||
| Self::Lancer
|
||||
| Self::Pugilist
|
||||
| Self::Rogue
|
||||
| Self::Thaumaturge => Role::Dps,
|
||||
|
||||
Self::Conjurer => Role::Healer,
|
||||
|
||||
Self::Gladiator
|
||||
| Self::Marauder => Role::Tank,
|
||||
}
|
||||
}
|
||||
|
||||
// classification
|
||||
#[cfg(feature = "job_classifications")]
|
||||
pub fn classification(&self) -> Classification {
|
||||
match self {
|
||||
Self::Archer
|
||||
| Self::Lancer
|
||||
| Self::Pugilist
|
||||
| Self::Rogue
|
||||
| Self::Gladiator
|
||||
| Self::Marauder => Classification::War,
|
||||
|
||||
Self::Arcanist
|
||||
| Self::Thaumaturge
|
||||
| Self::Conjurer => Classification::Magic,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,91 @@ pub mod non_combat;
|
|||
#[cfg(feature = "job_classifications")]
|
||||
pub use self::classification::Classification;
|
||||
#[cfg(feature = "combat_jobs")]
|
||||
pub use self::combat::Job;
|
||||
pub use self::combat::{Class, Job};
|
||||
#[cfg(feature = "non_combat_jobs")]
|
||||
pub use self::non_combat::NonCombatJob;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[cfg(any(feature = "combat_jobs", feature = "non_combat_jobs"))]
|
||||
#[cfg_attr(feature = "with_serde", derive(Serialize, Deserialize))]
|
||||
pub enum ClassJob {
|
||||
#[cfg(feature = "combat_jobs")]
|
||||
Class(Class),
|
||||
#[cfg(feature = "combat_jobs")]
|
||||
Job(Job),
|
||||
#[cfg(feature = "non_combat_jobs")]
|
||||
NonCombat(NonCombatJob),
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "combat_jobs", feature = "non_combat_jobs"))]
|
||||
impl ClassJob {
|
||||
#[cfg(feature = "combat_jobs")]
|
||||
pub fn as_job(&self) -> Option<Job> {
|
||||
match self {
|
||||
Self::Job(j) => Some(*j),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "combat_jobs")]
|
||||
pub fn as_class(&self) -> Option<Class> {
|
||||
match self {
|
||||
Self::Class(c) => Some(*c),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
#[cfg(feature = "combat_jobs")]
|
||||
Self::Job(j) => j.as_str(),
|
||||
#[cfg(feature = "combat_jobs")]
|
||||
Self::Class(c) => c.as_str(),
|
||||
#[cfg(feature = "non_combat_jobs")]
|
||||
Self::NonCombat(nc) => nc.as_str(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &'static str {
|
||||
match self {
|
||||
#[cfg(feature = "combat_jobs")]
|
||||
Self::Job(j) => j.name(),
|
||||
#[cfg(feature = "combat_jobs")]
|
||||
Self::Class(c) => c.name(),
|
||||
#[cfg(feature = "non_combat_jobs")]
|
||||
Self::NonCombat(nc) => nc.name(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn code(&self) -> &'static str {
|
||||
match self {
|
||||
#[cfg(feature = "combat_jobs")]
|
||||
Self::Job(j) => j.code(),
|
||||
#[cfg(feature = "combat_jobs")]
|
||||
Self::Class(c) => c.code(),
|
||||
#[cfg(feature = "non_combat_jobs")]
|
||||
Self::NonCombat(nc) => nc.code(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "roles", feature = "combat_jobs"))]
|
||||
pub fn role(&self) -> Option<crate::Role> {
|
||||
match self {
|
||||
Self::Job(j) => Some(j.role()),
|
||||
Self::Class(c) => Some(c.role()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "job_classifications", any(feature = "combat_jobs", feature = "non_combat_jobs")))]
|
||||
pub fn classification(&self) -> Classification {
|
||||
match self {
|
||||
#[cfg(feature = "combat_jobs")]
|
||||
Self::Job(j) => j.classification(),
|
||||
#[cfg(feature = "combat_jobs")]
|
||||
Self::Class(c) => c.classification(),
|
||||
#[cfg(feature = "non_combat_jobs")]
|
||||
Self::NonCombat(nc) => nc.classification(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue