commit 5f1db6a5da61ff87f6eaabc6a43b8fd712a74591 Author: Kyle Clemens Date: Wed Mar 28 20:44:30 2018 -0400 chore: initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a821aa9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ + +/target +**/*.rs.bk +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..2892939 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "ffxiv_types" +version = "0.1.0" +authors = ["Kyle Clemens "] + +[dependencies] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c59bec4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Kyle Clemens + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..c13b737 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# ffxiv_types + +These are useful types when working with FFXIV. + +Up to date as of *patch 4.25*. + +- `DataCenter` +- `World` +- `Role` +- `Job` + +All types implement `Debug`, `Display`, `Clone`, `Copy`, and `FromStr`. + +They also all have a `fn as_str(&self) -> &'static str`. + +They all have a `ALL` const (e.g. `Job::ALL`). + +Individual methods: + +- `Job` + - `fn role(&self) -> Role` +- `World` + - `fn data_center(&self) -> DataCenter` diff --git a/src/data_centers.rs b/src/data_centers.rs new file mode 100644 index 0000000..8a72ee4 --- /dev/null +++ b/src/data_centers.rs @@ -0,0 +1,58 @@ +use std::fmt::{Display, Formatter, Result as FmtResult}; +use std::str::FromStr; + +#[derive(Debug, Clone, Copy)] +pub enum DataCenter { + Aether, + Chaos, + Elemental, + Gaia, + Mana, + Primal, +} + +impl DataCenter { + pub const ALL: [DataCenter; 6] = [ + DataCenter::Aether, + DataCenter::Chaos, + DataCenter::Elemental, + DataCenter::Gaia, + DataCenter::Mana, + DataCenter::Primal, + ]; + + pub fn as_str(&self) -> &'static str { + match *self { + DataCenter::Aether => "Aether", + DataCenter::Chaos => "Chaos", + DataCenter::Elemental => "Elemental", + DataCenter::Gaia => "Gaia", + DataCenter::Mana => "Mana", + DataCenter::Primal => "Primal", + } + } +} + +impl FromStr for DataCenter { + type Err = (); + + fn from_str(s: &str) -> Result { + let data_center = match s.to_lowercase().as_str() { + "aether" => DataCenter::Aether, + "chaos" => DataCenter::Chaos, + "elemental" => DataCenter::Elemental, + "gaia" => DataCenter::Gaia, + "mana" => DataCenter::Mana, + "primal" => DataCenter::Primal, + _ => return Err(()) + }; + + Ok(data_center) + } +} + +impl Display for DataCenter { + fn fmt(&self, f: &mut Formatter) -> FmtResult { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/jobs.rs b/src/jobs.rs new file mode 100644 index 0000000..c316e9d --- /dev/null +++ b/src/jobs.rs @@ -0,0 +1,133 @@ +use roles::Role; + +use std::fmt::{Display, Formatter, Result as FmtResult}; +use std::str::FromStr; + +#[derive(Debug, Clone, Copy)] +pub enum Job { + // DPS + Bard, + BlackMage, + Dragoon, + Machinist, + Monk, + Ninja, + RedMage, + Samurai, + Summoner, + + // Healer + Astrologian, + Scholar, + WhiteMage, + + // Tank + DarkKnight, + Paladin, + Warrior, +} + +impl Job { + pub const ALL: [Job; 15] = [ + // DPS + Job::Bard, + Job::BlackMage, + Job::Dragoon, + Job::Machinist, + Job::Monk, + Job::Ninja, + Job::RedMage, + Job::Samurai, + Job::Summoner, + + // Healer + Job::Astrologian, + Job::Scholar, + Job::WhiteMage, + + // Tank + Job::DarkKnight, + Job::Paladin, + Job::Warrior, + ]; + + pub fn as_str(&self) -> &'static str { + match *self { + Job::Bard => "Bard", + Job::BlackMage => "Black Mage", + Job::Dragoon => "Dragoon", + Job::Machinist => "Machinist", + Job::Monk => "Monk", + Job::Ninja => "Ninja", + Job::RedMage => "Red Mage", + Job::Samurai => "Samurai", + Job::Summoner => "Summoner", + + Job::Astrologian => "Astrologian", + Job::Scholar => "Scholar", + Job::WhiteMage => "White Mage", + + Job::DarkKnight => "Dark Knight", + Job::Paladin => "Paladin", + Job::Warrior => "Warrior", + } + } + + pub fn role(&self) -> Role { + match *self { + Job::Bard | + Job::BlackMage | + Job::Dragoon | + Job::Machinist | + Job::Monk | + Job::Ninja | + Job::RedMage | + Job::Samurai | + Job::Summoner => Role::Dps, + + Job::Astrologian | + Job::Scholar | + Job::WhiteMage => Role::Healer, + + Job::DarkKnight | + Job::Paladin | + Job::Warrior => Role::Tank, + } + } +} + +impl FromStr for Job { + type Err = (); + + fn from_str(s: &str) -> Result { + let job = match s.to_lowercase().as_str() { + "bard" | "brd" => Job::Bard, + "black mage" | "blackmage" | "blm" => Job::BlackMage, + "dragoon" | "drg" => Job::Dragoon, + "machinist" | "mch" => Job::Machinist, + "monk" | "mnk" => Job::Monk, + "ninja" | "nin" => Job::Ninja, + "red mage" | "redmage" | "rdm" => Job::RedMage, + "samurai" | "sam" => Job::Samurai, + "summoner" | "smn" => Job::Summoner, + + "astrologian" | "ast" => Job::Astrologian, + "scholar" | "sch" => Job::Scholar, + "white mage" | "whitemage" | "whm" => Job::WhiteMage, + + "dark knight" | "darkknight" | "drk" => Job::DarkKnight, + "paladin" | "pld" => Job::Paladin, + "warrior" | "war" => Job::Warrior, + + _ => return Err(()) + }; + + Ok(job) + } +} + +impl Display for Job { + fn fmt(&self, f: &mut Formatter) -> FmtResult { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..87e7f14 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,9 @@ +pub mod data_centers; +pub mod jobs; +pub mod roles; +pub mod worlds; + +pub use self::data_centers::DataCenter; +pub use self::jobs::Job; +pub use self::roles::Role; +pub use self::worlds::World; diff --git a/src/roles.rs b/src/roles.rs new file mode 100644 index 0000000..ed135cd --- /dev/null +++ b/src/roles.rs @@ -0,0 +1,42 @@ +use std::fmt::{Display, Formatter, Result as FmtResult}; +use std::str::FromStr; + +#[derive(Debug, Clone, Copy)] +pub enum Role { + Dps, + Healer, + Tank, +} + +impl Role { + pub const ALL: [Role; 3] = [Role::Dps, Role::Healer, Role::Tank]; + + pub fn as_str(&self) -> &'static str { + match *self { + Role::Dps => "DPS", + Role::Healer => "Healer", + Role::Tank => "Tank", + } + } +} + +impl FromStr for Role { + type Err = (); + + fn from_str(s: &str) -> Result { + let role = match s.to_lowercase().as_str() { + "dps" => Role::Dps, + "healer" => Role::Healer, + "tank" => Role::Tank, + _ => return Err(()) + }; + + Ok(role) + } +} + +impl Display for Role { + fn fmt(&self, f: &mut Formatter) -> FmtResult { + write!(f, "{}", self.as_str()) + } +} diff --git a/src/worlds.rs b/src/worlds.rs new file mode 100644 index 0000000..ba23516 --- /dev/null +++ b/src/worlds.rs @@ -0,0 +1,412 @@ +use data_centers::DataCenter; + +use std::fmt::{Display, Formatter, Result as FmtResult}; +use std::str::FromStr; + +/// The worlds, sometimes called servers, in the game. +/// +/// Each [Data Center] has multiple worlds attached to it. +#[derive(Debug, Clone, Copy)] +pub enum World { + // Aether + Adamantoise, + Balmung, + Cactuar, + Coeurl, + Faerie, + Gilgamesh, + Goblin, + Jenova, + Mateus, + Midgardsormr, + Sargatanas, + Siren, + Zalera, + + // Chaos + Cerberus, + Lich, + Louisoix, + Moogle, + Odin, + Omega, + Phoenix, + Ragnarok, + Shiva, + Zodiark, + + // Elemental + Aegis, + Atomos, + Carbuncle, + Garuda, + Gungnir, + Kujata, + Ramuh, + Tonberry, + Typhon, + Unicorn, + + // Gaia + Alexander, + Bahamut, + Durandal, + Fenrir, + Ifrit, + Ridill, + Tiamat, + Ultima, + Valefor, + Yojimbo, + Zeromus, + + // Mana + Anima, + Asura, + Belias, + Chocobo, + Hades, + Ixion, + Mandragora, + Masamune, + Pandaemonium, + Shinryu, + Titan, + + // Primal + Behemoth, + Brynhildr, + Diabolos, + Excalibur, + Exodus, + Famfrit, + Hyperion, + Lamia, + Leviathan, + Malboro, + Ultros, +} + +impl World { + pub const ALL: [World; 66] = [ + // Aether + World::Adamantoise, + World::Balmung, + World::Cactuar, + World::Coeurl, + World::Faerie, + World::Gilgamesh, + World::Goblin, + World::Jenova, + World::Mateus, + World::Midgardsormr, + World::Sargatanas, + World::Siren, + World::Zalera, + + // Chaos + World::Cerberus, + World::Lich, + World::Louisoix, + World::Moogle, + World::Odin, + World::Omega, + World::Phoenix, + World::Ragnarok, + World::Shiva, + World::Zodiark, + + // Elemental + World::Aegis, + World::Atomos, + World::Carbuncle, + World::Garuda, + World::Gungnir, + World::Kujata, + World::Ramuh, + World::Tonberry, + World::Typhon, + World::Unicorn, + + // Gaia + World::Alexander, + World::Bahamut, + World::Durandal, + World::Fenrir, + World::Ifrit, + World::Ridill, + World::Tiamat, + World::Ultima, + World::Valefor, + World::Yojimbo, + World::Zeromus, + + // Mana + World::Anima, + World::Asura, + World::Belias, + World::Chocobo, + World::Hades, + World::Ixion, + World::Mandragora, + World::Masamune, + World::Pandaemonium, + World::Shinryu, + World::Titan, + + // Primal + World::Behemoth, + World::Brynhildr, + World::Diabolos, + World::Excalibur, + World::Exodus, + World::Famfrit, + World::Hyperion, + World::Lamia, + World::Leviathan, + World::Malboro, + World::Ultros, + ]; + + pub fn as_str(&self) -> &'static str { + match *self { + World::Adamantoise => "Adamantoise", + World::Balmung => "Balmung", + World::Cactuar => "Cactuar", + World::Coeurl => "Coeurl", + World::Faerie => "Faerie", + World::Gilgamesh => "Gilgamesh", + World::Goblin => "Goblin", + World::Jenova => "Jenova", + World::Mateus => "Mateus", + World::Midgardsormr => "Midgardsormr", + World::Sargatanas => "Sargatanas", + World::Siren => "Siren", + World::Zalera => "Zalera", + + World::Cerberus => "Cerberus", + World::Lich => "Lich", + World::Louisoix => "Louisoix", + World::Moogle => "Moogle", + World::Odin => "Odin", + World::Omega => "Omega", + World::Phoenix => "Phoenix", + World::Ragnarok => "Ragnarok", + World::Shiva => "Shiva", + World::Zodiark => "Zodiark", + + World::Aegis => "Aegis", + World::Atomos => "Atomos", + World::Carbuncle => "Carbuncle", + World::Garuda => "Garuda", + World::Gungnir => "Gungnir", + World::Kujata => "Kujata", + World::Ramuh => "Ramuh", + World::Tonberry => "Tonberry", + World::Typhon => "Typhon", + World::Unicorn => "Unicorn", + + World::Alexander => "Alexander", + World::Bahamut => "Bahamut", + World::Durandal => "Durandal", + World::Fenrir => "Fenrir", + World::Ifrit => "Ifrit", + World::Ridill => "Ridill", + World::Tiamat => "Tiamat", + World::Ultima => "Ultima", + World::Valefor => "Valefor", + World::Yojimbo => "Yojimbo", + World::Zeromus => "Zeromus", + + World::Anima => "Anima", + World::Asura => "Asura", + World::Belias => "Belias", + World::Chocobo => "Chocobo", + World::Hades => "Hades", + World::Ixion => "Ixion", + World::Mandragora => "Mandragora", + World::Masamune => "Masamune", + World::Pandaemonium => "Pandaemonium", + World::Shinryu => "Shinryu", + World::Titan => "Titan", + + World::Behemoth => "Behemoth", + World::Brynhildr => "Brynhildr", + World::Diabolos => "Diabolos", + World::Excalibur => "Excalibur", + World::Exodus => "Exodus", + World::Famfrit => "Famfrit", + World::Hyperion => "Hyperion", + World::Lamia => "Lamia", + World::Leviathan => "Leviathan", + World::Malboro => "Malboro", + World::Ultros => "Ultros", + } + } + + pub fn data_center(&self) -> DataCenter { + match *self { + World::Adamantoise | + World::Balmung | + World::Cactuar | + World::Coeurl | + World::Faerie | + World::Gilgamesh | + World::Goblin | + World::Jenova | + World::Mateus | + World::Midgardsormr | + World::Sargatanas | + World::Siren | + World::Zalera => DataCenter::Aether, + + World::Cerberus | + World::Lich | + World::Louisoix | + World::Moogle | + World::Odin | + World::Omega | + World::Phoenix | + World::Ragnarok | + World::Shiva | + World::Zodiark => DataCenter::Chaos, + + World::Aegis | + World::Atomos | + World::Carbuncle | + World::Garuda | + World::Gungnir | + World::Kujata | + World::Ramuh | + World::Tonberry | + World::Typhon | + World::Unicorn => DataCenter::Elemental, + + World::Alexander | + World::Bahamut | + World::Durandal | + World::Fenrir | + World::Ifrit | + World::Ridill | + World::Tiamat | + World::Ultima | + World::Valefor | + World::Yojimbo | + World::Zeromus => DataCenter::Gaia, + + World::Anima | + World::Asura | + World::Belias | + World::Chocobo | + World::Hades | + World::Ixion | + World::Mandragora | + World::Masamune | + World::Pandaemonium | + World::Shinryu | + World::Titan => DataCenter::Mana, + + World::Behemoth | + World::Brynhildr | + World::Diabolos | + World::Excalibur | + World::Exodus | + World::Famfrit | + World::Hyperion | + World::Lamia | + World::Leviathan | + World::Malboro | + World::Ultros => DataCenter::Primal, + } + } +} + +impl FromStr for World { + type Err = (); + + fn from_str(s: &str) -> Result { + let world = match s.to_lowercase().as_str() { + "adamantoise" => World::Adamantoise, + "balmung" => World::Balmung, + "cactuar" => World::Cactuar, + "coeurl" => World::Coeurl, + "faerie" => World::Faerie, + "gilgamesh" => World::Gilgamesh, + "goblin" => World::Goblin, + "jenova" => World::Jenova, + "mateus" => World::Mateus, + "midgardsormr" => World::Midgardsormr, + "sargatanas" => World::Sargatanas, + "siren" => World::Siren, + "zalera" => World::Zalera, + + "cerberus" => World::Cerberus, + "lich" => World::Lich, + "louisoix" => World::Louisoix, + "moogle" => World::Moogle, + "odin" => World::Odin, + "omega" => World::Omega, + "phoenix" => World::Phoenix, + "ragnarok" => World::Ragnarok, + "shiva" => World::Shiva, + "zodiark" => World::Zodiark, + + "aegis" => World::Aegis, + "atomos" => World::Atomos, + "carbuncle" => World::Carbuncle, + "garuda" => World::Garuda, + "gungnir" => World::Gungnir, + "kujata" => World::Kujata, + "ramuh" => World::Ramuh, + "tonberry" => World::Tonberry, + "typhon" => World::Typhon, + "unicorn" => World::Unicorn, + + "alexander" => World::Alexander, + "bahamut" => World::Bahamut, + "durandal" => World::Durandal, + "fenrir" => World::Fenrir, + "ifrit" => World::Ifrit, + "ridill" => World::Ridill, + "tiamat" => World::Tiamat, + "ultima" => World::Ultima, + "valefor" => World::Valefor, + "yojimbo" => World::Yojimbo, + "zeromus" => World::Zeromus, + + "anima" => World::Anima, + "asura" => World::Asura, + "belias" => World::Belias, + "chocobo" => World::Chocobo, + "hades" => World::Hades, + "ixion" => World::Ixion, + "mandragora" => World::Mandragora, + "masamune" => World::Masamune, + "pandaemonium" => World::Pandaemonium, + "shinryu" => World::Shinryu, + "titan" => World::Titan, + + "behemoth" => World::Behemoth, + "brynhildr" => World::Brynhildr, + "diabolos" => World::Diabolos, + "excalibur" => World::Excalibur, + "exodus" => World::Exodus, + "famfrit" => World::Famfrit, + "hyperion" => World::Hyperion, + "lamia" => World::Lamia, + "leviathan" => World::Leviathan, + "malboro" => World::Malboro, + "ultros" => World::Ultros, + + _ => return Err(()) + }; + + Ok(world) + } +} + +impl Display for World { + fn fmt(&self, f: &mut Formatter) -> FmtResult { + write!(f, "{}", self.as_str()) + } +}