commit be6b2e6544df022acffbfa25c9f962b1691d2939 Author: Filipe Rodrigues Date: Wed Aug 18 12:42:50 2021 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a1193e2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Target +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..fa69a9f --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,492 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28ae2b3dec75a406790005a200b1bd89785afc02517a00ca99ecfe093ee9e6cf" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "ascii" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbf56136a5198c7b01a49e3afcbef6cf84597273d298f54432926024107b0109" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +dependencies = [ + "libc", + "num-integer", + "num-traits", + "time", + "winapi", +] + +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "derive_more" +version = "0.99.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40eebddd2156ce1bb37b20bbe5151340a31828b1f2d22ba4141f3531710e38df" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "int-conv" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0249b28817672371aa3a25e0420548646663592c0442d71ac67c9cb4fe1f94c" +dependencies = [ + "static_assertions", +] + +[[package]] +name = "itoa" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" + +[[package]] +name = "libc" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765" + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + +[[package]] +name = "poke" +version = "0.1.0" +dependencies = [ + "log", + "serde", + "serde_json", + "zutil", +] + +[[package]] +name = "poke-base-stats" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "log", + "poke", + "serde", + "serde_json", + "simplelog", + "zutil", +] + +[[package]] +name = "proc-macro2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ref-cast" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300f2a835d808734ee295d45007adacb9ebb29dd3ae2424acfa17930cae541da" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c38e3aecd2b21cb3959637b883bb3714bc7e43f0268b9a29d3743ee3e55cdd2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "sealed" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "636b9882a0f4cc2039488df89a10eb4b7976d4b6c1917fc0518f3f0f5e2c72ca" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.127" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f03b9878abf6d14e6779d3f24f07b2cfa90352cfec4acc5aab8f1ac7f146fae8" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.127" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a024926d3432516606328597e0f224a51355a493b49fdd67e9209187cbe55ecc" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "336b10da19a12ad094b59d870ebde26a45402e5b470add4b5fd03c5048a32127" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "simplelog" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59d0fe306a0ced1c88a58042dc22fc2ddd000982c26d75f6aa09a394547c41e0" +dependencies = [ + "chrono", + "log", + "termcolor", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "syn" +version = "1.0.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1873d832550d4588c3dbc20f01361ab00bfe741048f71e3fecf145a7cc18b29c" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "termcolor" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +dependencies = [ + "libc", + "wasi", + "winapi", +] + +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + +[[package]] +name = "unicode-segmentation" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" + +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "zutil" +version = "0.1.0" +source = "git+https://github.com/Zenithsiz/zutil?rev=2a029369ac5aa4e7dbd6f6afb78ae419ee18666f#2a029369ac5aa4e7dbd6f6afb78ae419ee18666f" +dependencies = [ + "arrayref", + "ascii", + "derive_more", + "either", + "int-conv", + "log", + "ref-cast", + "sealed", + "thiserror", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..9c813ae --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[workspace] + +members = [ + "poke", + "poke-base-stats", +] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1d9755e --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +CARGO := cargo + +OBJS := $(wildcard src/*.rs) + +.PHONY: all clean + +all: target/release/poke-parser + +target/release/poke-parser: $(OBJS) + @$(CARGO) build --release + +clean: + $(RM) target diff --git a/poke-base-stats/Cargo.toml b/poke-base-stats/Cargo.toml new file mode 100644 index 0000000..a51c404 --- /dev/null +++ b/poke-base-stats/Cargo.toml @@ -0,0 +1,26 @@ +[package] +edition = "2018" +name = "poke-base-stats" +version = "0.1.0" + +[dependencies] + +# Poke +poke = {path = "../poke"} + +# Logging +log = "0.4.14" +simplelog = "0.10.0" + +# Error handling +anyhow = "1.0.43" + +# Cmd +clap = "2.33.3" + +# Serde +serde = {version = "1.0.127", features = ["derive"]} +serde_json = "1.0.66" + +# Util +zutil = {git = "https://github.com/Zenithsiz/zutil", rev = "2a029369ac5aa4e7dbd6f6afb78ae419ee18666f"} diff --git a/poke-base-stats/src/args.rs b/poke-base-stats/src/args.rs new file mode 100644 index 0000000..4b84262 --- /dev/null +++ b/poke-base-stats/src/args.rs @@ -0,0 +1,49 @@ +//! Cmd arguments + +// Imports +use std::path::PathBuf; + +/// Arguments +#[derive(Clone, Debug)] +pub enum Args { + /// Serialize to C + SerializeC { + /// Input file + input_file: PathBuf, + }, +} + +/// Parses arguments +pub fn parse() -> Result { + const SERIALIZE_C_SUBCMD: &str = "serialize-c"; + const INPUT_FILE_STR: &str = "input-file"; + + // Serialize to C subcommand + let serialize_c_subcmd = clap::SubCommand::with_name(SERIALIZE_C_SUBCMD) + .help("Serialize the json base stats to C") + .arg( + clap::Arg::with_name(INPUT_FILE_STR) + .takes_value(true) + .required(true) + .index(1), + ); + + let matches = clap::App::new("poke-base-stats") + .subcommands([serialize_c_subcmd]) + .get_matches(); + + let args = match matches.subcommand() { + (SERIALIZE_C_SUBCMD, Some(matches)) => { + let input_file = matches + .value_of_os(INPUT_FILE_STR) + .map(PathBuf::from) + .expect("Required argument missing"); + + Args::SerializeC { input_file } + }, + + (subcmd, _) => anyhow::bail!("Unknown subcommand {}", subcmd), + }; + + Ok(args) +} diff --git a/poke-base-stats/src/main.rs b/poke-base-stats/src/main.rs new file mode 100644 index 0000000..a9dfaff --- /dev/null +++ b/poke-base-stats/src/main.rs @@ -0,0 +1,131 @@ +//! Pokemon + +// Features +#![feature(format_args_capture, array_methods)] + +// Modules +mod args; + +// Imports +use anyhow::Context; +use poke::{Ability, BaseStats, EggGroup, Gender, Item, Species}; +use std::{collections::BTreeMap, fs, path::Path}; + +fn main() -> Result<(), anyhow::Error> { + // Initialize logger + simplelog::TermLogger::init( + log::LevelFilter::Debug, + simplelog::Config::default(), + simplelog::TerminalMode::Stderr, + simplelog::ColorChoice::Auto, + ) + .context("Unable to initialize logger")?; + + // Get arguments + let args = args::parse().context("Unable to parse arguments")?; + + match args { + args::Args::SerializeC { input_file } => { + self::serialize_c(&input_file) + .with_context(|| format!("Unable to serialize file {input_file:?} to `C`"))?; + }, + } + + Ok(()) +} + +/// Serialize a json to `C` and prints it +pub fn serialize_c(input_file: &Path) -> Result<(), anyhow::Error> { + // Open the file + let file = fs::File::open(&input_file).context("Unable to open file")?; + + // Then parse it + let base_stats = + serde_json::from_reader::<_, BTreeMap>(file).context("Unable to parse file")?; + + // Then emmit a `C` array element for each species + for (species, base_stats) in base_stats { + let species = species.c_name(); + + let base_hp = base_stats.stats.hp; + let base_atk = base_stats.stats.atk; + let base_def = base_stats.stats.def; + let base_speed = base_stats.stats.speed; + let base_sp_atk = base_stats.stats.sp_atk; + let base_sp_def = base_stats.stats.sp_def; + + let [type1, type2] = base_stats.types.map(|ty| ty.c_name()); + + let catch_rate = base_stats.catch_rate; + let exp_yield = base_stats.exp_yield; + + let ev_yield_hp = base_stats.ev_yield.hp; + let ev_yield_atk = base_stats.ev_yield.atk; + let ev_yield_def = base_stats.ev_yield.def; + let ev_yield_speed = base_stats.ev_yield.speed; + let ev_yield_sp_atk = base_stats.ev_yield.sp_atk; + let ev_yield_sp_def = base_stats.ev_yield.sp_def; + + let [item1, item2] = base_stats.items.map(|item| item.as_ref().map_or("NONE", Item::c_name)); + + let gender_ratio = zutil::DisplayWrapper::new(|f| match base_stats.gender { + Gender::PercentFemale { p } => write!(f, "PERCENT_FEMALE({p})"), + Gender::AlwaysMale => write!(f, "MON_MALE"), + Gender::AlwaysFemale => write!(f, "MON_FEMALE"), + Gender::Genderless => write!(f, "MON_GENDERLESS"), + }); + + let egg_cycles = base_stats.egg_cycles; + let friendship = base_stats.friendship; + + let growth_rate = base_stats.growth_rate.c_name(); + + let [egg_group1, egg_group2] = base_stats.egg_groups.each_ref().map(EggGroup::c_name); + + let [ability1, ability2] = base_stats + .abilities + .map(|ability| ability.as_ref().map_or("NONE", Ability::c_name)); + + let safari_zone_flee_rate = base_stats.safari_zone_flee_rate; + let body_color = base_stats.body_color.c_name(); + let no_flip = match base_stats.no_flip { + true => "TRUE", + false => "FALSE", + }; + + println!( + r#"[SPECIES_{species}] = {{ + .baseHP = {base_hp}, + .baseAttack = {base_atk}, + .baseDefense = {base_def}, + .baseSpeed = {base_speed}, + .baseSpAttack = {base_sp_atk}, + .baseSpDefense = {base_sp_def}, + .type1 = TYPE_{type1}, + .type2 = TYPE_{type2}, + .catchRate = {catch_rate}, + .expYield = {exp_yield}, + .evYield_HP = {ev_yield_hp}, + .evYield_Attack = {ev_yield_atk}, + .evYield_Defense = {ev_yield_def}, + .evYield_Speed = {ev_yield_speed}, + .evYield_SpAttack = {ev_yield_sp_atk}, + .evYield_SpDefense = {ev_yield_sp_def}, + .item1 = ITEM_{item1}, + .item2 = ITEM_{item2}, + .genderRatio = {gender_ratio}, + .eggCycles = {egg_cycles}, + .friendship = {friendship}, + .growthRate = GROWTH_{growth_rate}, + .eggGroup1 = EGG_GROUP_{egg_group1}, + .eggGroup2 = EGG_GROUP_{egg_group2}, + .abilities = {{ABILITY_{ability1}, ABILITY_{ability2}}}, + .safariZoneFleeRate = {safari_zone_flee_rate}, + .bodyColor = BODY_COLOR_{body_color}, + .noFlip = {no_flip}, +}},"#, + ); + } + + Ok(()) +} diff --git a/poke/Cargo.toml b/poke/Cargo.toml new file mode 100644 index 0000000..42d8e4f --- /dev/null +++ b/poke/Cargo.toml @@ -0,0 +1,18 @@ +[package] +edition = "2018" +name = "poke" +version = "0.1.0" + +[dependencies] + +# Logging +log = "0.4.14" + +# Error handling + +# Serde +serde = {version = "1.0.127", features = ["derive"]} +serde_json = "1.0.66" + +# Util +zutil = {git = "https://github.com/Zenithsiz/zutil", rev = "2a029369ac5aa4e7dbd6f6afb78ae419ee18666f"} diff --git a/poke/src/ability.rs b/poke/src/ability.rs new file mode 100644 index 0000000..688070f --- /dev/null +++ b/poke/src/ability.rs @@ -0,0 +1,170 @@ +//! Ability + + +/// Pokemon ability +#[derive(PartialEq, Eq, Clone, Copy, Hash, Debug)] +#[derive(serde::Serialize, serde::Deserialize)] +pub enum Ability { + Stench = 1, + Drizzle = 2, + SpeedBoost = 3, + BattleArmor = 4, + Sturdy = 5, + Damp = 6, + Limber = 7, + SandVeil = 8, + Static = 9, + VoltAbsorb = 10, + WaterAbsorb = 11, + Oblivious = 12, + CloudNine = 13, + CompoundEyes = 14, + Insomnia = 15, + ColorChange = 16, + Immunity = 17, + FlashFire = 18, + ShieldDust = 19, + OwnTempo = 20, + SuctionCups = 21, + Intimidate = 22, + ShadowTag = 23, + RoughSkin = 24, + WonderGuard = 25, + Levitate = 26, + EffectSpore = 27, + Synchronize = 28, + ClearBody = 29, + NaturalCure = 30, + LightningRod = 31, + SereneGrace = 32, + SwiftSwim = 33, + Chlorophyll = 34, + Illuminate = 35, + Trace = 36, + HugePower = 37, + PoisonPoint = 38, + InnerFocus = 39, + MagmaArmor = 40, + WaterVeil = 41, + MagnetPull = 42, + Soundproof = 43, + RainDish = 44, + SandStream = 45, + Pressure = 46, + ThickFat = 47, + EarlyBird = 48, + FlameBody = 49, + RunAway = 50, + KeenEye = 51, + HyperCutter = 52, + Pickup = 53, + Truant = 54, + Hustle = 55, + CuteCharm = 56, + Plus = 57, + Minus = 58, + Forecast = 59, + StickyHold = 60, + ShedSkin = 61, + Guts = 62, + MarvelScale = 63, + LiquidOoze = 64, + Overgrow = 65, + Blaze = 66, + Torrent = 67, + Swarm = 68, + RockHead = 69, + Drought = 70, + ArenaTrap = 71, + VitalSpirit = 72, + WhiteSmoke = 73, + PurePower = 74, + ShellArmor = 75, + Cacophony = 76, + AirLock = 77, +} + +impl Ability { + /// Returns the `C` name of this ability + pub fn c_name(&self) -> &'static str { + match self { + Ability::Stench => "STENCH", + Ability::Drizzle => "DRIZZLE", + Ability::SpeedBoost => "SPEED_BOOST", + Ability::BattleArmor => "BATTLE_ARMOR", + Ability::Sturdy => "STURDY", + Ability::Damp => "DAMP", + Ability::Limber => "LIMBER", + Ability::SandVeil => "SAND_VEIL", + Ability::Static => "STATIC", + Ability::VoltAbsorb => "VOLT_ABSORB", + Ability::WaterAbsorb => "WATER_ABSORB", + Ability::Oblivious => "OBLIVIOUS", + Ability::CloudNine => "CLOUD_NINE", + Ability::CompoundEyes => "COMPOUND_EYES", + Ability::Insomnia => "INSOMNIA", + Ability::ColorChange => "COLOR_CHANGE", + Ability::Immunity => "IMMUNITY", + Ability::FlashFire => "FLASH_FIRE", + Ability::ShieldDust => "SHIELD_DUST", + Ability::OwnTempo => "OWN_TEMPO", + Ability::SuctionCups => "SUCTION_CUPS", + Ability::Intimidate => "INTIMIDATE", + Ability::ShadowTag => "SHADOW_TAG", + Ability::RoughSkin => "ROUGH_SKIN", + Ability::WonderGuard => "WONDER_GUARD", + Ability::Levitate => "LEVITATE", + Ability::EffectSpore => "EFFECT_SPORE", + Ability::Synchronize => "SYNCHRONIZE", + Ability::ClearBody => "CLEAR_BODY", + Ability::NaturalCure => "NATURAL_CURE", + Ability::LightningRod => "LIGHTNING_ROD", + Ability::SereneGrace => "SERENE_GRACE", + Ability::SwiftSwim => "SWIFT_SWIM", + Ability::Chlorophyll => "CHLOROPHYLL", + Ability::Illuminate => "ILLUMINATE", + Ability::Trace => "TRACE", + Ability::HugePower => "HUGE_POWER", + Ability::PoisonPoint => "POISON_POINT", + Ability::InnerFocus => "INNER_FOCUS", + Ability::MagmaArmor => "MAGMA_ARMOR", + Ability::WaterVeil => "WATER_VEIL", + Ability::MagnetPull => "MAGNET_PULL", + Ability::Soundproof => "SOUNDPROOF", + Ability::RainDish => "RAIN_DISH", + Ability::SandStream => "SAND_STREAM", + Ability::Pressure => "PRESSURE", + Ability::ThickFat => "THICK_FAT", + Ability::EarlyBird => "EARLY_BIRD", + Ability::FlameBody => "FLAME_BODY", + Ability::RunAway => "RUN_AWAY", + Ability::KeenEye => "KEEN_EYE", + Ability::HyperCutter => "HYPER_CUTTER", + Ability::Pickup => "PICKUP", + Ability::Truant => "TRUANT", + Ability::Hustle => "HUSTLE", + Ability::CuteCharm => "CUTE_CHARM", + Ability::Plus => "PLUS", + Ability::Minus => "MINUS", + Ability::Forecast => "FORECAST", + Ability::StickyHold => "STICKY_HOLD", + Ability::ShedSkin => "SHED_SKIN", + Ability::Guts => "GUTS", + Ability::MarvelScale => "MARVEL_SCALE", + Ability::LiquidOoze => "LIQUID_OOZE", + Ability::Overgrow => "OVERGROW", + Ability::Blaze => "BLAZE", + Ability::Torrent => "TORRENT", + Ability::Swarm => "SWARM", + Ability::RockHead => "ROCK_HEAD", + Ability::Drought => "DROUGHT", + Ability::ArenaTrap => "ARENA_TRAP", + Ability::VitalSpirit => "VITAL_SPIRIT", + Ability::WhiteSmoke => "WHITE_SMOKE", + Ability::PurePower => "PURE_POWER", + Ability::ShellArmor => "SHELL_ARMOR", + Ability::Cacophony => "CACOPHONY", + Ability::AirLock => "AIR_LOCK", + } + } +} diff --git a/poke/src/base_stats.rs b/poke/src/base_stats.rs new file mode 100644 index 0000000..767ebf5 --- /dev/null +++ b/poke/src/base_stats.rs @@ -0,0 +1,88 @@ +//! Base stats + +// IMports +use crate::{Ability, BodyColor, EggGroup, GrowthRate, Item, Type}; + +/// Stats +#[derive(PartialEq, Clone, Copy, Debug)] +#[derive(serde::Serialize, serde::Deserialize)] +pub struct Stats { + /// Hp + pub hp: u8, + + /// Attack + pub atk: u8, + + /// Defense + pub def: u8, + + /// Speed + pub speed: u8, + + /// Special attack + pub sp_atk: u8, + + /// Special defense + pub sp_def: u8, +} + +/// Base stats +#[derive(PartialEq, Clone, Copy, Debug)] +#[derive(serde::Serialize, serde::Deserialize)] +pub struct BaseStats { + // Base stats + pub stats: Stats, + + /// Types + pub types: [Type; 2], + + /// Catch rate + pub catch_rate: u8, + + /// Exp yield + pub exp_yield: u8, + + // Ev yield + pub ev_yield: Stats, + + /// Items + pub items: [Option; 2], + + /// Gender + pub gender: Gender, + + /// Egg cycles + pub egg_cycles: u8, + + /// Friendship + pub friendship: u8, + + /// Growth Rate + pub growth_rate: GrowthRate, + + /// Egg groups + pub egg_groups: [EggGroup; 2], + + /// Abilities + pub abilities: [Option; 2], + + /// Safari zone flee rate + pub safari_zone_flee_rate: u8, + + /// Body color + pub body_color: BodyColor, + + /// No flip + pub no_flip: bool, +} + +/// Pokemon gender +#[derive(PartialEq, Clone, Copy, Debug)] +#[derive(serde::Serialize, serde::Deserialize)] +#[serde(tag = "type")] +pub enum Gender { + PercentFemale { p: f32 }, + AlwaysMale, + AlwaysFemale, + Genderless, +} diff --git a/poke/src/body_color.rs b/poke/src/body_color.rs new file mode 100644 index 0000000..0e1a6dd --- /dev/null +++ b/poke/src/body_color.rs @@ -0,0 +1,35 @@ +//! Body color + +/// Pokemon body color +#[derive(PartialEq, Eq, Clone, Copy, Hash, Debug)] +#[derive(serde::Serialize, serde::Deserialize)] +pub enum BodyColor { + Red = 0, + Blue = 1, + Yellow = 2, + Green = 3, + Black = 4, + Brown = 5, + Purple = 6, + Gray = 7, + White = 8, + Pink = 9, +} + +impl BodyColor { + /// Returns the `C` name of this body color + pub fn c_name(&self) -> &'static str { + match self { + BodyColor::Red => "RED", + BodyColor::Blue => "BLUE", + BodyColor::Yellow => "YELLOW", + BodyColor::Green => "GREEN", + BodyColor::Black => "BLACK", + BodyColor::Brown => "BROWN", + BodyColor::Purple => "PURPLE", + BodyColor::Gray => "GRAY", + BodyColor::White => "WHITE", + BodyColor::Pink => "PINK", + } + } +} diff --git a/poke/src/egg_group.rs b/poke/src/egg_group.rs new file mode 100644 index 0000000..08354f1 --- /dev/null +++ b/poke/src/egg_group.rs @@ -0,0 +1,46 @@ +//! Egg group + + +/// Pokemon egg group +#[derive(PartialEq, Eq, Clone, Copy, Hash, Debug)] +#[derive(serde::Serialize, serde::Deserialize)] +pub enum EggGroup { + Monster = 1, + Water1 = 2, + Bug = 3, + Flying = 4, + Field = 5, + Fairy = 6, + Grass = 7, + HumanLike = 8, + Water3 = 9, + Mineral = 10, + Amorphous = 11, + Water2 = 12, + Ditto = 13, + Dragon = 14, + Undiscovered = 15, +} + +impl EggGroup { + /// Returns the `C` name of this item + pub fn c_name(&self) -> &'static str { + match self { + EggGroup::Monster => "MONSTER", + EggGroup::Water1 => "WATER_1", + EggGroup::Bug => "BUG", + EggGroup::Flying => "FLYING", + EggGroup::Field => "FIELD", + EggGroup::Fairy => "FAIRY", + EggGroup::Grass => "GRASS", + EggGroup::HumanLike => "HUMAN_LIKE", + EggGroup::Water3 => "WATER_3", + EggGroup::Mineral => "MINERAL", + EggGroup::Amorphous => "AMORPHOUS", + EggGroup::Water2 => "WATER_2", + EggGroup::Ditto => "DITTO", + EggGroup::Dragon => "DRAGON", + EggGroup::Undiscovered => "UNDISCOVERED", + } + } +} diff --git a/poke/src/growth_rate.rs b/poke/src/growth_rate.rs new file mode 100644 index 0000000..cac13e9 --- /dev/null +++ b/poke/src/growth_rate.rs @@ -0,0 +1,27 @@ +//! Growth rate + +/// Pokemon growth rate +#[derive(PartialEq, Eq, Clone, Copy, Hash, Debug)] +#[derive(serde::Serialize, serde::Deserialize)] +pub enum GrowthRate { + MediumFast = 0, + Erratic = 1, + Fluctuating = 2, + MediumSlow = 3, + Fast = 4, + Slow = 5, +} + +impl GrowthRate { + /// Returns the `C` name of this growth rate + pub fn c_name(&self) -> &'static str { + match self { + GrowthRate::MediumFast => "MEDIUM_FAST", + GrowthRate::Erratic => "ERRATIC", + GrowthRate::Fluctuating => "FLUCTUATING", + GrowthRate::MediumSlow => "MEDIUM_SLOW", + GrowthRate::Fast => "FAST", + GrowthRate::Slow => "SLOW", + } + } +} diff --git a/poke/src/item.rs b/poke/src/item.rs new file mode 100644 index 0000000..7299cc8 --- /dev/null +++ b/poke/src/item.rs @@ -0,0 +1,767 @@ +//! Items + + +/// Item +#[derive(PartialEq, Eq, Clone, Copy, Hash, Debug)] +#[derive(serde::Serialize, serde::Deserialize)] +#[allow(clippy::enum_variant_names)] // Some items are number only, so we need to prepend `Item` to them +pub enum Item { + MasterBall = 1, + UltraBall = 2, + GreatBall = 3, + PokeBall = 4, + SafariBall = 5, + NetBall = 6, + DiveBall = 7, + NestBall = 8, + RepeatBall = 9, + TimerBall = 10, + LuxuryBall = 11, + PremierBall = 12, + Potion = 13, + Antidote = 14, + BurnHeal = 15, + IceHeal = 16, + Awakening = 17, + ParalyzeHeal = 18, + FullRestore = 19, + MaxPotion = 20, + HyperPotion = 21, + SuperPotion = 22, + FullHeal = 23, + Revive = 24, + MaxRevive = 25, + FreshWater = 26, + SodaPop = 27, + Lemonade = 28, + MoomooMilk = 29, + EnergyPowder = 30, + EnergyRoot = 31, + HealPowder = 32, + RevivalHerb = 33, + Ether = 34, + MaxEther = 35, + Elixir = 36, + MaxElixir = 37, + LavaCookie = 38, + BlueFlute = 39, + YellowFlute = 40, + RedFlute = 41, + BlackFlute = 42, + WhiteFlute = 43, + BerryJuice = 44, + SacredAsh = 45, + ShoalSalt = 46, + ShoalShell = 47, + RedShard = 48, + BlueShard = 49, + YellowShard = 50, + GreenShard = 51, + Item034 = 52, + Item035 = 53, + Item036 = 54, + Item037 = 55, + Item038 = 56, + Item039 = 57, + Item03A = 58, + Item03B = 59, + Item03C = 60, + Item03D = 61, + Item03E = 62, + HpUp = 63, + Protein = 64, + Iron = 65, + Carbos = 66, + Calcium = 67, + RareCandy = 68, + PpUp = 69, + Zinc = 70, + PpMax = 71, + Item048 = 72, + GuardSpec = 73, + DireHit = 74, + XAttack = 75, + XDefend = 76, + XSpeed = 77, + XAccuracy = 78, + XSpecial = 79, + PokeDoll = 80, + FluffyTail = 81, + Item052 = 82, + SuperRepel = 83, + MaxRepel = 84, + EscapeRope = 85, + Repel = 86, + Item057 = 87, + Item058 = 88, + Item059 = 89, + Item05A = 90, + Item05B = 91, + Item05C = 92, + SunStone = 93, + MoonStone = 94, + FireStone = 95, + ThunderStone = 96, + WaterStone = 97, + LeafStone = 98, + Item063 = 99, + Item064 = 100, + Item065 = 101, + Item066 = 102, + TinyMushroom = 103, + BigMushroom = 104, + Item069 = 105, + Pearl = 106, + BigPearl = 107, + Stardust = 108, + StarPiece = 109, + Nugget = 110, + HeartScale = 111, + Item070 = 112, + Item071 = 113, + Item072 = 114, + Item073 = 115, + Item074 = 116, + Item075 = 117, + Item076 = 118, + Item077 = 119, + Item078 = 120, + OrangeMail = 121, + HarborMail = 122, + GlitterMail = 123, + MechMail = 124, + WoodMail = 125, + WaveMail = 126, + BeadMail = 127, + ShadowMail = 128, + TropicMail = 129, + DreamMail = 130, + FabMail = 131, + RetroMail = 132, + CheriBerry = 133, + ChestoBerry = 134, + PechaBerry = 135, + RawstBerry = 136, + AspearBerry = 137, + LeppaBerry = 138, + OranBerry = 139, + PersimBerry = 140, + LumBerry = 141, + SitrusBerry = 142, + FigyBerry = 143, + WikiBerry = 144, + MagoBerry = 145, + AguavBerry = 146, + IapapaBerry = 147, + RazzBerry = 148, + BlukBerry = 149, + NanabBerry = 150, + WepearBerry = 151, + PinapBerry = 152, + PomegBerry = 153, + KelpsyBerry = 154, + QualotBerry = 155, + HondewBerry = 156, + GrepaBerry = 157, + TamatoBerry = 158, + CornnBerry = 159, + MagostBerry = 160, + RabutaBerry = 161, + NomelBerry = 162, + SpelonBerry = 163, + PamtreBerry = 164, + WatmelBerry = 165, + DurinBerry = 166, + BelueBerry = 167, + LiechiBerry = 168, + GanlonBerry = 169, + SalacBerry = 170, + PetayaBerry = 171, + ApicotBerry = 172, + LansatBerry = 173, + StarfBerry = 174, + EnigmaBerry = 175, + Item0B0 = 176, + Item0B1 = 177, + Item0B2 = 178, + BrightPowder = 179, + WhiteHerb = 180, + MachoBrace = 181, + ExpShare = 182, + QuickClaw = 183, + SootheBell = 184, + MentalHerb = 185, + ChoiceBand = 186, + KingsRock = 187, + SilverPowder = 188, + AmuletCoin = 189, + CleanseTag = 190, + SoulDew = 191, + DeepSeaTooth = 192, + DeepSeaScale = 193, + SmokeBall = 194, + Everstone = 195, + FocusBand = 196, + LuckyEgg = 197, + ScopeLens = 198, + MetalCoat = 199, + Leftovers = 200, + DragonScale = 201, + LightBall = 202, + SoftSand = 203, + HardStone = 204, + MiracleSeed = 205, + BlackGlasses = 206, + BlackBelt = 207, + Magnet = 208, + MysticWater = 209, + SharpBeak = 210, + PoisonBarb = 211, + NeverMeltIce = 212, + SpellTag = 213, + TwistedSpoon = 214, + Charcoal = 215, + DragonFang = 216, + SilkScarf = 217, + UpGrade = 218, + ShellBell = 219, + SeaIncense = 220, + LaxIncense = 221, + LuckyPunch = 222, + MetalPowder = 223, + ThickClub = 224, + Stick = 225, + Item0E2 = 226, + Item0E3 = 227, + Item0E4 = 228, + Item0E5 = 229, + Item0E6 = 230, + Item0E7 = 231, + Item0E8 = 232, + Item0E9 = 233, + Item0Ea = 234, + Item0Eb = 235, + Item0Ec = 236, + Item0Ed = 237, + Item0Ee = 238, + Item0Ef = 239, + Item0F0 = 240, + Item0F1 = 241, + Item0F2 = 242, + Item0F3 = 243, + Item0F4 = 244, + Item0F5 = 245, + Item0F6 = 246, + Item0F7 = 247, + Item0F8 = 248, + Item0F9 = 249, + Item0Fa = 250, + Item0Fb = 251, + Item0Fc = 252, + Item0Fd = 253, + RedScarf = 254, + BlueScarf = 255, + PinkScarf = 256, + GreenScarf = 257, + YellowScarf = 258, + MachBike = 259, + CoinCase = 260, + Itemfinder = 261, + OldRod = 262, + GoodRod = 263, + SuperRod = 264, + SsTicket = 265, + ContestPass = 266, + Item10B = 267, + WailmerPail = 268, + DevonGoods = 269, + SootSack = 270, + BasementKey = 271, + AcroBike = 272, + PokeblockCase = 273, + Letter = 274, + EonTicket = 275, + RedOrb = 276, + BlueOrb = 277, + Scanner = 278, + GoGoggles = 279, + Meteorite = 280, + Room1Key = 281, + Room2Key = 282, + Room4Key = 283, + Room6Key = 284, + StorageKey = 285, + RootFossil = 286, + ClawFossil = 287, + DevonScope = 288, + Tm01 = 289, + Tm02 = 290, + Tm03 = 291, + Tm04 = 292, + Tm05 = 293, + Tm06 = 294, + Tm07 = 295, + Tm08 = 296, + Tm09 = 297, + Tm10 = 298, + Tm11 = 299, + Tm12 = 300, + Tm13 = 301, + Tm14 = 302, + Tm15 = 303, + Tm16 = 304, + Tm17 = 305, + Tm18 = 306, + Tm19 = 307, + Tm20 = 308, + Tm21 = 309, + Tm22 = 310, + Tm23 = 311, + Tm24 = 312, + Tm25 = 313, + Tm26 = 314, + Tm27 = 315, + Tm28 = 316, + Tm29 = 317, + Tm30 = 318, + Tm31 = 319, + Tm32 = 320, + Tm33 = 321, + Tm34 = 322, + Tm35 = 323, + Tm36 = 324, + Tm37 = 325, + Tm38 = 326, + Tm39 = 327, + Tm40 = 328, + Tm41 = 329, + Tm42 = 330, + Tm43 = 331, + Tm44 = 332, + Tm45 = 333, + Tm46 = 334, + Tm47 = 335, + Tm48 = 336, + Tm49 = 337, + Tm50 = 338, + Hm01 = 339, + Hm02 = 340, + Hm03 = 341, + Hm04 = 342, + Hm05 = 343, + Hm06 = 344, + Hm07 = 345, + Hm08 = 346, + Item15B = 347, + Item15C = 348, + OaksParcel = 349, + PokeFlute = 350, + SecretKey = 351, + BikeVoucher = 352, + GoldTeeth = 353, + OldAmber = 354, + CardKey = 355, + LiftKey = 356, + HelixFossil = 357, + DomeFossil = 358, + SilphScope = 359, + Bicycle = 360, + TownMap = 361, + VsSeeker = 362, + FameChecker = 363, + TmCase = 364, + BerryPouch = 365, + TeachyTv = 366, + TriPass = 367, + RainbowPass = 368, + Tea = 369, + MysticTicket = 370, + AuroraTicket = 371, + PowderJar = 372, + Ruby = 373, + Sapphire = 374, + NA = 375, +} + +impl Item { + /// Returns the `C` name of this item + pub fn c_name(&self) -> &'static str { + match self { + Item::MasterBall => "MASTER_BALL", + Item::UltraBall => "ULTRA_BALL", + Item::GreatBall => "GREAT_BALL", + Item::PokeBall => "POKE_BALL", + Item::SafariBall => "SAFARI_BALL", + Item::NetBall => "NET_BALL", + Item::DiveBall => "DIVE_BALL", + Item::NestBall => "NEST_BALL", + Item::RepeatBall => "REPEAT_BALL", + Item::TimerBall => "TIMER_BALL", + Item::LuxuryBall => "LUXURY_BALL", + Item::PremierBall => "PREMIER_BALL", + Item::Potion => "POTION", + Item::Antidote => "ANTIDOTE", + Item::BurnHeal => "BURN_HEAL", + Item::IceHeal => "ICE_HEAL", + Item::Awakening => "AWAKENING", + Item::ParalyzeHeal => "PARALYZE_HEAL", + Item::FullRestore => "FULL_RESTORE", + Item::MaxPotion => "MAX_POTION", + Item::HyperPotion => "HYPER_POTION", + Item::SuperPotion => "SUPER_POTION", + Item::FullHeal => "FULL_HEAL", + Item::Revive => "REVIVE", + Item::MaxRevive => "MAX_REVIVE", + Item::FreshWater => "FRESH_WATER", + Item::SodaPop => "SODA_POP", + Item::Lemonade => "LEMONADE", + Item::MoomooMilk => "MOOMOO_MILK", + Item::EnergyPowder => "ENERGY_POWDER", + Item::EnergyRoot => "ENERGY_ROOT", + Item::HealPowder => "HEAL_POWDER", + Item::RevivalHerb => "REVIVAL_HERB", + Item::Ether => "ETHER", + Item::MaxEther => "MAX_ETHER", + Item::Elixir => "ELIXIR", + Item::MaxElixir => "MAX_ELIXIR", + Item::LavaCookie => "LAVA_COOKIE", + Item::BlueFlute => "BLUE_FLUTE", + Item::YellowFlute => "YELLOW_FLUTE", + Item::RedFlute => "RED_FLUTE", + Item::BlackFlute => "BLACK_FLUTE", + Item::WhiteFlute => "WHITE_FLUTE", + Item::BerryJuice => "BERRY_JUICE", + Item::SacredAsh => "SACRED_ASH", + Item::ShoalSalt => "SHOAL_SALT", + Item::ShoalShell => "SHOAL_SHELL", + Item::RedShard => "RED_SHARD", + Item::BlueShard => "BLUE_SHARD", + Item::YellowShard => "YELLOW_SHARD", + Item::GreenShard => "GREEN_SHARD", + Item::Item034 => "034", + Item::Item035 => "035", + Item::Item036 => "036", + Item::Item037 => "037", + Item::Item038 => "038", + Item::Item039 => "039", + Item::Item03A => "03A", + Item::Item03B => "03B", + Item::Item03C => "03C", + Item::Item03D => "03D", + Item::Item03E => "03E", + Item::HpUp => "HP_UP", + Item::Protein => "PROTEIN", + Item::Iron => "IRON", + Item::Carbos => "CARBOS", + Item::Calcium => "CALCIUM", + Item::RareCandy => "RARE_CANDY", + Item::PpUp => "PP_UP", + Item::Zinc => "ZINC", + Item::PpMax => "PP_MAX", + Item::Item048 => "048", + Item::GuardSpec => "GUARD_SPEC", + Item::DireHit => "DIRE_HIT", + Item::XAttack => "X_ATTACK", + Item::XDefend => "X_DEFEND", + Item::XSpeed => "X_SPEED", + Item::XAccuracy => "X_ACCURACY", + Item::XSpecial => "X_SPECIAL", + Item::PokeDoll => "POKE_DOLL", + Item::FluffyTail => "FLUFFY_TAIL", + Item::Item052 => "052", + Item::SuperRepel => "SUPER_REPEL", + Item::MaxRepel => "MAX_REPEL", + Item::EscapeRope => "ESCAPE_ROPE", + Item::Repel => "REPEL", + Item::Item057 => "057", + Item::Item058 => "058", + Item::Item059 => "059", + Item::Item05A => "05A", + Item::Item05B => "05B", + Item::Item05C => "05C", + Item::SunStone => "SUN_STONE", + Item::MoonStone => "MOON_STONE", + Item::FireStone => "FIRE_STONE", + Item::ThunderStone => "THUNDER_STONE", + Item::WaterStone => "WATER_STONE", + Item::LeafStone => "LEAF_STONE", + Item::Item063 => "063", + Item::Item064 => "064", + Item::Item065 => "065", + Item::Item066 => "066", + Item::TinyMushroom => "TINY_MUSHROOM", + Item::BigMushroom => "BIG_MUSHROOM", + Item::Item069 => "069", + Item::Pearl => "PEARL", + Item::BigPearl => "BIG_PEARL", + Item::Stardust => "STARDUST", + Item::StarPiece => "STAR_PIECE", + Item::Nugget => "NUGGET", + Item::HeartScale => "HEART_SCALE", + Item::Item070 => "070", + Item::Item071 => "071", + Item::Item072 => "072", + Item::Item073 => "073", + Item::Item074 => "074", + Item::Item075 => "075", + Item::Item076 => "076", + Item::Item077 => "077", + Item::Item078 => "078", + Item::OrangeMail => "ORANGE_MAIL", + Item::HarborMail => "HARBOR_MAIL", + Item::GlitterMail => "GLITTER_MAIL", + Item::MechMail => "MECH_MAIL", + Item::WoodMail => "WOOD_MAIL", + Item::WaveMail => "WAVE_MAIL", + Item::BeadMail => "BEAD_MAIL", + Item::ShadowMail => "SHADOW_MAIL", + Item::TropicMail => "TROPIC_MAIL", + Item::DreamMail => "DREAM_MAIL", + Item::FabMail => "FAB_MAIL", + Item::RetroMail => "RETRO_MAIL", + Item::CheriBerry => "CHERI_BERRY", + Item::ChestoBerry => "CHESTO_BERRY", + Item::PechaBerry => "PECHA_BERRY", + Item::RawstBerry => "RAWST_BERRY", + Item::AspearBerry => "ASPEAR_BERRY", + Item::LeppaBerry => "LEPPA_BERRY", + Item::OranBerry => "ORAN_BERRY", + Item::PersimBerry => "PERSIM_BERRY", + Item::LumBerry => "LUM_BERRY", + Item::SitrusBerry => "SITRUS_BERRY", + Item::FigyBerry => "FIGY_BERRY", + Item::WikiBerry => "WIKI_BERRY", + Item::MagoBerry => "MAGO_BERRY", + Item::AguavBerry => "AGUAV_BERRY", + Item::IapapaBerry => "IAPAPA_BERRY", + Item::RazzBerry => "RAZZ_BERRY", + Item::BlukBerry => "BLUK_BERRY", + Item::NanabBerry => "NANAB_BERRY", + Item::WepearBerry => "WEPEAR_BERRY", + Item::PinapBerry => "PINAP_BERRY", + Item::PomegBerry => "POMEG_BERRY", + Item::KelpsyBerry => "KELPSY_BERRY", + Item::QualotBerry => "QUALOT_BERRY", + Item::HondewBerry => "HONDEW_BERRY", + Item::GrepaBerry => "GREPA_BERRY", + Item::TamatoBerry => "TAMATO_BERRY", + Item::CornnBerry => "CORNN_BERRY", + Item::MagostBerry => "MAGOST_BERRY", + Item::RabutaBerry => "RABUTA_BERRY", + Item::NomelBerry => "NOMEL_BERRY", + Item::SpelonBerry => "SPELON_BERRY", + Item::PamtreBerry => "PAMTRE_BERRY", + Item::WatmelBerry => "WATMEL_BERRY", + Item::DurinBerry => "DURIN_BERRY", + Item::BelueBerry => "BELUE_BERRY", + Item::LiechiBerry => "LIECHI_BERRY", + Item::GanlonBerry => "GANLON_BERRY", + Item::SalacBerry => "SALAC_BERRY", + Item::PetayaBerry => "PETAYA_BERRY", + Item::ApicotBerry => "APICOT_BERRY", + Item::LansatBerry => "LANSAT_BERRY", + Item::StarfBerry => "STARF_BERRY", + Item::EnigmaBerry => "ENIGMA_BERRY", + Item::Item0B0 => "0B0", + Item::Item0B1 => "0B1", + Item::Item0B2 => "0B2", + Item::BrightPowder => "BRIGHT_POWDER", + Item::WhiteHerb => "WHITE_HERB", + Item::MachoBrace => "MACHO_BRACE", + Item::ExpShare => "EXP_SHARE", + Item::QuickClaw => "QUICK_CLAW", + Item::SootheBell => "SOOTHE_BELL", + Item::MentalHerb => "MENTAL_HERB", + Item::ChoiceBand => "CHOICE_BAND", + Item::KingsRock => "KINGS_ROCK", + Item::SilverPowder => "SILVER_POWDER", + Item::AmuletCoin => "AMULET_COIN", + Item::CleanseTag => "CLEANSE_TAG", + Item::SoulDew => "SOUL_DEW", + Item::DeepSeaTooth => "DEEP_SEA_TOOTH", + Item::DeepSeaScale => "DEEP_SEA_SCALE", + Item::SmokeBall => "SMOKE_BALL", + Item::Everstone => "EVERSTONE", + Item::FocusBand => "FOCUS_BAND", + Item::LuckyEgg => "LUCKY_EGG", + Item::ScopeLens => "SCOPE_LENS", + Item::MetalCoat => "METAL_COAT", + Item::Leftovers => "LEFTOVERS", + Item::DragonScale => "DRAGON_SCALE", + Item::LightBall => "LIGHT_BALL", + Item::SoftSand => "SOFT_SAND", + Item::HardStone => "HARD_STONE", + Item::MiracleSeed => "MIRACLE_SEED", + Item::BlackGlasses => "BLACK_GLASSES", + Item::BlackBelt => "BLACK_BELT", + Item::Magnet => "MAGNET", + Item::MysticWater => "MYSTIC_WATER", + Item::SharpBeak => "SHARP_BEAK", + Item::PoisonBarb => "POISON_BARB", + Item::NeverMeltIce => "NEVER_MELT_ICE", + Item::SpellTag => "SPELL_TAG", + Item::TwistedSpoon => "TWISTED_SPOON", + Item::Charcoal => "CHARCOAL", + Item::DragonFang => "DRAGON_FANG", + Item::SilkScarf => "SILK_SCARF", + Item::UpGrade => "UP_GRADE", + Item::ShellBell => "SHELL_BELL", + Item::SeaIncense => "SEA_INCENSE", + Item::LaxIncense => "LAX_INCENSE", + Item::LuckyPunch => "LUCKY_PUNCH", + Item::MetalPowder => "METAL_POWDER", + Item::ThickClub => "THICK_CLUB", + Item::Stick => "STICK", + Item::Item0E2 => "0E2", + Item::Item0E3 => "0E3", + Item::Item0E4 => "0E4", + Item::Item0E5 => "0E5", + Item::Item0E6 => "0E6", + Item::Item0E7 => "0E7", + Item::Item0E8 => "0E8", + Item::Item0E9 => "0E9", + Item::Item0Ea => "0EA", + Item::Item0Eb => "0EB", + Item::Item0Ec => "0EC", + Item::Item0Ed => "0ED", + Item::Item0Ee => "0EE", + Item::Item0Ef => "0EF", + Item::Item0F0 => "0F0", + Item::Item0F1 => "0F1", + Item::Item0F2 => "0F2", + Item::Item0F3 => "0F3", + Item::Item0F4 => "0F4", + Item::Item0F5 => "0F5", + Item::Item0F6 => "0F6", + Item::Item0F7 => "0F7", + Item::Item0F8 => "0F8", + Item::Item0F9 => "0F9", + Item::Item0Fa => "0FA", + Item::Item0Fb => "0FB", + Item::Item0Fc => "0FC", + Item::Item0Fd => "0FD", + Item::RedScarf => "RED_SCARF", + Item::BlueScarf => "BLUE_SCARF", + Item::PinkScarf => "PINK_SCARF", + Item::GreenScarf => "GREEN_SCARF", + Item::YellowScarf => "YELLOW_SCARF", + Item::MachBike => "MACH_BIKE", + Item::CoinCase => "COIN_CASE", + Item::Itemfinder => "ITEMFINDER", + Item::OldRod => "OLD_ROD", + Item::GoodRod => "GOOD_ROD", + Item::SuperRod => "SUPER_ROD", + Item::SsTicket => "SS_TICKET", + Item::ContestPass => "CONTEST_PASS", + Item::Item10B => "10B", + Item::WailmerPail => "WAILMER_PAIL", + Item::DevonGoods => "DEVON_GOODS", + Item::SootSack => "SOOT_SACK", + Item::BasementKey => "BASEMENT_KEY", + Item::AcroBike => "ACRO_BIKE", + Item::PokeblockCase => "POKEBLOCK_CASE", + Item::Letter => "LETTER", + Item::EonTicket => "EON_TICKET", + Item::RedOrb => "RED_ORB", + Item::BlueOrb => "BLUE_ORB", + Item::Scanner => "SCANNER", + Item::GoGoggles => "GO_GOGGLES", + Item::Meteorite => "METEORITE", + Item::Room1Key => "ROOM_1_KEY", + Item::Room2Key => "ROOM_2_KEY", + Item::Room4Key => "ROOM_4_KEY", + Item::Room6Key => "ROOM_6_KEY", + Item::StorageKey => "STORAGE_KEY", + Item::RootFossil => "ROOT_FOSSIL", + Item::ClawFossil => "CLAW_FOSSIL", + Item::DevonScope => "DEVON_SCOPE", + Item::Tm01 => "TM01", + Item::Tm02 => "TM02", + Item::Tm03 => "TM03", + Item::Tm04 => "TM04", + Item::Tm05 => "TM05", + Item::Tm06 => "TM06", + Item::Tm07 => "TM07", + Item::Tm08 => "TM08", + Item::Tm09 => "TM09", + Item::Tm10 => "TM10", + Item::Tm11 => "TM11", + Item::Tm12 => "TM12", + Item::Tm13 => "TM13", + Item::Tm14 => "TM14", + Item::Tm15 => "TM15", + Item::Tm16 => "TM16", + Item::Tm17 => "TM17", + Item::Tm18 => "TM18", + Item::Tm19 => "TM19", + Item::Tm20 => "TM20", + Item::Tm21 => "TM21", + Item::Tm22 => "TM22", + Item::Tm23 => "TM23", + Item::Tm24 => "TM24", + Item::Tm25 => "TM25", + Item::Tm26 => "TM26", + Item::Tm27 => "TM27", + Item::Tm28 => "TM28", + Item::Tm29 => "TM29", + Item::Tm30 => "TM30", + Item::Tm31 => "TM31", + Item::Tm32 => "TM32", + Item::Tm33 => "TM33", + Item::Tm34 => "TM34", + Item::Tm35 => "TM35", + Item::Tm36 => "TM36", + Item::Tm37 => "TM37", + Item::Tm38 => "TM38", + Item::Tm39 => "TM39", + Item::Tm40 => "TM40", + Item::Tm41 => "TM41", + Item::Tm42 => "TM42", + Item::Tm43 => "TM43", + Item::Tm44 => "TM44", + Item::Tm45 => "TM45", + Item::Tm46 => "TM46", + Item::Tm47 => "TM47", + Item::Tm48 => "TM48", + Item::Tm49 => "TM49", + Item::Tm50 => "TM50", + Item::Hm01 => "HM01", + Item::Hm02 => "HM02", + Item::Hm03 => "HM03", + Item::Hm04 => "HM04", + Item::Hm05 => "HM05", + Item::Hm06 => "HM06", + Item::Hm07 => "HM07", + Item::Hm08 => "HM08", + Item::Item15B => "15B", + Item::Item15C => "15C", + Item::OaksParcel => "OAKS_PARCEL", + Item::PokeFlute => "POKE_FLUTE", + Item::SecretKey => "SECRET_KEY", + Item::BikeVoucher => "BIKE_VOUCHER", + Item::GoldTeeth => "GOLD_TEETH", + Item::OldAmber => "OLD_AMBER", + Item::CardKey => "CARD_KEY", + Item::LiftKey => "LIFT_KEY", + Item::HelixFossil => "HELIX_FOSSIL", + Item::DomeFossil => "DOME_FOSSIL", + Item::SilphScope => "SILPH_SCOPE", + Item::Bicycle => "BICYCLE", + Item::TownMap => "TOWN_MAP", + Item::VsSeeker => "VS_SEEKER", + Item::FameChecker => "FAME_CHECKER", + Item::TmCase => "TM_CASE", + Item::BerryPouch => "BERRY_POUCH", + Item::TeachyTv => "TEACHY_TV", + Item::TriPass => "TRI_PASS", + Item::RainbowPass => "RAINBOW_PASS", + Item::Tea => "TEA", + Item::MysticTicket => "MYSTIC_TICKET", + Item::AuroraTicket => "AURORA_TICKET", + Item::PowderJar => "POWDER_JAR", + Item::Ruby => "RUBY", + Item::Sapphire => "SAPPHIRE", + Item::NA => "N_A", + } + } +} diff --git a/poke/src/lib.rs b/poke/src/lib.rs new file mode 100644 index 0000000..1bd894b --- /dev/null +++ b/poke/src/lib.rs @@ -0,0 +1,24 @@ +//! Pokemon + +// Features +#![feature(format_args_capture, array_methods)] + +// Modules +mod ability; +mod base_stats; +mod body_color; +mod egg_group; +mod growth_rate; +mod item; +mod species; +mod ty; + +// Exports +pub use ability::Ability; +pub use base_stats::{BaseStats, Gender}; +pub use body_color::BodyColor; +pub use egg_group::EggGroup; +pub use growth_rate::GrowthRate; +pub use item::Item; +pub use species::Species; +pub use ty::Type; diff --git a/poke/src/species.rs b/poke/src/species.rs new file mode 100644 index 0000000..e49d860 --- /dev/null +++ b/poke/src/species.rs @@ -0,0 +1,894 @@ +//! Species + + +/// Pokemon Species +#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash, Debug)] +#[derive(serde::Serialize, serde::Deserialize)] +pub enum Species { + Bulbasaur = 1, + Ivysaur = 2, + Venusaur = 3, + Charmander = 4, + Charmeleon = 5, + Charizard = 6, + Squirtle = 7, + Wartortle = 8, + Blastoise = 9, + Caterpie = 10, + Metapod = 11, + Butterfree = 12, + Weedle = 13, + Kakuna = 14, + Beedrill = 15, + Pidgey = 16, + Pidgeotto = 17, + Pidgeot = 18, + Rattata = 19, + Raticate = 20, + Spearow = 21, + Fearow = 22, + Ekans = 23, + Arbok = 24, + Pikachu = 25, + Raichu = 26, + Sandshrew = 27, + Sandslash = 28, + NidoranF = 29, + Nidorina = 30, + Nidoqueen = 31, + NidoranM = 32, + Nidorino = 33, + Nidoking = 34, + Clefairy = 35, + Clefable = 36, + Vulpix = 37, + Ninetales = 38, + Jigglypuff = 39, + Wigglytuff = 40, + Zubat = 41, + Golbat = 42, + Oddish = 43, + Gloom = 44, + Vileplume = 45, + Paras = 46, + Parasect = 47, + Venonat = 48, + Venomoth = 49, + Diglett = 50, + Dugtrio = 51, + Meowth = 52, + Persian = 53, + Psyduck = 54, + Golduck = 55, + Mankey = 56, + Primeape = 57, + Growlithe = 58, + Arcanine = 59, + Poliwag = 60, + Poliwhirl = 61, + Poliwrath = 62, + Abra = 63, + Kadabra = 64, + Alakazam = 65, + Machop = 66, + Machoke = 67, + Machamp = 68, + Bellsprout = 69, + Weepinbell = 70, + Victreebel = 71, + Tentacool = 72, + Tentacruel = 73, + Geodude = 74, + Graveler = 75, + Golem = 76, + Ponyta = 77, + Rapidash = 78, + Slowpoke = 79, + Slowbro = 80, + Magnemite = 81, + Magneton = 82, + Farfetchd = 83, + Doduo = 84, + Dodrio = 85, + Seel = 86, + Dewgong = 87, + Grimer = 88, + Muk = 89, + Shellder = 90, + Cloyster = 91, + Gastly = 92, + Haunter = 93, + Gengar = 94, + Onix = 95, + Drowzee = 96, + Hypno = 97, + Krabby = 98, + Kingler = 99, + Voltorb = 100, + Electrode = 101, + Exeggcute = 102, + Exeggutor = 103, + Cubone = 104, + Marowak = 105, + Hitmonlee = 106, + Hitmonchan = 107, + Lickitung = 108, + Koffing = 109, + Weezing = 110, + Rhyhorn = 111, + Rhydon = 112, + Chansey = 113, + Tangela = 114, + Kangaskhan = 115, + Horsea = 116, + Seadra = 117, + Goldeen = 118, + Seaking = 119, + Staryu = 120, + Starmie = 121, + MrMime = 122, + Scyther = 123, + Jynx = 124, + Electabuzz = 125, + Magmar = 126, + Pinsir = 127, + Tauros = 128, + Magikarp = 129, + Gyarados = 130, + Lapras = 131, + Ditto = 132, + Eevee = 133, + Vaporeon = 134, + Jolteon = 135, + Flareon = 136, + Porygon = 137, + Omanyte = 138, + Omastar = 139, + Kabuto = 140, + Kabutops = 141, + Aerodactyl = 142, + Snorlax = 143, + Articuno = 144, + Zapdos = 145, + Moltres = 146, + Dratini = 147, + Dragonair = 148, + Dragonite = 149, + Mewtwo = 150, + Mew = 151, + Chikorita = 152, + Bayleef = 153, + Meganium = 154, + Cyndaquil = 155, + Quilava = 156, + Typhlosion = 157, + Totodile = 158, + Croconaw = 159, + Feraligatr = 160, + Sentret = 161, + Furret = 162, + Hoothoot = 163, + Noctowl = 164, + Ledyba = 165, + Ledian = 166, + Spinarak = 167, + Ariados = 168, + Crobat = 169, + Chinchou = 170, + Lanturn = 171, + Pichu = 172, + Cleffa = 173, + Igglybuff = 174, + Togepi = 175, + Togetic = 176, + Natu = 177, + Xatu = 178, + Mareep = 179, + Flaaffy = 180, + Ampharos = 181, + Bellossom = 182, + Marill = 183, + Azumarill = 184, + Sudowoodo = 185, + Politoed = 186, + Hoppip = 187, + Skiploom = 188, + Jumpluff = 189, + Aipom = 190, + Sunkern = 191, + Sunflora = 192, + Yanma = 193, + Wooper = 194, + Quagsire = 195, + Espeon = 196, + Umbreon = 197, + Murkrow = 198, + Slowking = 199, + Misdreavus = 200, + Unown = 201, + Wobbuffet = 202, + Girafarig = 203, + Pineco = 204, + Forretress = 205, + Dunsparce = 206, + Gligar = 207, + Steelix = 208, + Snubbull = 209, + Granbull = 210, + Qwilfish = 211, + Scizor = 212, + Shuckle = 213, + Heracross = 214, + Sneasel = 215, + Teddiursa = 216, + Ursaring = 217, + Slugma = 218, + Magcargo = 219, + Swinub = 220, + Piloswine = 221, + Corsola = 222, + Remoraid = 223, + Octillery = 224, + Delibird = 225, + Mantine = 226, + Skarmory = 227, + Houndour = 228, + Houndoom = 229, + Kingdra = 230, + Phanpy = 231, + Donphan = 232, + Porygon2 = 233, + Stantler = 234, + Smeargle = 235, + Tyrogue = 236, + Hitmontop = 237, + Smoochum = 238, + Elekid = 239, + Magby = 240, + Miltank = 241, + Blissey = 242, + Raikou = 243, + Entei = 244, + Suicune = 245, + Larvitar = 246, + Pupitar = 247, + Tyranitar = 248, + Lugia = 249, + HoOh = 250, + Celebi = 251, + OldUnownB = 252, + OldUnownC = 253, + OldUnownD = 254, + OldUnownE = 255, + OldUnownF = 256, + OldUnownG = 257, + OldUnownH = 258, + OldUnownI = 259, + OldUnownJ = 260, + OldUnownK = 261, + OldUnownL = 262, + OldUnownM = 263, + OldUnownN = 264, + OldUnownO = 265, + OldUnownP = 266, + OldUnownQ = 267, + OldUnownR = 268, + OldUnownS = 269, + OldUnownT = 270, + OldUnownU = 271, + OldUnownV = 272, + OldUnownW = 273, + OldUnownX = 274, + OldUnownY = 275, + OldUnownZ = 276, + Treecko = 277, + Grovyle = 278, + Sceptile = 279, + Torchic = 280, + Combusken = 281, + Blaziken = 282, + Mudkip = 283, + Marshtomp = 284, + Swampert = 285, + Poochyena = 286, + Mightyena = 287, + Zigzagoon = 288, + Linoone = 289, + Wurmple = 290, + Silcoon = 291, + Beautifly = 292, + Cascoon = 293, + Dustox = 294, + Lotad = 295, + Lombre = 296, + Ludicolo = 297, + Seedot = 298, + Nuzleaf = 299, + Shiftry = 300, + Nincada = 301, + Ninjask = 302, + Shedinja = 303, + Taillow = 304, + Swellow = 305, + Shroomish = 306, + Breloom = 307, + Spinda = 308, + Wingull = 309, + Pelipper = 310, + Surskit = 311, + Masquerain = 312, + Wailmer = 313, + Wailord = 314, + Skitty = 315, + Delcatty = 316, + Kecleon = 317, + Baltoy = 318, + Claydol = 319, + Nosepass = 320, + Torkoal = 321, + Sableye = 322, + Barboach = 323, + Whiscash = 324, + Luvdisc = 325, + Corphish = 326, + Crawdaunt = 327, + Feebas = 328, + Milotic = 329, + Carvanha = 330, + Sharpedo = 331, + Trapinch = 332, + Vibrava = 333, + Flygon = 334, + Makuhita = 335, + Hariyama = 336, + Electrike = 337, + Manectric = 338, + Numel = 339, + Camerupt = 340, + Spheal = 341, + Sealeo = 342, + Walrein = 343, + Cacnea = 344, + Cacturne = 345, + Snorunt = 346, + Glalie = 347, + Lunatone = 348, + Solrock = 349, + Azurill = 350, + Spoink = 351, + Grumpig = 352, + Plusle = 353, + Minun = 354, + Mawile = 355, + Meditite = 356, + Medicham = 357, + Swablu = 358, + Altaria = 359, + Wynaut = 360, + Duskull = 361, + Dusclops = 362, + Roselia = 363, + Slakoth = 364, + Vigoroth = 365, + Slaking = 366, + Gulpin = 367, + Swalot = 368, + Tropius = 369, + Whismur = 370, + Loudred = 371, + Exploud = 372, + Clamperl = 373, + Huntail = 374, + Gorebyss = 375, + Absol = 376, + Shuppet = 377, + Banette = 378, + Seviper = 379, + Zangoose = 380, + Relicanth = 381, + Aron = 382, + Lairon = 383, + Aggron = 384, + Castform = 385, + Volbeat = 386, + Illumise = 387, + Lileep = 388, + Cradily = 389, + Anorith = 390, + Armaldo = 391, + Ralts = 392, + Kirlia = 393, + Gardevoir = 394, + Bagon = 395, + Shelgon = 396, + Salamence = 397, + Beldum = 398, + Metang = 399, + Metagross = 400, + Regirock = 401, + Regice = 402, + Registeel = 403, + Kyogre = 404, + Groudon = 405, + Rayquaza = 406, + Latias = 407, + Latios = 408, + Jirachi = 409, + Deoxys = 410, + Chimecho = 411, + Egg = 412, + UnownB = 413, + UnownC = 414, + UnownD = 415, + UnownE = 416, + UnownF = 417, + UnownG = 418, + UnownH = 419, + UnownI = 420, + UnownJ = 421, + UnownK = 422, + UnownL = 423, + UnownM = 424, + UnownN = 425, + UnownO = 426, + UnownP = 427, + UnownQ = 428, + UnownR = 429, + UnownS = 430, + UnownT = 431, + UnownU = 432, + UnownV = 433, + UnownW = 434, + UnownX = 435, + UnownY = 436, + UnownZ = 437, + UnownEmark = 438, + UnownQmark = 439, +} + +impl Species { + /// Returns the `C` name of this species + pub fn c_name(&self) -> &'static str { + match self { + Species::Bulbasaur => "BULBASAUR", + Species::Ivysaur => "IVYSAUR", + Species::Venusaur => "VENUSAUR", + Species::Charmander => "CHARMANDER", + Species::Charmeleon => "CHARMELEON", + Species::Charizard => "CHARIZARD", + Species::Squirtle => "SQUIRTLE", + Species::Wartortle => "WARTORTLE", + Species::Blastoise => "BLASTOISE", + Species::Caterpie => "CATERPIE", + Species::Metapod => "METAPOD", + Species::Butterfree => "BUTTERFREE", + Species::Weedle => "WEEDLE", + Species::Kakuna => "KAKUNA", + Species::Beedrill => "BEEDRILL", + Species::Pidgey => "PIDGEY", + Species::Pidgeotto => "PIDGEOTTO", + Species::Pidgeot => "PIDGEOT", + Species::Rattata => "RATTATA", + Species::Raticate => "RATICATE", + Species::Spearow => "SPEAROW", + Species::Fearow => "FEAROW", + Species::Ekans => "EKANS", + Species::Arbok => "ARBOK", + Species::Pikachu => "PIKACHU", + Species::Raichu => "RAICHU", + Species::Sandshrew => "SANDSHREW", + Species::Sandslash => "SANDSLASH", + Species::NidoranF => "NIDORAN_F", + Species::Nidorina => "NIDORINA", + Species::Nidoqueen => "NIDOQUEEN", + Species::NidoranM => "NIDORAN_M", + Species::Nidorino => "NIDORINO", + Species::Nidoking => "NIDOKING", + Species::Clefairy => "CLEFAIRY", + Species::Clefable => "CLEFABLE", + Species::Vulpix => "VULPIX", + Species::Ninetales => "NINETALES", + Species::Jigglypuff => "JIGGLYPUFF", + Species::Wigglytuff => "WIGGLYTUFF", + Species::Zubat => "ZUBAT", + Species::Golbat => "GOLBAT", + Species::Oddish => "ODDISH", + Species::Gloom => "GLOOM", + Species::Vileplume => "VILEPLUME", + Species::Paras => "PARAS", + Species::Parasect => "PARASECT", + Species::Venonat => "VENONAT", + Species::Venomoth => "VENOMOTH", + Species::Diglett => "DIGLETT", + Species::Dugtrio => "DUGTRIO", + Species::Meowth => "MEOWTH", + Species::Persian => "PERSIAN", + Species::Psyduck => "PSYDUCK", + Species::Golduck => "GOLDUCK", + Species::Mankey => "MANKEY", + Species::Primeape => "PRIMEAPE", + Species::Growlithe => "GROWLITHE", + Species::Arcanine => "ARCANINE", + Species::Poliwag => "POLIWAG", + Species::Poliwhirl => "POLIWHIRL", + Species::Poliwrath => "POLIWRATH", + Species::Abra => "ABRA", + Species::Kadabra => "KADABRA", + Species::Alakazam => "ALAKAZAM", + Species::Machop => "MACHOP", + Species::Machoke => "MACHOKE", + Species::Machamp => "MACHAMP", + Species::Bellsprout => "BELLSPROUT", + Species::Weepinbell => "WEEPINBELL", + Species::Victreebel => "VICTREEBEL", + Species::Tentacool => "TENTACOOL", + Species::Tentacruel => "TENTACRUEL", + Species::Geodude => "GEODUDE", + Species::Graveler => "GRAVELER", + Species::Golem => "GOLEM", + Species::Ponyta => "PONYTA", + Species::Rapidash => "RAPIDASH", + Species::Slowpoke => "SLOWPOKE", + Species::Slowbro => "SLOWBRO", + Species::Magnemite => "MAGNEMITE", + Species::Magneton => "MAGNETON", + Species::Farfetchd => "FARFETCHD", + Species::Doduo => "DODUO", + Species::Dodrio => "DODRIO", + Species::Seel => "SEEL", + Species::Dewgong => "DEWGONG", + Species::Grimer => "GRIMER", + Species::Muk => "MUK", + Species::Shellder => "SHELLDER", + Species::Cloyster => "CLOYSTER", + Species::Gastly => "GASTLY", + Species::Haunter => "HAUNTER", + Species::Gengar => "GENGAR", + Species::Onix => "ONIX", + Species::Drowzee => "DROWZEE", + Species::Hypno => "HYPNO", + Species::Krabby => "KRABBY", + Species::Kingler => "KINGLER", + Species::Voltorb => "VOLTORB", + Species::Electrode => "ELECTRODE", + Species::Exeggcute => "EXEGGCUTE", + Species::Exeggutor => "EXEGGUTOR", + Species::Cubone => "CUBONE", + Species::Marowak => "MAROWAK", + Species::Hitmonlee => "HITMONLEE", + Species::Hitmonchan => "HITMONCHAN", + Species::Lickitung => "LICKITUNG", + Species::Koffing => "KOFFING", + Species::Weezing => "WEEZING", + Species::Rhyhorn => "RHYHORN", + Species::Rhydon => "RHYDON", + Species::Chansey => "CHANSEY", + Species::Tangela => "TANGELA", + Species::Kangaskhan => "KANGASKHAN", + Species::Horsea => "HORSEA", + Species::Seadra => "SEADRA", + Species::Goldeen => "GOLDEEN", + Species::Seaking => "SEAKING", + Species::Staryu => "STARYU", + Species::Starmie => "STARMIE", + Species::MrMime => "MR_MIME", + Species::Scyther => "SCYTHER", + Species::Jynx => "JYNX", + Species::Electabuzz => "ELECTABUZZ", + Species::Magmar => "MAGMAR", + Species::Pinsir => "PINSIR", + Species::Tauros => "TAUROS", + Species::Magikarp => "MAGIKARP", + Species::Gyarados => "GYARADOS", + Species::Lapras => "LAPRAS", + Species::Ditto => "DITTO", + Species::Eevee => "EEVEE", + Species::Vaporeon => "VAPOREON", + Species::Jolteon => "JOLTEON", + Species::Flareon => "FLAREON", + Species::Porygon => "PORYGON", + Species::Omanyte => "OMANYTE", + Species::Omastar => "OMASTAR", + Species::Kabuto => "KABUTO", + Species::Kabutops => "KABUTOPS", + Species::Aerodactyl => "AERODACTYL", + Species::Snorlax => "SNORLAX", + Species::Articuno => "ARTICUNO", + Species::Zapdos => "ZAPDOS", + Species::Moltres => "MOLTRES", + Species::Dratini => "DRATINI", + Species::Dragonair => "DRAGONAIR", + Species::Dragonite => "DRAGONITE", + Species::Mewtwo => "MEWTWO", + Species::Mew => "MEW", + Species::Chikorita => "CHIKORITA", + Species::Bayleef => "BAYLEEF", + Species::Meganium => "MEGANIUM", + Species::Cyndaquil => "CYNDAQUIL", + Species::Quilava => "QUILAVA", + Species::Typhlosion => "TYPHLOSION", + Species::Totodile => "TOTODILE", + Species::Croconaw => "CROCONAW", + Species::Feraligatr => "FERALIGATR", + Species::Sentret => "SENTRET", + Species::Furret => "FURRET", + Species::Hoothoot => "HOOTHOOT", + Species::Noctowl => "NOCTOWL", + Species::Ledyba => "LEDYBA", + Species::Ledian => "LEDIAN", + Species::Spinarak => "SPINARAK", + Species::Ariados => "ARIADOS", + Species::Crobat => "CROBAT", + Species::Chinchou => "CHINCHOU", + Species::Lanturn => "LANTURN", + Species::Pichu => "PICHU", + Species::Cleffa => "CLEFFA", + Species::Igglybuff => "IGGLYBUFF", + Species::Togepi => "TOGEPI", + Species::Togetic => "TOGETIC", + Species::Natu => "NATU", + Species::Xatu => "XATU", + Species::Mareep => "MAREEP", + Species::Flaaffy => "FLAAFFY", + Species::Ampharos => "AMPHAROS", + Species::Bellossom => "BELLOSSOM", + Species::Marill => "MARILL", + Species::Azumarill => "AZUMARILL", + Species::Sudowoodo => "SUDOWOODO", + Species::Politoed => "POLITOED", + Species::Hoppip => "HOPPIP", + Species::Skiploom => "SKIPLOOM", + Species::Jumpluff => "JUMPLUFF", + Species::Aipom => "AIPOM", + Species::Sunkern => "SUNKERN", + Species::Sunflora => "SUNFLORA", + Species::Yanma => "YANMA", + Species::Wooper => "WOOPER", + Species::Quagsire => "QUAGSIRE", + Species::Espeon => "ESPEON", + Species::Umbreon => "UMBREON", + Species::Murkrow => "MURKROW", + Species::Slowking => "SLOWKING", + Species::Misdreavus => "MISDREAVUS", + Species::Unown => "UNOWN", + Species::Wobbuffet => "WOBBUFFET", + Species::Girafarig => "GIRAFARIG", + Species::Pineco => "PINECO", + Species::Forretress => "FORRETRESS", + Species::Dunsparce => "DUNSPARCE", + Species::Gligar => "GLIGAR", + Species::Steelix => "STEELIX", + Species::Snubbull => "SNUBBULL", + Species::Granbull => "GRANBULL", + Species::Qwilfish => "QWILFISH", + Species::Scizor => "SCIZOR", + Species::Shuckle => "SHUCKLE", + Species::Heracross => "HERACROSS", + Species::Sneasel => "SNEASEL", + Species::Teddiursa => "TEDDIURSA", + Species::Ursaring => "URSARING", + Species::Slugma => "SLUGMA", + Species::Magcargo => "MAGCARGO", + Species::Swinub => "SWINUB", + Species::Piloswine => "PILOSWINE", + Species::Corsola => "CORSOLA", + Species::Remoraid => "REMORAID", + Species::Octillery => "OCTILLERY", + Species::Delibird => "DELIBIRD", + Species::Mantine => "MANTINE", + Species::Skarmory => "SKARMORY", + Species::Houndour => "HOUNDOUR", + Species::Houndoom => "HOUNDOOM", + Species::Kingdra => "KINGDRA", + Species::Phanpy => "PHANPY", + Species::Donphan => "DONPHAN", + Species::Porygon2 => "PORYGON2", + Species::Stantler => "STANTLER", + Species::Smeargle => "SMEARGLE", + Species::Tyrogue => "TYROGUE", + Species::Hitmontop => "HITMONTOP", + Species::Smoochum => "SMOOCHUM", + Species::Elekid => "ELEKID", + Species::Magby => "MAGBY", + Species::Miltank => "MILTANK", + Species::Blissey => "BLISSEY", + Species::Raikou => "RAIKOU", + Species::Entei => "ENTEI", + Species::Suicune => "SUICUNE", + Species::Larvitar => "LARVITAR", + Species::Pupitar => "PUPITAR", + Species::Tyranitar => "TYRANITAR", + Species::Lugia => "LUGIA", + Species::HoOh => "HO_OH", + Species::Celebi => "CELEBI", + Species::OldUnownB => "OLD_UNOWN_B", + Species::OldUnownC => "OLD_UNOWN_C", + Species::OldUnownD => "OLD_UNOWN_D", + Species::OldUnownE => "OLD_UNOWN_E", + Species::OldUnownF => "OLD_UNOWN_F", + Species::OldUnownG => "OLD_UNOWN_G", + Species::OldUnownH => "OLD_UNOWN_H", + Species::OldUnownI => "OLD_UNOWN_I", + Species::OldUnownJ => "OLD_UNOWN_J", + Species::OldUnownK => "OLD_UNOWN_K", + Species::OldUnownL => "OLD_UNOWN_L", + Species::OldUnownM => "OLD_UNOWN_M", + Species::OldUnownN => "OLD_UNOWN_N", + Species::OldUnownO => "OLD_UNOWN_O", + Species::OldUnownP => "OLD_UNOWN_P", + Species::OldUnownQ => "OLD_UNOWN_Q", + Species::OldUnownR => "OLD_UNOWN_R", + Species::OldUnownS => "OLD_UNOWN_S", + Species::OldUnownT => "OLD_UNOWN_T", + Species::OldUnownU => "OLD_UNOWN_U", + Species::OldUnownV => "OLD_UNOWN_V", + Species::OldUnownW => "OLD_UNOWN_W", + Species::OldUnownX => "OLD_UNOWN_X", + Species::OldUnownY => "OLD_UNOWN_Y", + Species::OldUnownZ => "OLD_UNOWN_Z", + Species::Treecko => "TREECKO", + Species::Grovyle => "GROVYLE", + Species::Sceptile => "SCEPTILE", + Species::Torchic => "TORCHIC", + Species::Combusken => "COMBUSKEN", + Species::Blaziken => "BLAZIKEN", + Species::Mudkip => "MUDKIP", + Species::Marshtomp => "MARSHTOMP", + Species::Swampert => "SWAMPERT", + Species::Poochyena => "POOCHYENA", + Species::Mightyena => "MIGHTYENA", + Species::Zigzagoon => "ZIGZAGOON", + Species::Linoone => "LINOONE", + Species::Wurmple => "WURMPLE", + Species::Silcoon => "SILCOON", + Species::Beautifly => "BEAUTIFLY", + Species::Cascoon => "CASCOON", + Species::Dustox => "DUSTOX", + Species::Lotad => "LOTAD", + Species::Lombre => "LOMBRE", + Species::Ludicolo => "LUDICOLO", + Species::Seedot => "SEEDOT", + Species::Nuzleaf => "NUZLEAF", + Species::Shiftry => "SHIFTRY", + Species::Nincada => "NINCADA", + Species::Ninjask => "NINJASK", + Species::Shedinja => "SHEDINJA", + Species::Taillow => "TAILLOW", + Species::Swellow => "SWELLOW", + Species::Shroomish => "SHROOMISH", + Species::Breloom => "BRELOOM", + Species::Spinda => "SPINDA", + Species::Wingull => "WINGULL", + Species::Pelipper => "PELIPPER", + Species::Surskit => "SURSKIT", + Species::Masquerain => "MASQUERAIN", + Species::Wailmer => "WAILMER", + Species::Wailord => "WAILORD", + Species::Skitty => "SKITTY", + Species::Delcatty => "DELCATTY", + Species::Kecleon => "KECLEON", + Species::Baltoy => "BALTOY", + Species::Claydol => "CLAYDOL", + Species::Nosepass => "NOSEPASS", + Species::Torkoal => "TORKOAL", + Species::Sableye => "SABLEYE", + Species::Barboach => "BARBOACH", + Species::Whiscash => "WHISCASH", + Species::Luvdisc => "LUVDISC", + Species::Corphish => "CORPHISH", + Species::Crawdaunt => "CRAWDAUNT", + Species::Feebas => "FEEBAS", + Species::Milotic => "MILOTIC", + Species::Carvanha => "CARVANHA", + Species::Sharpedo => "SHARPEDO", + Species::Trapinch => "TRAPINCH", + Species::Vibrava => "VIBRAVA", + Species::Flygon => "FLYGON", + Species::Makuhita => "MAKUHITA", + Species::Hariyama => "HARIYAMA", + Species::Electrike => "ELECTRIKE", + Species::Manectric => "MANECTRIC", + Species::Numel => "NUMEL", + Species::Camerupt => "CAMERUPT", + Species::Spheal => "SPHEAL", + Species::Sealeo => "SEALEO", + Species::Walrein => "WALREIN", + Species::Cacnea => "CACNEA", + Species::Cacturne => "CACTURNE", + Species::Snorunt => "SNORUNT", + Species::Glalie => "GLALIE", + Species::Lunatone => "LUNATONE", + Species::Solrock => "SOLROCK", + Species::Azurill => "AZURILL", + Species::Spoink => "SPOINK", + Species::Grumpig => "GRUMPIG", + Species::Plusle => "PLUSLE", + Species::Minun => "MINUN", + Species::Mawile => "MAWILE", + Species::Meditite => "MEDITITE", + Species::Medicham => "MEDICHAM", + Species::Swablu => "SWABLU", + Species::Altaria => "ALTARIA", + Species::Wynaut => "WYNAUT", + Species::Duskull => "DUSKULL", + Species::Dusclops => "DUSCLOPS", + Species::Roselia => "ROSELIA", + Species::Slakoth => "SLAKOTH", + Species::Vigoroth => "VIGOROTH", + Species::Slaking => "SLAKING", + Species::Gulpin => "GULPIN", + Species::Swalot => "SWALOT", + Species::Tropius => "TROPIUS", + Species::Whismur => "WHISMUR", + Species::Loudred => "LOUDRED", + Species::Exploud => "EXPLOUD", + Species::Clamperl => "CLAMPERL", + Species::Huntail => "HUNTAIL", + Species::Gorebyss => "GOREBYSS", + Species::Absol => "ABSOL", + Species::Shuppet => "SHUPPET", + Species::Banette => "BANETTE", + Species::Seviper => "SEVIPER", + Species::Zangoose => "ZANGOOSE", + Species::Relicanth => "RELICANTH", + Species::Aron => "ARON", + Species::Lairon => "LAIRON", + Species::Aggron => "AGGRON", + Species::Castform => "CASTFORM", + Species::Volbeat => "VOLBEAT", + Species::Illumise => "ILLUMISE", + Species::Lileep => "LILEEP", + Species::Cradily => "CRADILY", + Species::Anorith => "ANORITH", + Species::Armaldo => "ARMALDO", + Species::Ralts => "RALTS", + Species::Kirlia => "KIRLIA", + Species::Gardevoir => "GARDEVOIR", + Species::Bagon => "BAGON", + Species::Shelgon => "SHELGON", + Species::Salamence => "SALAMENCE", + Species::Beldum => "BELDUM", + Species::Metang => "METANG", + Species::Metagross => "METAGROSS", + Species::Regirock => "REGIROCK", + Species::Regice => "REGICE", + Species::Registeel => "REGISTEEL", + Species::Kyogre => "KYOGRE", + Species::Groudon => "GROUDON", + Species::Rayquaza => "RAYQUAZA", + Species::Latias => "LATIAS", + Species::Latios => "LATIOS", + Species::Jirachi => "JIRACHI", + Species::Deoxys => "DEOXYS", + Species::Chimecho => "CHIMECHO", + Species::Egg => "EGG", + Species::UnownB => "UNOWN_B", + Species::UnownC => "UNOWN_C", + Species::UnownD => "UNOWN_D", + Species::UnownE => "UNOWN_E", + Species::UnownF => "UNOWN_F", + Species::UnownG => "UNOWN_G", + Species::UnownH => "UNOWN_H", + Species::UnownI => "UNOWN_I", + Species::UnownJ => "UNOWN_J", + Species::UnownK => "UNOWN_K", + Species::UnownL => "UNOWN_L", + Species::UnownM => "UNOWN_M", + Species::UnownN => "UNOWN_N", + Species::UnownO => "UNOWN_O", + Species::UnownP => "UNOWN_P", + Species::UnownQ => "UNOWN_Q", + Species::UnownR => "UNOWN_R", + Species::UnownS => "UNOWN_S", + Species::UnownT => "UNOWN_T", + Species::UnownU => "UNOWN_U", + Species::UnownV => "UNOWN_V", + Species::UnownW => "UNOWN_W", + Species::UnownX => "UNOWN_X", + Species::UnownY => "UNOWN_Y", + Species::UnownZ => "UNOWN_Z", + Species::UnownEmark => "UNOWN_EMARK", + Species::UnownQmark => "UNOWN_QMARK", + } + } +} diff --git a/poke/src/ty.rs b/poke/src/ty.rs new file mode 100644 index 0000000..75f9bb3 --- /dev/null +++ b/poke/src/ty.rs @@ -0,0 +1,51 @@ +//! Pokemon type + +/// Pokemon type +#[derive(PartialEq, Eq, Clone, Copy, Hash, Debug)] +#[derive(serde::Serialize, serde::Deserialize)] +pub enum Type { + Normal = 0x00, + Fighting = 0x01, + Flying = 0x02, + Poison = 0x03, + Ground = 0x04, + Rock = 0x05, + Bug = 0x06, + Ghost = 0x07, + Steel = 0x08, + Mystery = 0x09, + Fire = 0x0a, + Water = 0x0b, + Grass = 0x0c, + Electric = 0x0d, + Psychic = 0x0e, + Ice = 0x0f, + Dragon = 0x10, + Dark = 0x11, +} + +impl Type { + /// Returns the `C` name of this type + pub fn c_name(&self) -> &'static str { + match self { + Type::Normal => "NORMAL", + Type::Fighting => "FIGHTING", + Type::Flying => "FLYING", + Type::Poison => "POISON", + Type::Ground => "GROUND", + Type::Rock => "ROCK", + Type::Bug => "BUG", + Type::Ghost => "GHOST", + Type::Steel => "STEEL", + Type::Mystery => "MYSTERY", + Type::Fire => "FIRE", + Type::Water => "WATER", + Type::Grass => "GRASS", + Type::Electric => "ELECTRIC", + Type::Psychic => "PSYCHIC", + Type::Ice => "ICE", + Type::Dragon => "DRAGON", + Type::Dark => "DARK", + } + } +} diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..f0b76b3 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,55 @@ +# We're fine with unstable features +unstable_features = true + +binop_separator = "Back" +blank_lines_lower_bound = 0 +blank_lines_upper_bound = 2 +brace_style = "SameLineWhere" +combine_control_expr = true +comment_width = 120 +condense_wildcard_suffixes = true +control_brace_style = "AlwaysSameLine" +empty_item_single_line = true +enum_discrim_align_threshold = 100 +error_on_line_overflow = false +error_on_unformatted = false +fn_args_layout = "Compressed" +fn_single_line = false +force_explicit_abi = true +force_multiline_blocks = false +format_code_in_doc_comments = false +format_macro_bodies = true +format_macro_matchers = true +format_strings = true +hard_tabs = true +imports_granularity = "Crate" +imports_indent = "Block" +imports_layout = "Mixed" +indent_style = "Block" +inline_attribute_width = 0 +license_template_path = "" +match_arm_blocks = true +match_block_trailing_comma = true +max_width = 120 +merge_derives = false +newline_style = "Unix" +normalize_comments = false +normalize_doc_attributes = false +overflow_delimited_expr = true +remove_nested_parens = true +reorder_impl_items = true +reorder_imports = true +reorder_modules = true +space_after_colon = true +space_before_colon = false +spaces_around_ranges = false +struct_field_align_threshold = 20 +struct_lit_single_line = true +trailing_comma = "Vertical" +trailing_semicolon = true +type_punctuation_density = "Wide" +use_field_init_shorthand = true +use_small_heuristics = "Default" +use_try_shorthand = true +where_single_line = false +wrap_comments = true