gameServer/HWProtoInRoomState.hs
changeset 2928 0e95e0e24fd8
parent 2917 2f4320a1b31f
child 2952 18fada739b55
equal deleted inserted replaced
2927:616378221e58 2928:0e95e0e24fd8
    71 handleCmd_inRoom clID clients rooms ["REMOVE_TEAM", teamName]
    71 handleCmd_inRoom clID clients rooms ["REMOVE_TEAM", teamName]
    72     | noSuchTeam = [Warning "REMOVE_TEAM: no such team"]
    72     | noSuchTeam = [Warning "REMOVE_TEAM: no such team"]
    73     | nick client /= teamowner team = [ProtocolError "Not team owner!"]
    73     | nick client /= teamowner team = [ProtocolError "Not team owner!"]
    74     | otherwise =
    74     | otherwise =
    75             [RemoveTeam teamName,
    75             [RemoveTeam teamName,
    76             ModifyClient (\c -> c{teamsInGame = teamsInGame c - 1})
    76             ModifyClient (\c -> c{teamsInGame = teamsInGame c - 1, clientClan = if teamsInGame client == 1 then undefined else anotherTeamClan})
    77             ]
    77             ]
    78     where
    78     where
    79         client = clients IntMap.! clID
    79         client = clients IntMap.! clID
    80         room = rooms IntMap.! (roomID client)
    80         room = rooms IntMap.! (roomID client)
    81         noSuchTeam = isNothing findTeam
    81         noSuchTeam = isNothing findTeam
    82         team = fromJust findTeam
    82         team = fromJust findTeam
    83         findTeam = find (\t -> teamName == teamname t) $ teams room
    83         findTeam = find (\t -> teamName == teamname t) $ teams room
       
    84         anotherTeamClan = teamcolor $ fromJust $ find (\t -> teamownerId t == clID) $ teams room
    84 
    85 
    85 
    86 
    86 handleCmd_inRoom clID clients rooms ["HH_NUM", teamName, numberStr]
    87 handleCmd_inRoom clID clients rooms ["HH_NUM", teamName, numberStr]
    87     | not $ isMaster client = [ProtocolError "Not room master"]
    88     | not $ isMaster client = [ProtocolError "Not room master"]
    88     | hhNumber < 1 || hhNumber > 8 || noSuchTeam || hhNumber > (canAddNumber + (hhnum team)) = []
    89     | hhNumber < 1 || hhNumber > 8 || noSuchTeam || hhNumber > (canAddNumber + (hhnum team)) = []