gameServer2/src/server/actions.rs
changeset 13480 fb37745c5bca
parent 13478 d79795acaa73
child 13520 1ee192f13456
--- a/gameServer2/src/server/actions.rs	Mon Jul 09 19:39:15 2018 +0300
+++ b/gameServer2/src/server/actions.rs	Mon Jul 09 19:41:26 2018 +0300
@@ -7,7 +7,7 @@
     server::HWServer,
     room::{GameInfo},
     client::HWClient,
-    coretypes::{ClientId, RoomId, VoteType},
+    coretypes::{ClientId, RoomId, GameCfg, VoteType},
     room::HWRoom,
     handlers
 };
@@ -18,6 +18,7 @@
     server_chat
 };
 use utils::to_engine_msg;
+use rand::{thread_rng, Rng, distributions::Uniform};
 
 pub enum Destination {
     ToId(ClientId),
@@ -381,7 +382,7 @@
                     unimplemented!();
                 },
                 VoteType::Pause => {
-                    if let Some(ref mut info) = server.room(client_id).unwrap().game_info {
+                    if let Some(ref mut info) = server.rooms[room_id].game_info {
                         info.is_paused = !info.is_paused;
                         actions.push(server_chat("Pause toggled.")
                             .send_all().in_room(room_id).action());
@@ -390,7 +391,10 @@
                     }
                 },
                 VoteType::NewSeed => {
-                    unimplemented!();
+                    let seed = thread_rng().gen_range(0, 1_000_000_000).to_string();
+                    let cfg = GameCfg::Seed(seed);
+                    actions.push(cfg.to_server_msg().send_all().in_room(room_id).action());
+                    server.rooms[room_id].set_config(cfg);
                 },
                 VoteType::HedgehogsPerTeam(number) => {
                     let r = &mut server.rooms[room_id];