Changeset 344 for trunk/Game.pas
- Timestamp:
- Dec 23, 2024, 8:16:05 AM (10 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Game.pas
r342 r344 295 295 var 296 296 Cell: TCell; 297 NewPower: Integer;298 297 begin 299 298 // Randomize map terrain … … 317 316 NewPower := Random(MaxNeutralUnits + 1); 318 317 if (NewPower > 0) and not Assigned(OneUnit) then begin 319 OneUnit := Units.AddNew( TUnitKind(GameSystem.UnitKinds[0]), NewPower);318 OneUnit := Units.AddNew(GameSystem.UnitKinds[0], NewPower); 320 319 end; 321 320 Player := nil; … … 330 329 with Cell do begin 331 330 if (Terrain = ttNormal) and CityEnabled and (Random < CityPercentage / 100) then begin 332 Building := TBuilding(Buildings.AddItem('City'));333 Building.Kind := TBuildingKind(GameSystem.BuildingKinds.FindBySpecialType(stCity));331 Building := Buildings.AddItem('City'); 332 Building.Kind := GameSystem.BuildingKinds.FindBySpecialType(stCity); 334 333 end; 335 334 end; … … 344 343 345 344 for I := 0 to Players.Count - 1 do begin 346 TPlayer(Players[I]).Reset;347 TPlayer(Players[I]).StartCell := nil;345 Players[I].Reset; 346 Players[I].StartCell := nil; 348 347 end; 349 348 for I := 0 to Players.Count - 1 do 350 with TPlayer(Players[I])do begin351 Player := TPlayer(Players[I]);349 with Players[I] do begin 350 Player := Players[I]; 352 351 PlayerMap.Update; 353 352 if (Map.Size.X > 0) and (Map.Size.Y > 0) then begin … … 355 354 if Assigned(Player.StartCell) then begin 356 355 if SymetricMap and (I = 1) then 357 StartCell := Map.Cells[Map.Cells.Count - 1 - Map.Cells.IndexOf( TPlayer(Players[0]).StartCell)];356 StartCell := Map.Cells[Map.Cells.Count - 1 - Map.Cells.IndexOf(Players[0].StartCell)]; 358 357 359 358 if CityEnabled then begin 360 StartCell.Building := TBuilding(Buildings.AddItem('City'));361 StartCell.Building.Kind := TBuildingKind(GameSystem.BuildingKinds.FindBySpecialType(stCity));359 StartCell.Building := Buildings.AddItem('City'); 360 StartCell.Building.Kind := GameSystem.BuildingKinds.FindBySpecialType(stCity); 362 361 end; 363 362 StartCell.Player := Player; 364 363 if GameSystem.UnitKinds.Count > 0 then begin 365 364 if not Assigned(StartCell.OneUnit) then 366 StartCell.OneUnit := Self.Units.AddNew( TUnitKind(GameSystem.UnitKinds[0]), Player.StartUnits);365 StartCell.OneUnit := Self.Units.AddNew(GameSystem.UnitKinds[0], Player.StartUnits); 367 366 StartCell.OneUnit.Power := Player.StartUnits; 368 StartCell.OneUnit.Kind := TUnitKind(GameSystem.UnitKinds[0]);367 StartCell.OneUnit.Kind := GameSystem.UnitKinds[0]; 369 368 StartCell.OneUnit.Player := Player; 370 369 end; … … 428 427 begin 429 428 for I := 0 to Players.Count - 1 do begin 430 Player := TPlayer(Players[I]);429 Player := Players[I]; 431 430 if Assigned(Player.StartCell) then begin 432 431 Player.StartCell.Weight := 1; … … 633 632 if Assigned(NewNode) then 634 633 Players.LoadFromNode(NewNode); 635 if Players.Count > 0 then CurrentPlayer := TPlayer(Players[0])634 if Players.Count > 0 then CurrentPlayer := Players[0] 636 635 else CurrentPlayer := nil; 637 636 … … 644 643 645 644 for I := 0 to Players.Count - 1 do begin 646 TPlayer(Players[I]).PlayerMap.Update;647 TPlayer(Players[I]).PlayerMap.CheckVisibility;645 Players[I].PlayerMap.Update; 646 Players[I].PlayerMap.CheckVisibility; 648 647 end; 649 648 ComputePlayerStats; … … 742 741 begin 743 742 for I := 0 to Players.Count - 1 do 744 with TPlayer(Players[I])do begin743 with Players[I] do begin 745 744 TotalUnits := 0; 746 745 TotalCells := 0; … … 763 762 begin 764 763 for I := 0 to Players.Count - 1 do 765 with TPlayer(Players[I])do begin764 with Players[I] do begin 766 765 NewStat := TGameTurnStat.Create; 767 766 NewStat.DiscoveredCells := TotalDiscovered; … … 804 803 NewPlayerIndex := NewPlayerIndex mod AlivePlayers.Count; 805 804 end; 806 CurrentPlayer := TPlayer(AlivePlayers[NewPlayerIndex]);805 CurrentPlayer := AlivePlayers[NewPlayerIndex]; 807 806 finally 808 807 AlivePlayers.Free; … … 931 930 I: Integer; 932 931 begin 933 for I := 0 to Players.Count - 1 do TPlayer(Players[I]).Clear;932 for I := 0 to Players.Count - 1 do Players[I].Clear; 934 933 Map.Clear; 935 934 Units.Clear; … … 960 959 961 960 InitPlayers; 962 if Players.Count > 0 then CurrentPlayer := TPlayer(Players[0])961 if Players.Count > 0 then CurrentPlayer := Players[0] 963 962 else CurrentPlayer := nil; 964 963
Note:
See TracChangeset
for help on using the changeset viewer.