gameServer/HWProtoInRoomState.hs
changeset 8431 74c2c95ab07b
parent 8429 f814a7c2a318
child 8433 3b318a130a62
equal deleted inserted replaced
8430:5a5c34a75e1a 8431:74c2c95ab07b
    95 
    95 
    96 
    96 
    97 handleCmd_inRoom ["REMOVE_TEAM", tName] = do
    97 handleCmd_inRoom ["REMOVE_TEAM", tName] = do
    98         (ci, _) <- ask
    98         (ci, _) <- ask
    99         r <- thisRoom
    99         r <- thisRoom
   100         clNick <- clientNick
       
   101 
   100 
   102         let maybeTeam = findTeam r
   101         let maybeTeam = findTeam r
   103         let team = fromJust maybeTeam
   102         let team = fromJust maybeTeam
   104 
   103 
   105         return $
   104         return $
   106             if isNothing $ maybeTeam then
   105             if isNothing $ maybeTeam then
   107                 [Warning $ loc "REMOVE_TEAM: no such team"]
   106                 [Warning $ loc "REMOVE_TEAM: no such team"]
   108             else if clNick /= teamowner team then
   107             else if ci /= teamownerId team then
   109                 [ProtocolError $ loc "Not team owner!"]
   108                 [ProtocolError $ loc "Not team owner!"]
   110             else
   109             else
   111                 [RemoveTeam tName,
   110                 [RemoveTeam tName,
   112                 ModifyClient
   111                 ModifyClient
   113                     (\c -> c{
   112                     (\c -> c{
   114                         teamsInGame = teamsInGame c - 1,
   113                         teamsInGame = teamsInGame c - 1,
   115                         clientClan = if teamsInGame c == 1 then Nothing else Just $ anotherTeamClan ci r
   114                         clientClan = if teamsInGame c == 1 then Nothing else Just $ anotherTeamClan ci r
   116                     })
   115                     })
   117                 ]
   116                 ]
   118     where
   117     where
   119         anotherTeamClan ci = teamcolor . fromJust . find (\t -> teamownerId t == ci) . teams
   118         anotherTeamClan ci = teamcolor . fromJust . find (\t -> (teamownerId t == ci) && (t /= team)) . teams
   120         findTeam = find (\t -> tName == teamname t) . teams
   119         findTeam = find (\t -> tName == teamname t) . teams
   121 
   120 
   122 
   121 
   123 handleCmd_inRoom ["HH_NUM", teamName, numberStr] = do
   122 handleCmd_inRoom ["HH_NUM", teamName, numberStr] = do
   124     cl <- thisClient
   123     cl <- thisClient