equal
deleted
inserted
replaced
1 module HWProtoLobbyState where |
1 module HWProtoLobbyState where |
2 |
2 |
3 import qualified Data.Map as Map |
3 import qualified Data.Map as Map |
4 import qualified Data.IntMap as IntMap |
4 import qualified Data.IntMap as IntMap |
5 import qualified Data.IntSet as IntSet |
5 import qualified Data.IntSet as IntSet |
|
6 import qualified Data.Foldable as Foldable |
6 import Maybe |
7 import Maybe |
7 import Data.List |
8 import Data.List |
8 -------------------------------------- |
9 -------------------------------------- |
9 import CoreTypes |
10 import CoreTypes |
10 import Actions |
11 import Actions |
66 ++ answerNicks |
67 ++ answerNicks |
67 ++ answerReady |
68 ++ answerReady |
68 ++ [AnswerThisRoom ["NOT_READY", nick client]] |
69 ++ [AnswerThisRoom ["NOT_READY", nick client]] |
69 ++ answerFullConfig jRoom |
70 ++ answerFullConfig jRoom |
70 ++ answerTeams |
71 ++ answerTeams |
71 -- ++ watchRound) |
72 ++ watchRound |
72 where |
73 where |
73 noSuchRoom = isNothing mbRoom |
74 noSuchRoom = isNothing mbRoom |
74 mbRoom = find (\r -> roomName == name r && roomProto r == clientProto client) $ IntMap.elems rooms |
75 mbRoom = find (\r -> roomName == name r && roomProto r == clientProto client) $ IntMap.elems rooms |
75 jRoom = fromJust mbRoom |
76 jRoom = fromJust mbRoom |
76 rID = roomUID jRoom |
77 rID = roomUID jRoom |
84 map (\c -> AnswerThisClient [if isReady c then "READY" else "NOT_READY", nick c]) $ |
85 map (\c -> AnswerThisClient [if isReady c then "READY" else "NOT_READY", nick c]) $ |
85 map (\clID -> clients IntMap.! clID) roomClientsIDs |
86 map (\clID -> clients IntMap.! clID) roomClientsIDs |
86 |
87 |
87 toAnswer (paramName, paramStrs) = AnswerThisClient $ "CFG" : paramName : paramStrs |
88 toAnswer (paramName, paramStrs) = AnswerThisClient $ "CFG" : paramName : paramStrs |
88 answerFullConfig room = map toAnswer (Map.toList $ params room) |
89 answerFullConfig room = map toAnswer (Map.toList $ params room) |
89 {- |
90 |
90 watchRound = if (roomProto clRoom < 20) || (not $ gameinprogress clRoom) then |
91 watchRound = if not $ gameinprogress jRoom then |
91 [] |
92 [] |
92 else |
93 else |
93 (answerClientOnly ["RUN_GAME"]) ++ |
94 [AnswerThisClient ["RUN_GAME"], |
94 answerClientOnly ("GAMEMSG" : toEngineMsg "e$spectate 1" : (toList $ roundMsgs clRoom)) -} |
95 AnswerThisClient $ "GAMEMSG" : toEngineMsg "e$spectate 1" : (Foldable.toList $ roundMsgs jRoom)] |
|
96 |
95 answerTeams = if gameinprogress jRoom then |
97 answerTeams = if gameinprogress jRoom then |
96 answerAllTeams (teamsAtStart jRoom) |
98 answerAllTeams (teamsAtStart jRoom) |
97 else |
99 else |
98 answerAllTeams (teams jRoom) |
100 answerAllTeams (teams jRoom) |
99 |
101 |