247 |
247 |
248 TurnTimeLeft:= cHedgehogTurnTime |
248 TurnTimeLeft:= cHedgehogTurnTime |
249 end; |
249 end; |
250 |
250 |
251 function AddTeam(TeamColor: Longword): PTeam; |
251 function AddTeam(TeamColor: Longword): PTeam; |
252 var Result: PTeam; |
252 var team: PTeam; |
253 c: LongInt; |
253 c: LongInt; |
254 begin |
254 begin |
255 TryDo(TeamsCount < cMaxTeams, 'Too many teams', true); |
255 TryDo(TeamsCount < cMaxTeams, 'Too many teams', true); |
256 New(Result); |
256 New(team); |
257 TryDo(Result <> nil, 'AddTeam: Result = nil', true); |
257 TryDo(team <> nil, 'AddTeam: team = nil', true); |
258 FillChar(Result^, sizeof(TTeam), 0); |
258 FillChar(team^, sizeof(TTeam), 0); |
259 Result^.AttackBar:= 2; |
259 team^.AttackBar:= 2; |
260 Result^.CurrHedgehog:= cMaxHHIndex; |
260 team^.CurrHedgehog:= cMaxHHIndex; |
261 |
261 |
262 TeamsArray[TeamsCount]:= Result; |
262 TeamsArray[TeamsCount]:= team; |
263 inc(TeamsCount); |
263 inc(TeamsCount); |
264 |
264 |
265 c:= Pred(ClansCount); |
265 c:= Pred(ClansCount); |
266 while (c >= 0) and (ClansArray[c]^.Color <> TeamColor) do dec(c); |
266 while (c >= 0) and (ClansArray[c]^.Color <> TeamColor) do dec(c); |
267 if c < 0 then |
267 if c < 0 then |
268 begin |
268 begin |
269 new(Result^.Clan); |
269 new(team^.Clan); |
270 FillChar(Result^.Clan^, sizeof(TClan), 0); |
270 FillChar(team^.Clan^, sizeof(TClan), 0); |
271 ClansArray[ClansCount]:= Result^.Clan; |
271 ClansArray[ClansCount]:= team^.Clan; |
272 inc(ClansCount); |
272 inc(ClansCount); |
273 with Result^.Clan^ do |
273 with team^.Clan^ do |
274 begin |
274 begin |
275 ClanIndex:= Pred(ClansCount); |
275 ClanIndex:= Pred(ClansCount); |
276 Color:= TeamColor |
276 Color:= TeamColor |
277 end |
277 end |
278 end else |
278 end else |
279 begin |
279 begin |
280 Result^.Clan:= ClansArray[c]; |
280 team^.Clan:= ClansArray[c]; |
281 end; |
281 end; |
282 |
282 |
283 with Result^.Clan^ do |
283 with team^.Clan^ do |
284 begin |
284 begin |
285 Teams[TeamsNumber]:= Result; |
285 Teams[TeamsNumber]:= team; |
286 inc(TeamsNumber) |
286 inc(TeamsNumber) |
287 end; |
287 end; |
288 |
288 |
289 CurrentTeam:= Result; |
289 CurrentTeam:= team; |
290 AddTeam:= Result |
290 AddTeam:= team; |
291 end; |
291 end; |
292 |
292 |
293 procedure FreeTeamsList; |
293 procedure FreeTeamsList; |
294 var t: LongInt; |
294 var t: LongInt; |
295 begin |
295 begin |
321 end; |
321 end; |
322 RecountAllTeamsHealth |
322 RecountAllTeamsHealth |
323 end; |
323 end; |
324 |
324 |
325 function TeamSize(p: PTeam): Longword; |
325 function TeamSize(p: PTeam): Longword; |
326 var i, Result: Longword; |
326 var i, value: Longword; |
327 begin |
327 begin |
328 Result:= 0; |
328 value:= 0; |
329 for i:= 0 to cMaxHHIndex do |
329 for i:= 0 to cMaxHHIndex do |
330 if p^.Hedgehogs[i].Gear <> nil then inc(Result); |
330 if p^.Hedgehogs[i].Gear <> nil then inc(value); |
331 TeamSize:= Result |
331 TeamSize:= value; |
332 end; |
332 end; |
333 |
333 |
334 procedure RecountClanHealth(clan: PClan); |
334 procedure RecountClanHealth(clan: PClan); |
335 var i: LongInt; |
335 var i: LongInt; |
336 begin |
336 begin |