gameServer/Votes.hs
changeset 10786 712283ed86e0
parent 10464 d08611b52000
child 10787 50a4cdeedb44
--- a/gameServer/Votes.hs	Mon Jan 12 08:20:20 2015 -0500
+++ b/gameServer/Votes.hs	Tue Jan 13 23:37:07 2015 +0300
@@ -49,7 +49,7 @@
                 return [AnswerClients [sendChan cl] ["CHAT", "[server]", loc "You already have voted"]]
             else
                 actOnVoting $ voting{votes = (uid, vote):votes voting}
-      
+
     where
     actOnVoting :: Voting -> Reader (ClientIndex, IRnC) [Action]
     actOnVoting vt = do
@@ -107,8 +107,24 @@
         chans <- roomClientsChans
         let modifyGameInfo f room  = room{gameInfo = fmap f $ gameInfo room}
         return [ModifyRoom (modifyGameInfo $ \g -> g{isPaused = not $ isPaused g}),
-                AnswerClients chans ["CHAT", "[server]", "Pause toggled"],
+                AnswerClients chans ["CHAT", "[server]", loc "Pause toggled"],
                 AnswerClients chans ["EM", toEngineMsg "I"]]
+    act (VoteNewSeed) =
+        return [SetRandomSeed]
+    act (VoteHedgehogsPerTeam h) = do
+        rm <- thisRoom
+        chans <- roomClientsChans
+        let answers = concatMap (\t -> 
+                [ModifyRoom $ modifyTeam t{hhnum = h}
+                , AnswerClients chans ["HHNUM", teamname t, showB h]]
+                )
+                $
+                if isJust $ gameInfo rm then
+                    teamsAtStart . fromJust . gameInfo $ rm 
+                else
+                    teams rm
+
+        return $ ModifyRoom (\r -> r{defaultHedgehogsNumber = h}) : answers
 
 
 startVote :: VoteType -> Reader (ClientIndex, IRnC) [Action]
@@ -154,3 +170,5 @@
 voteInfo (VoteKick n) = B.concat [loc "kick", " ", n]
 voteInfo (VoteMap n) = B.concat [loc "map", " ", n]
 voteInfo (VotePause) = B.concat [loc "pause"]
+voteInfo (VoteNewSeed) = B.concat [loc "new seed"]
+voteInfo (VoteHedgehogsPerTeam i) = B.concat [loc "number of hedgehogs in team", " ", showB i]