726 let i = if null items then ["heads", "tails"] else items |
726 let i = if null items then ["heads", "tails"] else items |
727 n <- io $ randomRIO (0, length i - 1) |
727 n <- io $ randomRIO (0, length i - 1) |
728 processAction $ AnswerClients chans ["CHAT", "[random]", i !! n] |
728 processAction $ AnswerClients chans ["CHAT", "[random]", i !! n] |
729 |
729 |
730 |
730 |
|
731 processAction (LoadGhost location) = do |
|
732 points <- io $ loadFile (B.unpack $ "ghosts/" `B.append` sanitizeName location) |
|
733 ri <- clientRoomA |
|
734 rnc <- gets roomsClients |
|
735 thisRoomChans <- liftM (map sendChan) $ roomClientsS ri |
|
736 -- inject ghost points into map |
|
737 rm <- io $ room'sM rnc id ri |
|
738 cl <- client's id |
|
739 mapM processAction $ map (replaceChans thisRoomChans) $ answerFullConfigParams cl (mapParams rm) (params rm) |
|
740 return () |
|
741 where |
|
742 loadFile :: String -> IO [Int] |
|
743 loadFile fileName = E.handle (\(e :: SomeException) -> return []) $ do |
|
744 points <- liftM read $ readFile fileName |
|
745 return (points `deepseq` points) |
|
746 replaceChans chans (AnswerClients _ msg) = AnswerClients chans msg |
|
747 replaceChans _ a = a |
|
748 {- |
|
749 let a = map (replaceChans chans) $ answerFullConfigParams cl mp p |
|
750 -} |
731 #if defined(OFFICIAL_SERVER) |
751 #if defined(OFFICIAL_SERVER) |
732 processAction SaveReplay = do |
752 processAction SaveReplay = do |
733 ri <- clientRoomA |
753 ri <- clientRoomA |
734 rnc <- gets roomsClients |
754 rnc <- gets roomsClients |
735 |
755 |