add czar rotation
This commit is contained in:
parent
4734227da0
commit
1ef29807b0
2 changed files with 27 additions and 1 deletions
|
@ -78,6 +78,10 @@ pub struct Game {
|
|||
pub white_discard: Vec<Arc<CardWhiteWithID>>,
|
||||
/// Black draw pile
|
||||
pub black: Vec<Arc<CardBlackWithID>>,
|
||||
|
||||
// TODO: do this better
|
||||
rotation: Vec<String>,
|
||||
rotation_index: usize,
|
||||
}
|
||||
|
||||
impl Game {
|
||||
|
@ -129,6 +133,8 @@ impl Game {
|
|||
judge_pile_meta: HashMap::new(),
|
||||
judge_pile: HashMap::new(),
|
||||
white_discard: vec![],
|
||||
rotation: vec![], // this gets set in create_user()
|
||||
rotation_index: 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,6 +239,23 @@ impl Game {
|
|||
.map(|pair| pair.1)
|
||||
.collect::<Vec<Arc<CardWhiteWithID>>>(),
|
||||
);
|
||||
|
||||
tracing::debug!("{:#?}", self.rotation);
|
||||
tracing::debug!("{:#?}", self.rotation_index);
|
||||
// Choose new czar
|
||||
if self.rotation_index == self.rotation.len() {
|
||||
self.rotation_index = 0;
|
||||
} else {
|
||||
self.rotation_index += 1;
|
||||
}
|
||||
tracing::debug!("{:#?}", self.rotation);
|
||||
tracing::debug!("{:#?}", self.rotation_index);
|
||||
self.czar = self
|
||||
.players
|
||||
.get(&self.rotation[self.rotation_index])
|
||||
.unwrap()
|
||||
.user
|
||||
.clone();
|
||||
}
|
||||
|
||||
/// Draw one black card at random from play deck.
|
||||
|
@ -279,5 +302,8 @@ impl Game {
|
|||
// Add player to game
|
||||
self.players
|
||||
.insert(user.read().unwrap().uuid.clone(), new_player);
|
||||
|
||||
// Add player to rotation
|
||||
self.rotation.push(user.read().unwrap().uuid.to_string());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,7 +235,7 @@ impl GameHandler {
|
|||
name: this_game.read().unwrap().name.clone(),
|
||||
host: this_game.read().unwrap().host.read().unwrap().name.clone(),
|
||||
players: players.clone(),
|
||||
czar: this_game.read().unwrap().host.read().unwrap().name.clone(),
|
||||
czar: this_game.read().unwrap().czar.read().unwrap().name.clone(),
|
||||
black: (
|
||||
this_game.read().unwrap().current_black.text.clone(),
|
||||
this_game.read().unwrap().current_black.pick,
|
||||
|
|
Loading…
Add table
Reference in a new issue