add Default trait to player object
This commit is contained in:
parent
b1f081dc86
commit
f813c1681e
19
Player.rs
19
Player.rs
|
@ -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
|
||||||
}
|
}
|
Loading…
Reference in New Issue