gameServer/HandlerUtils.hs
author smxx
Tue, 01 Jun 2010 19:33:45 +0000
changeset 3489 aedf289192f5
parent 3435 4e4f88a7bdf2
child 3500 af8390d807d6
permissions -rw-r--r--
Engine: * Removed horizontal weapon offsets for now (shouldn't affect human player's gameplay but that of AI) Frontend: * Added some main menu tips

module HandlerUtils where

import Control.Monad.Reader

import RoomsAndClients
import CoreTypes
import Actions

thisClient :: Reader (ClientIndex, IRnC) ClientInfo
thisClient = do
    (ci, rnc) <- ask
    return $ rnc `client` ci

clientNick :: Reader (ClientIndex, IRnC) String
clientNick = liftM nick thisClient

roomOthersChans :: Reader (ClientIndex, IRnC) [ClientChan]
roomOthersChans = do
    (ci, rnc) <- ask
    let ri = clientRoom rnc ci
    return $ map (sendChan . client rnc) (roomClients rnc ri)

thisClientChans :: Reader (ClientIndex, IRnC) [ClientChan]
thisClientChans = do
    (ci, rnc) <- ask
    return $ [sendChan (rnc `client` ci)]

answerClient :: [String] -> Reader (ClientIndex, IRnC) [Action]
answerClient msg = thisClientChans >>= return . (: []) . flip AnswerClients msg