73 Just (i, t) | B.null t -> fromIntegral i |
73 Just (i, t) | B.null t -> fromIntegral i |
74 otherwise -> 0 |
74 otherwise -> 0 |
75 hhsList [] = [] |
75 hhsList [] = [] |
76 hhsList (n:h:hhs) = HedgehogInfo n h : hhsList hhs |
76 hhsList (n:h:hhs) = HedgehogInfo n h : hhsList hhs |
77 newTeamHHNum r = min 4 (canAddNumber r) |
77 newTeamHHNum r = min 4 (canAddNumber r) |
|
78 |
|
79 handleCmd_inRoom ["REMOVE_TEAM", name] = do |
|
80 (ci, rnc) <- ask |
|
81 let r = room rnc $ clientRoom rnc ci |
|
82 clNick <- clientNick |
|
83 |
|
84 let maybeTeam = findTeam r |
|
85 let team = fromJust maybeTeam |
|
86 |
|
87 return $ |
|
88 if isNothing $ findTeam r then |
|
89 [Warning "REMOVE_TEAM: no such team"] |
|
90 else if clNick /= teamowner team then |
|
91 [ProtocolError "Not team owner!"] |
|
92 else |
|
93 [RemoveTeam name, |
|
94 ModifyClient |
|
95 (\c -> c{ |
|
96 teamsInGame = teamsInGame c - 1, |
|
97 clientClan = if teamsInGame client == 1 then undefined else anotherTeamClan ci r |
|
98 }) |
|
99 ] |
|
100 where |
|
101 anotherTeamClan ci = teamcolor . fromJust . find (\t -> teamownerId t == ci) . teams |
|
102 |
78 {- |
103 {- |
79 handleCmd_inRoom clID clients rooms ["REMOVE_TEAM", teamName] |
|
80 | noSuchTeam = [Warning "REMOVE_TEAM: no such team"] |
|
81 | nick client /= teamowner team = [ProtocolError "Not team owner!"] |
|
82 | otherwise = |
|
83 [RemoveTeam teamName, |
|
84 ModifyClient (\c -> c{teamsInGame = teamsInGame c - 1, clientClan = if teamsInGame client == 1 then undefined else anotherTeamClan}) |
|
85 ] |
|
86 where |
|
87 client = clients IntMap.! clID |
|
88 room = rooms IntMap.! (roomID client) |
|
89 noSuchTeam = isNothing findTeam |
|
90 team = fromJust findTeam |
|
91 findTeam = find (\t -> teamName == teamname t) $ teams room |
|
92 anotherTeamClan = teamcolor $ fromJust $ find (\t -> teamownerId t == clID) $ teams room |
|
93 |
|
94 |
104 |
95 handleCmd_inRoom clID clients rooms ["HH_NUM", teamName, numberStr] |
105 handleCmd_inRoom clID clients rooms ["HH_NUM", teamName, numberStr] |
96 | not $ isMaster client = [ProtocolError "Not room master"] |
106 | not $ isMaster client = [ProtocolError "Not room master"] |
97 | hhNumber < 1 || hhNumber > 8 || noSuchTeam || hhNumber > (canAddNumber + (hhnum team)) = [] |
107 | hhNumber < 1 || hhNumber > 8 || noSuchTeam || hhNumber > (canAddNumber + (hhnum team)) = [] |
98 | otherwise = |
108 | otherwise = |