From 5871f3129bd5cde9dfd497f64869c5c275b8ac9b Mon Sep 17 00:00:00 2001 From: ntr Date: Fri, 10 Jan 2020 12:21:37 +1000 Subject: [PATCH] fix tutorial construct order bug --- core/src/game.rs | 3 +-- core/src/player.rs | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/game.rs b/core/src/game.rs index 42e14f8b..5364013b 100644 --- a/core/src/game.rs +++ b/core/src/game.rs @@ -104,7 +104,6 @@ impl Game { // let player_description = player.constructs.iter().map(|c| c.name.clone()).collect::>().join(", "); // self.log.push(format!("{:} has joined the game. [{:}]", player.name, player_description)); - player.constructs.sort_unstable_by_key(|c| c.id); self.players.push(player); Ok(self) @@ -1201,7 +1200,7 @@ mod tests { .player_add(y_player).unwrap(); game = game.start(); - + assert!(game.players[0].constructs[0].skill_on_cd(Skill::Ruin).is_some()); assert!(game.players[1].constructs[0].skill_on_cd(Skill::Ruin).is_none()); } diff --git a/core/src/player.rs b/core/src/player.rs index 21556a0b..0b686a60 100644 --- a/core/src/player.rs +++ b/core/src/player.rs @@ -65,7 +65,9 @@ pub struct Player { } impl Player { - pub fn new(account: Uuid, img: Option, name: &String, constructs: Vec) -> Player { + pub fn new(account: Uuid, img: Option, name: &String, mut constructs: Vec) -> Player { + constructs.sort_unstable_by_key(|c| c.id); + Player { id: account, img,