Changeset 199 for trunk/UGame.pas


Ignore:
Timestamp:
May 16, 2018, 2:48:57 PM (6 years ago)
Author:
chronos
Message:
  • Modified: Initial game setting made independent to current game settings. So last game can be automatically loaded on start and initial setting will be intact.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UGame.pas

    r198 r199  
    329329    Moves: TUnitMoves;
    330330    Computer: TComputer;
     331    procedure Reset;
    331332    function IsAlive: Boolean;
    332333    procedure Clear;
     
    442443    procedure CalculatePlayersDistance;
    443444    procedure PropagatePlayerDistance(List: TCells);
    444     procedure InitDefaultPlayersSetting;
     445    procedure InitDefaultPlayers;
    445446    procedure WinObjectiveMapPrepare;
    446447  public
    447448    DevelMode: Boolean;
    448449    Players: TPlayers;
    449     PlayersSetting: TPlayers;
    450450    Map: TMap;
    451451    MapImageFileName: string;
     
    467467    BridgeEnabled: Boolean;
    468468    MaxPower: Integer;
     469    procedure Assign(Source: TGame);
    469470    function AttackProbability(AttackCount, DefendCount: Integer): Double;
    470471    procedure LoadConfig(Config: TXmlConfig; Path: string);
     
    28092810end;
    28102811
     2812procedure TPlayer.Reset;
     2813begin
     2814  Moves.Clear;
     2815  PlayerMap.Cells.Clear;
     2816  TotalUnits := 0;
     2817  TotalCells := 0;
     2818  TotalCities := 0;
     2819  TotalDiscovered := 0;
     2820  TurnStats.Clear;
     2821  StartCell := nil;
     2822end;
     2823
    28112824function TPlayer.IsAlive: Boolean;
    28122825begin
     
    31993212end;
    32003213
    3201 procedure TGame.InitDefaultPlayersSetting;
    3202 begin
    3203   PlayersSetting.Clear;
    3204   PlayersSetting.New(SPlayer + ' 1', clBlue, pmHuman);
    3205   PlayersSetting.New(SPlayer + ' 2', clRed, pmComputer);
     3214procedure TGame.InitDefaultPlayers;
     3215begin
     3216  Players.Clear;
     3217  Players.New(SPlayer + ' 1', clBlue, pmHuman);
     3218  Players.New(SPlayer + ' 2', clRed, pmComputer);
    32063219end;
    32073220
     
    32263239    Cells.Free;
    32273240  end;
     3241end;
     3242
     3243procedure TGame.Assign(Source: TGame);
     3244begin
     3245  DevelMode := Source.DevelMode;
     3246  Players.Assign(Source.Players);
     3247  MapType := Source.MapType;
     3248  Map.Assign(Source.Map);
     3249  MapImageFileName := Source.MapImageFileName;
     3250  VoidEnabled := Source.VoidEnabled;
     3251  VoidPercentage := Source.VoidPercentage;
     3252  SymetricMap := Source.SymetricMap;
     3253  GrowCells := Source.GrowCells;
     3254  GrowAmount := Source.GrowAmount;
     3255  CityEnabled := Source.CityEnabled;
     3256  CityPercentage := Source.CityPercentage;
     3257  TurnCounter := Source.TurnCounter;
     3258  WinObjective := Source.WinObjective;
     3259  SpecialCaptureCellCount := Source.SpecialCaptureCellCount;
     3260  StayAliveForDefinedTurns := Source.StayAliveForDefinedTurns;
     3261  MaxNeutralUnits := Source.MaxNeutralUnits;
     3262  FileName := Source.FileName;
     3263  FogOfWar := Source.FogOfWar;
     3264  BridgeEnabled := Source.BridgeEnabled;
     3265  MaxPower := Source.MaxPower;
    32283266end;
    32293267
     
    32483286    SetValue(DOMString(Path + '/StayAliveForDefinedTurns'), StayAliveForDefinedTurns);
    32493287    SetValue(DOMString(Path + '/SpecialCaptureCellCount'), SpecialCaptureCellCount);
    3250     PlayersSetting.SaveConfig(Config, Path + '/Players');
     3288    Players.SaveConfig(Config, Path + '/Players');
    32513289  end;
    32523290end;
     
    32823320    StayAliveForDefinedTurns := GetValue(DOMString(Path + '/StayAliveForDefinedTurns'), 20);
    32833321    SpecialCaptureCellCount := GetValue(DOMString(Path + '/SpecialCaptureCellCount'), 1);
    3284     PlayersSetting.LoadConfig(Config, Path + '/Players');
     3322    Players.LoadConfig(Config, Path + '/Players');
    32853323  end;
    32863324end;
     
    34993537  Players := TPlayers.Create;
    35003538  Players.Game := Self;
    3501   PlayersSetting := TPlayers.Create;
    3502   PlayersSetting.Game := Self;
    35033539
    35043540  MapImageFileName := 'Images/Maps/WorldMap.png';
    35053541  Randomize;
    3506   InitDefaultPlayersSetting;
     3542  InitDefaultPlayers;
    35073543
    35083544  VoidEnabled := True;
     
    35173553destructor TGame.Destroy;
    35183554begin
    3519   FreeAndNil(PlayersSetting);
    35203555  FreeAndNil(Players);
    35213556  FreeAndNil(Map);
     
    35243559
    35253560procedure TGame.Clear;
    3526 begin
    3527   Players.Clear;
     3561var
     3562  I: Integer;
     3563begin
     3564  for I := 0 to Players.Count - 1 do Players[I].Clear;
    35283565  Map.Clear;
    35293566end;
     
    35513588  end;
    35523589
    3553   Players.Assign(PlayersSetting);
    35543590  for Player in Players do Player.StartCell := nil;
    35553591  I := 0;
Note: See TracChangeset for help on using the changeset viewer.