Changeset 342 for trunk/Game.pas
- Timestamp:
- Dec 22, 2024, 10:52:26 AM (10 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Game.pas
r339 r342 6 6 Classes, SysUtils, ExtCtrls, Graphics, XMLConf, XMLRead, XMLWrite, Forms, 7 7 DOM, Math, LazFileUtils, XML, Dialogs, LCLType, LCLIntf, Building, Geometry, 8 Player, Map, MapType, &Unit, GameSystem;8 Player, Map, MapType, Units, GameSystem; 9 9 10 10 const … … 49 49 procedure SetRunning(AValue: Boolean); 50 50 procedure BuildTerrain; 51 procedure PlaceUnits; 51 52 procedure PlaceCities; 52 53 procedure InitPlayers; … … 91 92 procedure LoadFromFile(FileName: string); 92 93 procedure SaveToFile(FileName: string); 94 function ToString: string; override; 93 95 procedure ComputePlayerStats; 94 96 procedure NextPlayer; … … 301 303 (Map.IsOutsideShape(PosPx)) then Terrain := ttVoid 302 304 else Terrain := ttNormal; 305 end; 306 end; 307 308 procedure TGame.PlaceUnits; 309 var 310 Cell: TCell; 311 NewPower: Integer; 312 begin 313 if GameSystem.UnitKinds.Count = 0 then Exit; 314 315 for Cell in Map.Cells do 316 with Cell do begin 303 317 NewPower := Random(MaxNeutralUnits + 1); 304 318 if (NewPower > 0) and not Assigned(OneUnit) then begin … … 348 362 end; 349 363 StartCell.Player := Player; 350 if not Assigned(StartCell.OneUnit) then 351 StartCell.OneUnit := Self.Units.AddNew(TUnitKind(GameSystem.UnitKinds[0]), Player.StartUnits); 352 StartCell.OneUnit.Power := Player.StartUnits; 353 StartCell.OneUnit.Kind := TUnitKind(GameSystem.UnitKinds[0]); 354 StartCell.OneUnit.Player := Player; 364 if GameSystem.UnitKinds.Count > 0 then begin 365 if not Assigned(StartCell.OneUnit) then 366 StartCell.OneUnit := Self.Units.AddNew(TUnitKind(GameSystem.UnitKinds[0]), Player.StartUnits); 367 StartCell.OneUnit.Power := Player.StartUnits; 368 StartCell.OneUnit.Kind := TUnitKind(GameSystem.UnitKinds[0]); 369 StartCell.OneUnit.Player := Player; 370 end; 355 371 end; 356 372 end; … … 694 710 end; 695 711 712 function TGame.ToString: string; 713 begin 714 Result := 'StoredRandSeed: ' + IntToStr(StoredRandSeed) + LineEnding; 715 Result := Result + 'MapType: ' + IntToStr(Integer(MapType)) + LineEnding; 716 Result := Result + 'SymetricMap: ' + BoolToStr(SymetricMap) + LineEnding; 717 Result := Result + 'CyclicMap: ' + BoolToStr(CyclicMap) + LineEnding; 718 Result := Result + 'FogOfWar: ' + BoolToStr(FogOfWar) + LineEnding; 719 Result := Result + 'VoidEnabled: ' + BoolToStr(VoidEnabled) + LineEnding; 720 Result := Result + 'VoidPercentage: ' + IntToStr(VoidPercentage) + LineEnding; 721 Result := Result + 'MaxNeutralUnits: ' + IntToStr(MaxNeutralUnits) + LineEnding; 722 Result := Result + 'MaxPower: ' + IntToStr(MaxPower) + LineEnding; 723 Result := Result + 'GrowCells: ' + IntToStr(Integer(GrowCells)) + LineEnding; 724 Result := Result + 'GrowAmount: ' + IntToStr(Integer(GrowAmount)) + LineEnding; 725 Result := Result + 'CityEnabled: ' + BoolToStr(CityEnabled) + LineEnding; 726 Result := Result + 'CityPercentage: ' + IntToStr(CityPercentage) + LineEnding; 727 Result := Result + 'BridgeEnabled: ' + BoolToStr(BridgeEnabled) + LineEnding; 728 Result := Result + 'TurnCounter: ' + IntToStr(TurnCounter) + LineEnding; 729 Result := Result + 'WinObjective: ' + IntToStr(Integer(WinObjective)) + LineEnding; 730 Result := Result + 'StayAliveForDefinedTurns: ' + IntToStr(StayAliveForDefinedTurns) + LineEnding; 731 Result := Result + 'Running: ' + BoolToStr(Running) + LineEnding; 732 Result := Result + 'GameSystem: ' + LineEnding + GameSystem.ToString + LineEnding; 733 Result := Result + 'Map: ' + LineEnding + Map.ToString + LineEnding; 734 Result := Result + 'Players: ' + LineEnding + Players.ToString + LineEnding; 735 Result := Result + 'Units: ' + LineEnding + Units.ToString + LineEnding; 736 end; 737 696 738 procedure TGame.ComputePlayerStats; 697 739 var … … 905 947 Map.MaxPower := MaxPower; 906 948 BuildTerrain; 949 PlaceUnits; 907 950 PlaceCities; 908 951 WinObjectiveMapPrepare; … … 931 974 function TGame.Compare(Game: TGame): Boolean; 932 975 begin 933 Result := BridgeEnabled = Game.BridgeEnabled; 976 Result := (StoredRandSeed = Game.StoredRandSeed) and 977 (DevelMode = Game.DevelMode) and 978 Players.Compare(Game.Players) and 979 (MapType = Game.MapType) and 980 Map.Compare(Game.Map) and 981 (MapImageFileName = Game.MapImageFileName) and 982 (VoidEnabled = Game.VoidEnabled) and 983 (VoidPercentage = Game.VoidPercentage) and 984 (SymetricMap = Game.SymetricMap) and 985 (CyclicMap = Game.CyclicMap) and 986 (GrowCells = Game.GrowCells) and 987 (GrowAmount = Game.GrowAmount) and 988 (CityEnabled = Game.CityEnabled) and 989 (CityPercentage = Game.CityPercentage) and 990 (TurnCounter = Game.TurnCounter) and 991 (WinObjective = Game.WinObjective) and 992 (SpecialCaptureCellCount = Game.SpecialCaptureCellCount) and 993 (StayAliveForDefinedTurns = Game.StayAliveForDefinedTurns) and 994 (MaxNeutralUnits = Game.MaxNeutralUnits) and 995 (FileName = Game.FileName) and 996 (FogOfWar = Game.FogOfWar) and 997 (BridgeEnabled = Game.BridgeEnabled) and 998 (MaxPower = Game.MaxPower) and 999 GameSystem.Compare(Game.GameSystem); 934 1000 end; 935 1001
Note:
See TracChangeset
for help on using the changeset viewer.