add another player
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
mod player;
|
||||
pub mod player;
|
||||
mod star;
|
||||
mod carrier;
|
||||
|
||||
@@ -14,9 +14,8 @@ pub struct Game {
|
||||
}
|
||||
|
||||
impl Game {
|
||||
pub fn addPlayer(&mut self, name: String) {
|
||||
let mut player: Player = Player::default();
|
||||
player.name = name;
|
||||
pub fn addPlayer(&mut self, name: String, color: Option<(u8,u8,u8)>, race: Option<player::Race>) {
|
||||
let player = Player::new(name, color, race);
|
||||
self.players.push(player);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#[derive(Debug)]
|
||||
enum Race {
|
||||
pub enum Race {
|
||||
Griffin,
|
||||
Catte
|
||||
}
|
||||
@@ -36,7 +36,7 @@ struct Research {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Player {
|
||||
pub name: String,
|
||||
name: String,
|
||||
color: (u8, u8, u8),
|
||||
race: Race,
|
||||
research: Research
|
||||
@@ -51,4 +51,15 @@ impl Default for Player {
|
||||
research: Research::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Player {
|
||||
pub fn new(name: String, color: Option<(u8, u8, u8)>, race: Option<Race>) -> Player {
|
||||
Player {
|
||||
name: name,
|
||||
color: color.unwrap_or(Player::default().color),
|
||||
race: race.unwrap_or(Player::default().race),
|
||||
research: Research::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user