Randomize starting player, fixes #1

This commit is contained in:
Markus Wagner 2021-01-20 22:34:34 +01:00
parent f2dab8a71c
commit 998d27764d

View File

@ -4,7 +4,7 @@ mod cards;
use async_std::{prelude::*, sync::RwLock};
use cards::*;
use itertools::Itertools;
use rand::{seq::SliceRandom, thread_rng};
use rand::{seq::SliceRandom, Rng, thread_rng};
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, sync::Arc};
use tide::{Body, Redirect, Request, Response};
@ -255,6 +255,10 @@ impl Game {
GameState::Setup => {
self.state = GameState::InProgress;
if self.players.len() > 1 {
self.active_player = thread_rng().gen_range(0..self.players.len());
}
for p in self.players.iter_mut() {
(*p).discard_pile = self.setup.deck.clone();
p.draw(5);