|  | @@ -28,6 +28,7 @@ pub struct GameLobby {
 | 
	
		
			
				|  |  |      connected_players: BTreeMap<String, Addr<GameConnection>>,
 | 
	
		
			
				|  |  |      game_id: String,
 | 
	
		
			
				|  |  |      game: game::Game,
 | 
	
		
			
				|  |  | +    player_points: BTreeMap<String, i64>,
 | 
	
		
			
				|  |  |      waiting_players: BTreeMap<String, Addr<GameConnection>>,
 | 
	
		
			
				|  |  |      ready_players: Vec<String>,
 | 
	
		
			
				|  |  |      lobby_state: LobbyState,
 | 
	
	
		
			
				|  | @@ -111,8 +112,14 @@ impl Handler<SubmitGuessMsg> for GameLobby {
 | 
	
		
			
				|  |  |      fn handle(&mut self, sgm: SubmitGuessMsg, _ctx: &mut Self::Context) -> Self::Result {
 | 
	
		
			
				|  |  |          self.game.submit_guess(&sgm.nick, sgm.guesses);
 | 
	
		
			
				|  |  |          if self.game.all_guesses_submitted() {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              self.set_state(LobbyState::Revealing);
 | 
	
		
			
				|  |  |              let results = self.create_result_data();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            for (nick, pts) in &results.point_list {
 | 
	
		
			
				|  |  | +                self.add_player_points(nick, *pts);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              self.broadcast_results(results);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              self.game.next_state();
 | 
	
	
		
			
				|  | @@ -128,6 +135,7 @@ impl GameLobby {
 | 
	
		
			
				|  |  |              connected_players: BTreeMap::new(),
 | 
	
		
			
				|  |  |              game_id: gi,
 | 
	
		
			
				|  |  |              game: game::Game::new(),
 | 
	
		
			
				|  |  | +            player_points: BTreeMap::new(),
 | 
	
		
			
				|  |  |              waiting_players: BTreeMap::new(),
 | 
	
		
			
				|  |  |              ready_players: Vec::new(),
 | 
	
		
			
				|  |  |              lobby_state: LobbyState::Starting,
 | 
	
	
		
			
				|  | @@ -137,7 +145,6 @@ impl GameLobby {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      fn set_state(&mut self, new_state: LobbyState) {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          match new_state {
 | 
	
		
			
				|  |  |              LobbyState::Starting => {
 | 
	
		
			
				|  |  |                  for (nick, _addr) in &self.waiting_players {
 | 
	
	
		
			
				|  | @@ -149,7 +156,6 @@ impl GameLobby {
 | 
	
		
			
				|  |  |              LobbyState::Creating => {
 | 
	
		
			
				|  |  |                  let s = &mut self.shuffler;
 | 
	
		
			
				|  |  |                  let ld = &self.letter_distribution;
 | 
	
		
			
				|  |  | -                let mut index = 0;
 | 
	
		
			
				|  |  |                  self.game.start_round(|| s.get(), || ld.get(4, 6));
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  |              _ => {}
 | 
	
	
		
			
				|  | @@ -157,6 +163,18 @@ impl GameLobby {
 | 
	
		
			
				|  |  |          self.lobby_state = new_state;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    pub fn get_player_points(&self, nick: &str) -> i64 {
 | 
	
		
			
				|  |  | +        *self.player_points.get(nick).unwrap_or(&0)
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    pub fn add_player_points(&mut self, nick: &str, points: i64) {
 | 
	
		
			
				|  |  | +        let entry = self.player_points.get_mut(nick);
 | 
	
		
			
				|  |  | +        match entry {
 | 
	
		
			
				|  |  | +            Some(x) => *x += points,
 | 
	
		
			
				|  |  | +            None => { self.player_points.insert(nick.to_owned(), points); },
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      pub fn send_game_to_all(&self) {
 | 
	
		
			
				|  |  |          for (nick, player) in &self.connected_players {
 | 
	
		
			
				|  |  |              let game_state = self.create_opaque_message(nick);
 | 
	
	
		
			
				|  | @@ -165,7 +183,7 @@ impl GameLobby {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      pub fn create_result_data(&self) -> RoundResultData {
 | 
	
		
			
				|  |  | -        let results_table = self.game.create_results();
 | 
	
		
			
				|  |  | +        let (guesses, point_list) = self.game.create_results();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          let words = self.game.players.iter()
 | 
	
		
			
				|  |  |                          .map(|p| p.submitted_word.clone().unwrap())
 | 
	
	
		
			
				|  | @@ -179,13 +197,12 @@ impl GameLobby {
 | 
	
		
			
				|  |  |                          .zip(questions.iter().map(|x| x.clone()))
 | 
	
		
			
				|  |  |                          .collect::<Vec<_>>();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        let guesses = self.game.create_results();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          RoundResultData {
 | 
	
		
			
				|  |  |              words,
 | 
	
		
			
				|  |  |              questions,
 | 
	
		
			
				|  |  |              solutions,
 | 
	
		
			
				|  |  | -            guesses
 | 
	
		
			
				|  |  | +            guesses,
 | 
	
		
			
				|  |  | +            point_list
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -201,7 +218,7 @@ impl GameLobby {
 | 
	
		
			
				|  |  |                          .find(|p| p.nick == nick);
 | 
	
		
			
				|  |  |          GameData {
 | 
	
		
			
				|  |  |              players: self.game.players.iter()
 | 
	
		
			
				|  |  | -                        .map(|p| websocket::PlayerData{ nick: p.nick.clone(), points: 0 })
 | 
	
		
			
				|  |  | +                        .map(|p| websocket::PlayerData{ nick: p.nick.clone(), points: self.get_player_points(&p.nick) })
 | 
	
		
			
				|  |  |                          .collect::<Vec<_>>(),
 | 
	
		
			
				|  |  |              state_data:
 | 
	
		
			
				|  |  |                  match self.game.state {
 |