Randomize starting player, fixes #1
This commit is contained in:
parent
f2dab8a71c
commit
998d27764d
@ -4,7 +4,7 @@ mod cards;
|
|||||||
use async_std::{prelude::*, sync::RwLock};
|
use async_std::{prelude::*, sync::RwLock};
|
||||||
use cards::*;
|
use cards::*;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use rand::{seq::SliceRandom, thread_rng};
|
use rand::{seq::SliceRandom, Rng, thread_rng};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{collections::HashMap, sync::Arc};
|
use std::{collections::HashMap, sync::Arc};
|
||||||
use tide::{Body, Redirect, Request, Response};
|
use tide::{Body, Redirect, Request, Response};
|
||||||
@ -255,6 +255,10 @@ impl Game {
|
|||||||
GameState::Setup => {
|
GameState::Setup => {
|
||||||
self.state = GameState::InProgress;
|
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() {
|
for p in self.players.iter_mut() {
|
||||||
(*p).discard_pile = self.setup.deck.clone();
|
(*p).discard_pile = self.setup.deck.clone();
|
||||||
p.draw(5);
|
p.draw(5);
|
||||||
|
Loading…
Reference in New Issue
Block a user