# HG changeset patch # User unc0rr # Date 1369169415 -14400 # Node ID d1478ce0f2989335232e46cf023deebb6c822fe3 # Parent e84d42a4311c9eb08c65b677d3260474310cb4d6# Parent 1ae1b6017b27d144bd9eb33be86a045d03f8db2f merge diff -r 1ae1b6017b27 -r d1478ce0f298 gameServer/Actions.hs --- a/gameServer/Actions.hs Tue May 21 16:14:36 2013 -0400 +++ b/gameServer/Actions.hs Wed May 22 00:50:15 2013 +0400 @@ -20,6 +20,7 @@ import Control.Exception import System.Process import Network.Socket +import System.Random ----------------------------- #if defined(OFFICIAL_SERVER) import OfficialServer.GameReplayStore @@ -615,6 +616,12 @@ processAction $ Warning versionsStats +processAction (Random chans items) = do + let i = if null items then ["heads", "tails"] else items + n <- io $ randomRIO (0, length i - 1) + processAction $ AnswerClients chans ["CHAT", "[random]", i !! n] + + #if defined(OFFICIAL_SERVER) processAction SaveReplay = do ri <- clientRoomA diff -r 1ae1b6017b27 -r d1478ce0f298 gameServer/CoreTypes.hs --- a/gameServer/CoreTypes.hs Tue May 21 16:14:36 2013 -0400 +++ b/gameServer/CoreTypes.hs Wed May 22 00:50:15 2013 +0400 @@ -75,6 +75,7 @@ | CheckRecord | CheckFailed B.ByteString | CheckSuccess [B.ByteString] + | Random [ClientChan] [B.ByteString] type ClientChan = Chan [B.ByteString] diff -r 1ae1b6017b27 -r d1478ce0f298 gameServer/HWProtoCore.hs --- a/gameServer/HWProtoCore.hs Tue May 21 16:14:36 2013 -0400 +++ b/gameServer/HWProtoCore.hs Wed May 22 00:50:15 2013 +0400 @@ -45,10 +45,12 @@ h ["STATS"] = handleCmd ["STATS"] h ("PART":m:ms) = handleCmd ["PART", B.unwords $ m:ms] h ("QUIT":m:ms) = handleCmd ["QUIT", B.unwords $ m:ms] + h ("RND":rs) = handleCmd ("RND":rs) h ("GLOBAL":m:ms) = do + cl <- thisClient rnc <- liftM snd ask let chans = map (sendChan . client rnc) $ allClients rnc - return [AnswerClients chans ["CHAT", "[global notice]", B.unwords $ m:ms]] + return [AnswerClients chans ["CHAT", "[global notice]", B.unwords $ m:ms] | isAdministrator cl] h c = return [Warning . B.concat . L.intersperse " " $ "Unknown cmd" : c] handleCmd cmd = do diff -r 1ae1b6017b27 -r d1478ce0f298 gameServer/HWProtoInRoomState.hs --- a/gameServer/HWProtoInRoomState.hs Tue May 21 16:14:36 2013 -0400 +++ b/gameServer/HWProtoInRoomState.hs Wed May 22 00:50:15 2013 +0400 @@ -348,6 +348,10 @@ else return [] +handleCmd_inRoom ("RND":rs) = do + n <- clientNick + s <- roomClientsChans + return [AnswerClients s ["CHAT", n, B.unwords $ "/rnd" : rs], Random s rs] handleCmd_inRoom ["LIST"] = return [] -- for old clients (<= 0.9.17) diff -r 1ae1b6017b27 -r d1478ce0f298 gameServer/HWProtoLobbyState.hs --- a/gameServer/HWProtoLobbyState.hs Tue May 21 16:14:36 2013 -0400 +++ b/gameServer/HWProtoLobbyState.hs Wed May 22 00:50:15 2013 +0400 @@ -144,6 +144,11 @@ else liftM ((:) (AnswerClients [clChan] ["JOINING", roomName])) $ handleCmd_lobby ["JOIN_ROOM", roomName] + +handleCmd_lobby ("RND":rs) = do + c <- liftM sendChan thisClient + return [Random [c] rs] + --------------------------- -- Administrator's stuff --