gameServer/HWProtoInRoomState.hs
changeset 13696 d732ca5dcab9
parent 13673 1aa5e884326a
child 13697 7f174e7285e5
equal deleted inserted replaced
13695:e529a34872f9 13696:d732ca5dcab9
   397 
   397 
   398 handleCmd_inRoom ["MAXTEAMS", n] = roomAdminOnly $ do
   398 handleCmd_inRoom ["MAXTEAMS", n] = roomAdminOnly $ do
   399     cl <- thisClient
   399     cl <- thisClient
   400     let m = readInt_ n
   400     let m = readInt_ n
   401     if m < 2 || m > cMaxTeams then
   401     if m < 2 || m > cMaxTeams then
   402         return [AnswerClients [sendChan cl] ["CHAT", "[server]", loc "/maxteams: specify number from 2 to 8"]]
   402         return [AnswerClients [sendChan cl] ["CHAT", nickServer, loc "/maxteams: specify number from 2 to 8"]]
   403     else
   403     else
   404         return [ModifyRoom (\r -> r{teamsNumberLimit = m})]
   404         return [ModifyRoom (\r -> r{teamsNumberLimit = m})]
   405 
   405 
   406 handleCmd_inRoom ["FIX"] = serverAdminOnly $
   406 handleCmd_inRoom ["FIX"] = serverAdminOnly $
   407     return [ModifyRoom (\r -> r{isSpecial = True})]
   407     return [ModifyRoom (\r -> r{isSpecial = True})]
   423 
   423 
   424 
   424 
   425 handleCmd_inRoom ["CALLVOTE"] = do
   425 handleCmd_inRoom ["CALLVOTE"] = do
   426     cl <- thisClient
   426     cl <- thisClient
   427     return [AnswerClients [sendChan cl]
   427     return [AnswerClients [sendChan cl]
   428         ["CHAT", "[server]", loc "Available callvote commands: kick <nickname>, map <name>, pause, newseed, hedgehogs"]
   428         ["CHAT", nickServer, loc "Available callvote commands: kick <nickname>, map <name>, pause, newseed, hedgehogs"]
   429         ]
   429         ]
   430 
   430 
   431 handleCmd_inRoom ["CALLVOTE", "KICK"] = do
   431 handleCmd_inRoom ["CALLVOTE", "KICK"] = do
   432     cl <- thisClient
   432     cl <- thisClient
   433     return [AnswerClients [sendChan cl] ["CHAT", "[server]", loc "/callvote kick: You need to specify a nickname."]]
   433     return [AnswerClients [sendChan cl] ["CHAT", nickServer, loc "/callvote kick: You need to specify a nickname."]]
   434 
   434 
   435 handleCmd_inRoom ["CALLVOTE", "KICK", nickname] = do
   435 handleCmd_inRoom ["CALLVOTE", "KICK", nickname] = do
   436     (thisClientId, rnc) <- ask
   436     (thisClientId, rnc) <- ask
   437     cl <- thisClient
   437     cl <- thisClient
   438     rm <- thisRoom
   438     rm <- thisRoom
   444         return []
   444         return []
   445         else
   445         else
   446         if isJust maybeClientId && sameRoom then
   446         if isJust maybeClientId && sameRoom then
   447             startVote $ VoteKick nickname
   447             startVote $ VoteKick nickname
   448             else
   448             else
   449             return [AnswerClients [sendChan cl] ["CHAT", "[server]", loc "/callvote kick: No such user!"]]
   449             return [AnswerClients [sendChan cl] ["CHAT", nickServer, loc "/callvote kick: No such user!"]]
   450 
   450 
   451 
   451 
   452 handleCmd_inRoom ["CALLVOTE", "MAP"] = do
   452 handleCmd_inRoom ["CALLVOTE", "MAP"] = do
   453     cl <- thisClient
   453     cl <- thisClient
   454     s <- liftM (Map.keys . roomSaves) thisRoom
   454     s <- liftM (Map.keys . roomSaves) thisRoom
   455     return [AnswerClients [sendChan cl] ["CHAT", "[server]", B.concat ["callvote map: ", B.intercalate ", " s]]]
   455     return [AnswerClients [sendChan cl] ["CHAT", nickServer, B.concat ["callvote map: ", B.intercalate ", " s]]]
   456 
   456 
   457 
   457 
   458 handleCmd_inRoom ["CALLVOTE", "MAP", roomSave] = do
   458 handleCmd_inRoom ["CALLVOTE", "MAP", roomSave] = do
   459     cl <- thisClient
   459     cl <- thisClient
   460     rm <- thisRoom
   460     rm <- thisRoom
   461 
   461 
   462     if Map.member roomSave $ roomSaves rm then
   462     if Map.member roomSave $ roomSaves rm then
   463         startVote $ VoteMap roomSave
   463         startVote $ VoteMap roomSave
   464         else
   464         else
   465         return [AnswerClients [sendChan cl] ["CHAT", "[server]", loc "/callvote map: No such map!"]]
   465         return [AnswerClients [sendChan cl] ["CHAT", nickServer, loc "/callvote map: No such map!"]]
   466 
   466 
   467 
   467 
   468 handleCmd_inRoom ["CALLVOTE", "PAUSE"] = do
   468 handleCmd_inRoom ["CALLVOTE", "PAUSE"] = do
   469     cl <- thisClient
   469     cl <- thisClient
   470     rm <- thisRoom
   470     rm <- thisRoom
   471 
   471 
   472     if isJust $ gameInfo rm then
   472     if isJust $ gameInfo rm then
   473         startVote VotePause
   473         startVote VotePause
   474         else 
   474         else 
   475         return [AnswerClients [sendChan cl] ["CHAT", "[server]", loc "/callvote pause: No game in progress!"]]
   475         return [AnswerClients [sendChan cl] ["CHAT", nickServer, loc "/callvote pause: No game in progress!"]]
   476 
   476 
   477 
   477 
   478 handleCmd_inRoom ["CALLVOTE", "NEWSEED"] = do
   478 handleCmd_inRoom ["CALLVOTE", "NEWSEED"] = do
   479     startVote VoteNewSeed
   479     startVote VoteNewSeed
   480 
   480 
   481 
   481 
   482 handleCmd_inRoom ["CALLVOTE", "HEDGEHOGS"] = do
   482 handleCmd_inRoom ["CALLVOTE", "HEDGEHOGS"] = do
   483     cl <- thisClient
   483     cl <- thisClient
   484     return [AnswerClients [sendChan cl] ["CHAT", "[server]", loc "/callvote hedgehogs: Specify number from 1 to 8."]]
   484     return [AnswerClients [sendChan cl] ["CHAT", nickServer, loc "/callvote hedgehogs: Specify number from 1 to 8."]]
   485 
   485 
   486 
   486 
   487 handleCmd_inRoom ["CALLVOTE", "HEDGEHOGS", hhs] = do
   487 handleCmd_inRoom ["CALLVOTE", "HEDGEHOGS", hhs] = do
   488     cl <- thisClient
   488     cl <- thisClient
   489     let h = readInt_ hhs
   489     let h = readInt_ hhs
   490 
   490 
   491     if h > 0 && h <= cHogsPerTeam then
   491     if h > 0 && h <= cHogsPerTeam then
   492         startVote $ VoteHedgehogsPerTeam h
   492         startVote $ VoteHedgehogsPerTeam h
   493         else
   493         else
   494         return [AnswerClients [sendChan cl] ["CHAT", "[server]", loc "/callvote hedgehogs: Specify number from 1 to 8."]]
   494         return [AnswerClients [sendChan cl] ["CHAT", nickServer, loc "/callvote hedgehogs: Specify number from 1 to 8."]]
   495 
   495 
   496 
   496 
   497 handleCmd_inRoom ("VOTE" : m : p) = do
   497 handleCmd_inRoom ("VOTE" : m : p) = do
   498     cl <- thisClient
   498     cl <- thisClient
   499     let b = if m == "YES" then Just True else if m == "NO" then Just False else Nothing
   499     let b = if m == "YES" then Just True else if m == "NO" then Just False else Nothing
   500     if isJust b then
   500     if isJust b then
   501         voted (p == ["FORCE"]) (fromJust b)
   501         voted (p == ["FORCE"]) (fromJust b)
   502     else
   502     else
   503         return [AnswerClients [sendChan cl] ["CHAT", "[server]",
   503         return [AnswerClients [sendChan cl] ["CHAT", nickServer,
   504             if (p == ["FORCE"]) then
   504             if (p == ["FORCE"]) then
   505                 loc "/force: Please use 'yes' or 'no'."
   505                 loc "/force: Please use 'yes' or 'no'."
   506             else
   506             else
   507                 loc "/vote: Please use 'yes' or 'no'."
   507                 loc "/vote: Please use 'yes' or 'no'."
   508         ]]
   508         ]]