equal
deleted
inserted
replaced
24 import ServerState |
24 import ServerState |
25 import qualified Data.ByteString.Char8 as B |
25 import qualified Data.ByteString.Char8 as B |
26 import qualified Data.List as L |
26 import qualified Data.List as L |
27 import qualified Data.Map as Map |
27 import qualified Data.Map as Map |
28 import Data.Maybe |
28 import Data.Maybe |
|
29 import Control.Applicative |
29 ------------------- |
30 ------------------- |
30 import Utils |
31 import Utils |
31 import CoreTypes |
32 import CoreTypes |
32 import HandlerUtils |
33 import HandlerUtils |
33 import EngineInteraction |
34 import EngineInteraction |
46 if uid `L.notElem` entitledToVote voting then |
47 if uid `L.notElem` entitledToVote voting then |
47 return [] |
48 return [] |
48 else if uid `L.elem` map fst (votes voting) then |
49 else if uid `L.elem` map fst (votes voting) then |
49 return [AnswerClients [sendChan cl] ["CHAT", "[server]", loc "You already have voted"]] |
50 return [AnswerClients [sendChan cl] ["CHAT", "[server]", loc "You already have voted"]] |
50 else |
51 else |
51 actOnVoting $ voting{votes = (uid, vote):votes voting} |
52 ((:) (AnswerClients [sendChan cl] ["CHAT", "[server]", loc "Your vote counted"])) |
|
53 <$> (actOnVoting $ voting{votes = (uid, vote):votes voting}) |
52 |
54 |
53 where |
55 where |
54 actOnVoting :: Voting -> Reader (ClientIndex, IRnC) [Action] |
56 actOnVoting :: Voting -> Reader (ClientIndex, IRnC) [Action] |
55 actOnVoting vt = do |
57 actOnVoting vt = do |
56 let (pro, contra) = L.partition snd $ votes vt |
58 let (pro, contra) = L.partition snd $ votes vt |