#[derive(Debug)] pub enum Race { Griffin, Catte } impl Default for Race { fn default() -> Self { Race::Catte } } #[derive(Debug)] struct ResearchItem { levels: u8, points: u16 } impl Default for ResearchItem { fn default() -> Self { ResearchItem{ levels: 1, points: 0 } } } #[derive(Default,Debug)] struct Research { weapons: ResearchItem, banking: ResearchItem, manufactoring: ResearchItem, terraforming: ResearchItem, hyperspace: ResearchItem, experimentation: ResearchItem, scanning: ResearchItem } #[derive(Debug)] pub struct Player { name: String, color: (u8, u8, u8), race: Race, research: Research } impl Default for Player { fn default() -> Self { Player{ name: String::default(), //Color: (rand::thread_rng().gen(), rand::thread_rng().gen(), rand::thread_rng().gen()), color: (0,0,0), race: Race::default(), research: Research::default() } } } impl Player { pub fn new(name: String, color: Option<(u8, u8, u8)>, race: Option) -> Player { Player { name: name, color: color.unwrap_or(Player::default().color), race: race.unwrap_or(Player::default().race), research: Research::default() } } }