hedgewars/uTeams.pas
changeset 1351 aa7aefec5c1b
parent 1299 fc801a832e0e
child 1352 405ad07cf875
equal deleted inserted replaced
1350:99a921e292f4 1351:aa7aefec5c1b
    63 			TeamHealthBarWidth,
    63 			TeamHealthBarWidth,
    64 			NewTeamHealthBarWidth: LongInt;
    64 			NewTeamHealthBarWidth: LongInt;
    65 			DrawHealthY: LongInt;
    65 			DrawHealthY: LongInt;
    66 			AttackBar: LongWord;
    66 			AttackBar: LongWord;
    67 			HedgehogsNumber: Longword;
    67 			HedgehogsNumber: Longword;
    68 			hasSurrendered: boolean;
    68 			hasGone: boolean;
    69 			end;
    69 			end;
    70 			
    70 			
    71 	TClan = record
    71 	TClan = record
    72 			Color: Longword;
    72 			Color: Longword;
    73 			Teams: array[0..Pred(cMaxTeams)] of PTeam;
    73 			Teams: array[0..Pred(cMaxTeams)] of PTeam;
    92 procedure InitTeams;
    92 procedure InitTeams;
    93 function  TeamSize(p: PTeam): Longword;
    93 function  TeamSize(p: PTeam): Longword;
    94 procedure RecountTeamHealth(team: PTeam);
    94 procedure RecountTeamHealth(team: PTeam);
    95 procedure RestoreTeamsFromSave;
    95 procedure RestoreTeamsFromSave;
    96 function  CheckForWin: boolean;
    96 function  CheckForWin: boolean;
       
    97 procedure TeamGone(s: shortstring);
    97 
    98 
    98 implementation
    99 implementation
    99 uses uMisc, uWorld, uAI, uLocale, uConsole, uAmmos, uSound;
   100 uses uMisc, uWorld, uAI, uLocale, uConsole, uAmmos, uSound, uChat;
   100 const MaxTeamHealth: LongInt = 0;
   101 const MaxTeamHealth: LongInt = 0;
   101 
   102 
   102 procedure FreeTeamsList; forward;
   103 procedure FreeTeamsList; forward;
   103 
   104 
   104 function CheckForWin: boolean;
   105 function CheckForWin: boolean;
   172 		inc(TotalRounds);
   173 		inc(TotalRounds);
   173 		c:= 0
   174 		c:= 0
   174 		end;
   175 		end;
   175 
   176 
   176 	with ClansArray[c]^ do
   177 	with ClansArray[c]^ do
       
   178 		begin
       
   179 		PrevTeam:= CurrTeam;
   177 		repeat
   180 		repeat
   178 			PrevTeam:= CurrTeam;
       
   179 			CurrTeam:= Succ(CurrTeam) mod TeamsNumber;
   181 			CurrTeam:= Succ(CurrTeam) mod TeamsNumber;
   180 			CurrentTeam:= Teams[CurrTeam];
   182 			CurrentTeam:= Teams[CurrTeam];
   181 			with CurrentTeam^ do
   183 			with CurrentTeam^ do
   182 				begin
   184 				begin
   183 				PrevHH:= CurrHedgehog;
   185 				PrevHH:= CurrHedgehog;
   184 				repeat
   186 				repeat
   185 					CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber;
   187 					CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber;
   186 				until (Hedgehogs[CurrHedgehog].Gear <> nil) or (CurrHedgehog = PrevHH)
   188 				until (Hedgehogs[CurrHedgehog].Gear <> nil) or (CurrHedgehog = PrevHH)
   187 				end
   189 				end
   188 		until ((CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (not CurrentTeam^.hasSurrendered)) or (PrevTeam = CurrTeam);
   190 		until ((CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (not CurrentTeam^.hasGone)) or (PrevTeam = CurrTeam);
   189 until CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil;
   191 		end
       
   192 until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (not CurrentTeam^.hasGone);
   190 
   193 
   191 CurrentHedgehog:= @(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog])
   194 CurrentHedgehog:= @(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog])
   192 end;
   195 end;
   193 
   196 
   194 procedure AfterSwitchHedgehog;
   197 procedure AfterSwitchHedgehog;
   349 begin
   352 begin
   350 for t:= 0 to Pred(TeamsCount) do
   353 for t:= 0 to Pred(TeamsCount) do
   351    TeamsArray[t]^.ExtDriven:= false
   354    TeamsArray[t]^.ExtDriven:= false
   352 end;
   355 end;
   353 
   356 
       
   357 procedure TeamGone(s: shortstring);
       
   358 var i: integer;
       
   359 begin
       
   360 i:= 0;
       
   361 
       
   362 while (i < cMaxTeams)
       
   363 	and (TeamsArray[i] <> nil)
       
   364 	and (TeamsArray[i]^.TeamName <> s) do inc(i);
       
   365 if (i = cMaxTeams) or (TeamsArray[i] = nil) then exit;
       
   366 
       
   367 with TeamsArray[i]^ do
       
   368 	begin
       
   369 	AddChatString('* '+ TeamName + ' is gone');
       
   370 	//for i:= 0 to cMaxHHIndex do Hedgehogs[i].Gear:= nil;
       
   371 	hasGone:= true
       
   372 	end
       
   373 end;
       
   374 
   354 initialization
   375 initialization
   355 
   376 
   356 finalization
   377 finalization
   357 
   378 
   358 FreeTeamsList
   379 FreeTeamsList