Changeset 304 for trunk/UGame.pas


Ignore:
Timestamp:
Aug 11, 2019, 4:53:05 PM (5 years ago)
Author:
chronos
Message:
  • Fixed: First game system was rewritten by game system stored in game file.
  • Modified: Each TGame instance has own TGameSystem instance and different game systems are assigned.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UGame.pas

    r301 r304  
    3737  TGame = class
    3838  private
    39     FGameSystem: TGameSystem;
    4039    FMapType: TMapType;
    4140    FOnChange: TNotifyEvent;
     
    4948    ProbabilityMatrix: array of array of Single;
    5049    procedure RecordTurnStats;
    51     procedure SetGameSystem(AValue: TGameSystem);
    5250    procedure SetMapType(AValue: TMapType);
    5351    procedure SetRunning(AValue: Boolean);
     
    6159    procedure WinObjectiveMapPrepare;
    6260  public
     61    GameSystem: TGameSystem;
    6362    FileName: string;
    6463    DevelMode: Boolean;
     
    8786    StoredRandSeed: Cardinal;
    8887    GeneratePlayers: Boolean;
    89     GameSystemName: string;
    9088    procedure PostConfig;
    9189    procedure Assign(Source: TGame);
     
    105103    property Running: Boolean read FRunning write SetRunning;
    106104    property MapType: TMapType read FMapType write SetMapType;
    107     property GameSystem: TGameSystem read FGameSystem write SetGameSystem;
    108105  published
    109106    property OnMoveUpdated: TMoveUpdatedEvent read FOnMoveUpdated write FOnMoveUpdated;
     
    504501  BridgeEnabled := Source.BridgeEnabled;
    505502  MaxPower := Source.MaxPower;
    506   GameSystem := Source.GameSystem;
     503  GameSystem.Assign(Source.GameSystem);
    507504end;
    508505
     
    532529    SetValue(DOMString(Path + '/MaxPower'), MaxPower);
    533530    Players.SaveConfig(Config, Path + '/Players');
    534     SetValue(DOMString(Path + '/GameSystemName'), DOMString(GameSystemName));
     531    SetValue(DOMString(Path + '/GameSystemName'), DOMString(GameSystem.GetName));
    535532  end;
    536533end;
     
    733730end;
    734731
    735 procedure TGame.SetGameSystem(AValue: TGameSystem);
    736 begin
    737   if FGameSystem = AValue then Exit;
    738   FGameSystem := AValue;
    739   if Assigned(FGameSystem) then GameSystemName := FGameSystem.GetName
    740     else GameSystemName := '';
    741 end;
    742 
    743732procedure TGame.NextPlayer;
    744733var
     
    860849constructor TGame.Create;
    861850begin
     851  GameSystem := TGameSystem.Create;
    862852  Units := TUnits.Create;
    863853  Units.Game := Self;
     
    889879  FreeAndNil(Buildings);
    890880  FreeAndNil(Units);
     881  FreeAndNil(GameSystem);
    891882  inherited Destroy;
    892883end;
Note: See TracChangeset for help on using the changeset viewer.