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