gameServer/HWProtoChecker.hs
author unc0rr
Sun, 23 Mar 2014 23:35:33 +0400
changeset 10212 5fb3bb2de9d2
parent 9444 30748b1d9ec7
child 10460 8dcea9087d75
permissions -rw-r--r--
Some fixes to voting + small refactoring

{-# LANGUAGE OverloadedStrings #-}
module HWProtoChecker where

import Data.Maybe
import Control.Monad.Reader
--------------------------------------
import CoreTypes
import HandlerUtils


handleCmd_checker :: CmdHandler

handleCmd_checker ["READY"] = return [ModifyClient $ \c -> c{isReady = True}, CheckRecord]

handleCmd_checker ["CHECKED", "FAIL", msg] = do
    isChecking <- liftM (isJust . checkInfo) thisClient
    if not isChecking then
        return []
        else
        return [CheckFailed msg, ModifyClient $ \c -> c{checkInfo = Nothing}]


handleCmd_checker ("CHECKED" : "OK" : info) = do
    isChecking <- liftM (isJust . checkInfo) thisClient
    if not isChecking then
        return []
        else
        return [CheckSuccess info, ModifyClient $ \c -> c{checkInfo = Nothing}]

handleCmd_checker _ = return [ProtocolError "Unknown command"]