--- a/gameServer/HWProtoInRoomState.hs Tue Jan 21 21:16:52 2014 +0100
+++ b/gameServer/HWProtoInRoomState.hs Wed Jan 22 01:11:13 2014 +0400
@@ -14,7 +14,7 @@
import HandlerUtils
import RoomsAndClients
import EngineInteraction
-
+import Votes
startGame :: Reader (ClientIndex, IRnC) [Action]
startGame = do
@@ -397,6 +397,35 @@
rm <- thisRoom
return [ModifyRoom (\r -> r{greeting = msg}) | isAdministrator cl || (isMaster cl && (not $ isSpecial rm))]
+
+handleCmd_inRoom ["CALLVOTE"] = do
+ cl <- thisClient
+ return [AnswerClients [sendChan cl] ["CHAT", "[server]", "Available callvote commands: kick <nickname>"]]
+
+handleCmd_inRoom ["CALLVOTE", "KICK"] = do
+ cl <- thisClient
+ return [AnswerClients [sendChan cl] ["CHAT", "[server]", "callvote kick: specify nickname"]]
+
+handleCmd_inRoom ["CALLVOTE", "KICK", nickname] = do
+ (thisClientId, rnc) <- ask
+ cl <- thisClient
+ maybeClientId <- clientByNick nickname
+ let kickId = fromJust maybeClientId
+ let sameRoom = clientRoom rnc thisClientId == clientRoom rnc kickId
+
+ if isJust maybeClientId && sameRoom then
+ startVote $ VoteKick nickname
+ else
+ return [AnswerClients [sendChan cl] ["CHAT", "[server]", "callvote kick: no such user"]]
+
+handleCmd_inRoom ["VOTE", m] = do
+ cl <- thisClient
+ let b = if m == "YES" then Just True else if m == "NO" then Just False else Nothing
+ if isJust b then
+ voted (clUID cl) (fromJust b)
+ else
+ return [AnswerClients [sendChan cl] ["CHAT", "[server]", "vote: 'yes' or 'no'"]]
+
handleCmd_inRoom ["LIST"] = return [] -- for old clients (<= 0.9.17)
handleCmd_inRoom (s:_) = return [ProtocolError $ "Incorrect command '" `B.append` s `B.append` "' (state: in room)"]