add Default trait to player object

This commit is contained in:
Daniel Løvbrøtte Olsen 2019-05-06 01:28:22 +02:00
parent b1f081dc86
commit f813c1681e
1 changed files with 18 additions and 3 deletions

View File

@ -2,14 +2,28 @@ enum Race {
Griffin, Griffin,
Catte Catte
} }
impl Default for Race {
fn default() -> Self {
Race::Catte
}
}
struct ResearchItem { struct ResearchItem {
levels: u8, levels: u8,
points: u16 points: u16
} }
impl Default for ResearchItem {
fn default() -> Self {
ResearchItem{
levels: 1,
points: 0
}
}
}
#[derive(Default)]
struct Research { struct Research {
Weapons: ResearchItem Weapons: ResearchItem,
Banking: ResearchItem, Banking: ResearchItem,
Manufactoring: ResearchItem, Manufactoring: ResearchItem,
Terraforming: ResearchItem, Terraforming: ResearchItem,
@ -18,9 +32,10 @@ struct Research {
Scanning: ResearchItem Scanning: ResearchItem
} }
#[derive(Default)]
struct Player { struct Player {
Name: String, Name: String,
Color: (u8, u8, u8), Color: (u8, u8, u8),
Race: Race, Race: Race,
Research Research: Research
} }