|
|
@ -1,6 +1,9 @@ |
|
|
|
use std::io::Read; |
|
|
|
use std::io::Read; |
|
|
|
|
|
|
|
|
|
|
|
use crate::general::{Ability, BinaryGender, Gender, Language, Move, Nature, PokeBall, Species}; |
|
|
|
use crate::general::{ |
|
|
|
|
|
|
|
Ability, BinaryGender, EVs, Gender, IVs, Language, Move, MoveSet, Nature, PokeBall, Species, |
|
|
|
|
|
|
|
StatSpread, StatusCondition, Trainer, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
pub mod gen5; |
|
|
|
pub mod gen5; |
|
|
|
|
|
|
|
|
|
|
@ -18,6 +21,33 @@ pub trait PKM { |
|
|
|
fn ot(&self) -> &Trainer; |
|
|
|
fn ot(&self) -> &Trainer; |
|
|
|
|
|
|
|
|
|
|
|
fn gain_xp(&mut self, xp: u32) -> Vec<Progression>; |
|
|
|
fn gain_xp(&mut self, xp: u32) -> Vec<Progression>; |
|
|
|
|
|
|
|
fn defeated(&mut self, other: Species); |
|
|
|
|
|
|
|
fn use_item(&mut self, item: Item) -> Result<(), ItemUseError>; |
|
|
|
|
|
|
|
fn damage(&mut self, hp: u16); |
|
|
|
|
|
|
|
fn apply_status(&mut self, status: StatusCondition); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn species(&self) -> Species; |
|
|
|
|
|
|
|
fn ivs(&self) -> IVs; |
|
|
|
|
|
|
|
fn evs(&self) -> EVs; |
|
|
|
|
|
|
|
fn is_shiny(&self) -> bool; |
|
|
|
|
|
|
|
fn nickname(&self) -> Option<String>; |
|
|
|
|
|
|
|
fn held_item(&self) -> Option<Item>; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn current_hp(&self) -> u16; |
|
|
|
|
|
|
|
fn max_hp(&self) -> u16; |
|
|
|
|
|
|
|
fn effective_base_stats(&self) -> StatSpread<u16>; |
|
|
|
|
|
|
|
fn move_set(&self) -> MoveSet; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn display_name(&self) -> String { |
|
|
|
|
|
|
|
self.nickname() |
|
|
|
|
|
|
|
.unwrap_or_else(|| format!("{:?}", self.species())) // todo: multi lang
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
fn fainted(&self) -> bool { |
|
|
|
|
|
|
|
self.current_hp() == 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
fn health(&self) -> f32 { |
|
|
|
|
|
|
|
self.current_hp() as f32 / self.max_hp() as f32 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub enum Progression { |
|
|
|
pub enum Progression { |
|
|
@ -35,70 +65,11 @@ where |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// pub trait Pokemon {
|
|
|
|
impl<P> From<P> for Pokemon<P> { |
|
|
|
// // main
|
|
|
|
fn from(value: P) -> Self { |
|
|
|
// fn species(&self) -> Species;
|
|
|
|
Self { |
|
|
|
// fn nickname(&self) -> String;
|
|
|
|
pkm: value, |
|
|
|
// fn held_item(&self) -> Item;
|
|
|
|
pending_progressions: Vec::new(), |
|
|
|
// fn gender(&self) -> Gender;
|
|
|
|
} |
|
|
|
// fn nature(&self) -> Nature;
|
|
|
|
} |
|
|
|
// fn ability(&self) -> Ability;
|
|
|
|
} |
|
|
|
// fn form(&self) -> PokemonForm;
|
|
|
|
|
|
|
|
// fn is_egg(&self) -> bool;
|
|
|
|
|
|
|
|
// fn is_nicknamed(&self) -> bool;
|
|
|
|
|
|
|
|
// fn exp(&self) -> u32;
|
|
|
|
|
|
|
|
// fn ot_name(&self) -> String;
|
|
|
|
|
|
|
|
// fn ot_gender(&self) -> BinaryGender;
|
|
|
|
|
|
|
|
// fn level(&self) -> u8;
|
|
|
|
|
|
|
|
// fn met_level(&self) -> u8;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // internal
|
|
|
|
|
|
|
|
// fn tid16(&self) -> u16;
|
|
|
|
|
|
|
|
// fn sid16(&self) -> u16;
|
|
|
|
|
|
|
|
// fn id32(&self) -> u32;
|
|
|
|
|
|
|
|
// fn ball(&self) -> PokeBall;
|
|
|
|
|
|
|
|
// fn current_friendship(&self) -> i32;
|
|
|
|
|
|
|
|
// fn version(&self) -> i32;
|
|
|
|
|
|
|
|
// fn pokerus_strain(&self) -> i32;
|
|
|
|
|
|
|
|
// fn pokerus_days(&self) -> i32;
|
|
|
|
|
|
|
|
// fn encryption_constant(&self) -> u32;
|
|
|
|
|
|
|
|
// fn pid(&self) -> u32;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // misc
|
|
|
|
|
|
|
|
// fn language(&self) -> Language;
|
|
|
|
|
|
|
|
// fn is_fateful_encounter(&self) -> bool;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // battle
|
|
|
|
|
|
|
|
// fn move1(&self) -> u16;
|
|
|
|
|
|
|
|
// fn move2(&self) -> u16;
|
|
|
|
|
|
|
|
// fn move3(&self) -> u16;
|
|
|
|
|
|
|
|
// fn move4(&self) -> u16;
|
|
|
|
|
|
|
|
// fn pp_move1(&self) -> u8;
|
|
|
|
|
|
|
|
// fn pp_move2(&self) -> u8;
|
|
|
|
|
|
|
|
// fn pp_move3(&self) -> u8;
|
|
|
|
|
|
|
|
// fn pp_move4(&self) -> u8;
|
|
|
|
|
|
|
|
// fn pp_up_move1(&self) -> u8;
|
|
|
|
|
|
|
|
// fn pp_up_move2(&self) -> u8;
|
|
|
|
|
|
|
|
// fn pp_up_move3(&self) -> u8;
|
|
|
|
|
|
|
|
// fn pp_up_move4(&self) -> u8;
|
|
|
|
|
|
|
|
// fn ev_hp(&self) -> u8;
|
|
|
|
|
|
|
|
// fn ev_attack(&self) -> u8;
|
|
|
|
|
|
|
|
// fn ev_defense(&self) -> u8;
|
|
|
|
|
|
|
|
// fn ev_speed(&self) -> u8;
|
|
|
|
|
|
|
|
// fn ev_sp_attack(&self) -> u8;
|
|
|
|
|
|
|
|
// fn ev_sp_defense(&self) -> u8;
|
|
|
|
|
|
|
|
// fn iv_hp(&self) -> IV;
|
|
|
|
|
|
|
|
// fn iv_attack(&self) -> IV;
|
|
|
|
|
|
|
|
// fn iv_defense(&self) -> IV;
|
|
|
|
|
|
|
|
// fn iv_speed(&self) -> IV;
|
|
|
|
|
|
|
|
// fn iv_sp_attack(&self) -> IV;
|
|
|
|
|
|
|
|
// fn iv_sp_defense(&self) -> IV;
|
|
|
|
|
|
|
|
// fn status_condition(&self) -> StatusCondition;
|
|
|
|
|
|
|
|
// fn stat_hp_max(&self) -> u16;
|
|
|
|
|
|
|
|
// fn stat_hp_current(&self) -> u16;
|
|
|
|
|
|
|
|
// fn stat_attack(&self) -> u16;
|
|
|
|
|
|
|
|
// fn stat_defense(&self) -> u16;
|
|
|
|
|
|
|
|
// fn stat_speed(&self) -> u16;
|
|
|
|
|
|
|
|
// fn stat_sp_attack(&self) -> u16;
|
|
|
|
|
|
|
|
// fn stat_sp_defense(&self) -> u16;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|