gameServer/HWProtoInRoomState.hs
changeset 10195 d1c23bb73346
parent 10194 7025bd3c3131
child 10212 5fb3bb2de9d2
equal deleted inserted replaced
10194:7025bd3c3131 10195:d1c23bb73346
   373     return [ModifyRoom (\r -> r{greeting = msg}) | isAdministrator cl || (isMaster cl && (not $ isSpecial rm))]
   373     return [ModifyRoom (\r -> r{greeting = msg}) | isAdministrator cl || (isMaster cl && (not $ isSpecial rm))]
   374 
   374 
   375 
   375 
   376 handleCmd_inRoom ["CALLVOTE"] = do
   376 handleCmd_inRoom ["CALLVOTE"] = do
   377     cl <- thisClient
   377     cl <- thisClient
   378     return [AnswerClients [sendChan cl] ["CHAT", "[server]", "Available callvote commands: kick <nickname>"]]
   378     return [AnswerClients [sendChan cl] ["CHAT", "[server]", "Available callvote commands: kick <nickname>, map <name>"]]
   379 
   379 
   380 handleCmd_inRoom ["CALLVOTE", "KICK"] = do
   380 handleCmd_inRoom ["CALLVOTE", "KICK"] = do
   381     cl <- thisClient
   381     cl <- thisClient
   382     return [AnswerClients [sendChan cl] ["CHAT", "[server]", "callvote kick: specify nickname"]]
   382     return [AnswerClients [sendChan cl] ["CHAT", "[server]", "callvote kick: specify nickname"]]
   383 
   383 
   395         if isJust maybeClientId && sameRoom then
   395         if isJust maybeClientId && sameRoom then
   396             startVote $ VoteKick nickname
   396             startVote $ VoteKick nickname
   397             else
   397             else
   398             return [AnswerClients [sendChan cl] ["CHAT", "[server]", "callvote kick: no such user"]]
   398             return [AnswerClients [sendChan cl] ["CHAT", "[server]", "callvote kick: no such user"]]
   399 
   399 
       
   400 
       
   401 handleCmd_inRoom ["CALLVOTE", "MAP", roomSave] = do
       
   402     cl <- thisClient
       
   403     rm <- thisRoom
       
   404 
       
   405     if Map.member roomSave $ roomSaves rm then
       
   406         startVote $ VoteMap roomSave
       
   407         else
       
   408         return [AnswerClients [sendChan cl] ["CHAT", "[server]", "callvote map: no such map"]]
       
   409 
       
   410 
   400 handleCmd_inRoom ["VOTE", m] = do
   411 handleCmd_inRoom ["VOTE", m] = do
   401     cl <- thisClient
   412     cl <- thisClient
   402     let b = if m == "YES" then Just True else if m == "NO" then Just False else Nothing
   413     let b = if m == "YES" then Just True else if m == "NO" then Just False else Nothing
   403     if isJust b then
   414     if isJust b then
   404         voted (fromJust b)
   415         voted (fromJust b)
   410     return [ModifyRoom $ \r -> r{roomSaves = Map.insert stateName (mapParams r, params r) (roomSaves r)}]
   421     return [ModifyRoom $ \r -> r{roomSaves = Map.insert stateName (mapParams r, params r) (roomSaves r)}]
   411 
   422 
   412 handleCmd_inRoom ["DELETE", stateName] = serverAdminOnly $ do
   423 handleCmd_inRoom ["DELETE", stateName] = serverAdminOnly $ do
   413     return [ModifyRoom $ \r -> r{roomSaves = Map.delete stateName (roomSaves r)}]
   424     return [ModifyRoom $ \r -> r{roomSaves = Map.delete stateName (roomSaves r)}]
   414 
   425 
   415 
   426 handleCmd_inRoom ["SAVEROOM", fileName] = serverAdminOnly $ do
       
   427     return [SaveRoom fileName]
       
   428 
       
   429 handleCmd_inRoom ["LOADROOM", fileName] = serverAdminOnly $ do
       
   430     return [LoadRoom fileName]
       
   431 
       
   432     
   416 handleCmd_inRoom ["LIST"] = return [] -- for old clients (<= 0.9.17)
   433 handleCmd_inRoom ["LIST"] = return [] -- for old clients (<= 0.9.17)
   417 
   434 
   418 handleCmd_inRoom (s:_) = return [ProtocolError $ "Incorrect command '" `B.append` s `B.append` "' (state: in room)"]
   435 handleCmd_inRoom (s:_) = return [ProtocolError $ "Incorrect command '" `B.append` s `B.append` "' (state: in room)"]
   419 
   436 
   420 handleCmd_inRoom [] = return [ProtocolError "Empty command (state: in room)"]
   437 handleCmd_inRoom [] = return [ProtocolError "Empty command (state: in room)"]