gameServer/HWProtoInRoomState.hs
changeset 10040 4ac87acbaed9
parent 10017 de822cd3df3a
parent 10039 58cf89284115
child 10057 795f5f918c8c
equal deleted inserted replaced
10019:c00db97a668f 10040:4ac87acbaed9
    12 import Actions
    12 import Actions
    13 import Utils
    13 import Utils
    14 import HandlerUtils
    14 import HandlerUtils
    15 import RoomsAndClients
    15 import RoomsAndClients
    16 import EngineInteraction
    16 import EngineInteraction
    17 
    17 import Votes
    18 
    18 
    19 startGame :: Reader (ClientIndex, IRnC) [Action]
    19 startGame :: Reader (ClientIndex, IRnC) [Action]
    20 startGame = do
    20 startGame = do
    21     (ci, rnc) <- ask
    21     (ci, rnc) <- ask
    22     cl <- thisClient
    22     cl <- thisClient
   395 handleCmd_inRoom ["GREETING", msg] = do
   395 handleCmd_inRoom ["GREETING", msg] = do
   396     cl <- thisClient
   396     cl <- thisClient
   397     rm <- thisRoom
   397     rm <- thisRoom
   398     return [ModifyRoom (\r -> r{greeting = msg}) | isAdministrator cl || (isMaster cl && (not $ isSpecial rm))]
   398     return [ModifyRoom (\r -> r{greeting = msg}) | isAdministrator cl || (isMaster cl && (not $ isSpecial rm))]
   399 
   399 
       
   400 
       
   401 handleCmd_inRoom ["CALLVOTE"] = do
       
   402     cl <- thisClient
       
   403     return [AnswerClients [sendChan cl] ["CHAT", "[server]", "Available callvote commands: kick <nickname>"]]
       
   404 
       
   405 handleCmd_inRoom ["CALLVOTE", "KICK"] = do
       
   406     cl <- thisClient
       
   407     return [AnswerClients [sendChan cl] ["CHAT", "[server]", "callvote kick: specify nickname"]]
       
   408 
       
   409 handleCmd_inRoom ["CALLVOTE", "KICK", nickname] = do
       
   410     (thisClientId, rnc) <- ask
       
   411     cl <- thisClient
       
   412     maybeClientId <- clientByNick nickname
       
   413     let kickId = fromJust maybeClientId
       
   414     let sameRoom = clientRoom rnc thisClientId == clientRoom rnc kickId
       
   415 
       
   416     if isJust maybeClientId && sameRoom then
       
   417         startVote $ VoteKick nickname
       
   418         else
       
   419         return [AnswerClients [sendChan cl] ["CHAT", "[server]", "callvote kick: no such user"]]
       
   420 
       
   421 handleCmd_inRoom ["VOTE", m] = do
       
   422     cl <- thisClient
       
   423     let b = if m == "YES" then Just True else if m == "NO" then Just False else Nothing
       
   424     if isJust b then
       
   425         voted (clUID cl) (fromJust b)
       
   426         else
       
   427         return [AnswerClients [sendChan cl] ["CHAT", "[server]", "vote: 'yes' or 'no'"]]
       
   428 
   400 handleCmd_inRoom ["LIST"] = return [] -- for old clients (<= 0.9.17)
   429 handleCmd_inRoom ["LIST"] = return [] -- for old clients (<= 0.9.17)
   401 
   430 
   402 handleCmd_inRoom (s:_) = return [ProtocolError $ "Incorrect command '" `B.append` s `B.append` "' (state: in room)"]
   431 handleCmd_inRoom (s:_) = return [ProtocolError $ "Incorrect command '" `B.append` s `B.append` "' (state: in room)"]
   403 
   432 
   404 handleCmd_inRoom [] = return [ProtocolError "Empty command (state: in room)"]
   433 handleCmd_inRoom [] = return [ProtocolError "Empty command (state: in room)"]