Changeset 274 for trunk/UGameSystem.pas


Ignore:
Timestamp:
Feb 3, 2019, 8:32:20 PM (6 years ago)
Author:
chronos
Message:
  • Added: Keep information about available unit moves during turn.
  • Added: Allow to move units instantly during turn.
  • Added: Game system parameter to play without possibility to merge/split units.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UGameSystem.pas

    r265 r274  
    66
    77uses
    8   Classes, SysUtils, fgl, UUnit, DOM, UXMLUtils;
     8  Classes, SysUtils, fgl, UUnit, DOM, UXMLUtils, XMLConf;
    99
    1010type
     
    1515  TGameSystem = class
    1616    Name: string;
    17     ActionExecutionPhase: TActionExecutionPhase;
    1817    MaxPlayerCount: Integer;
    1918    UnitKinds: TUnitKinds;
    20     CanSplitMerge: Boolean;
     19    UnitsSplitMerge: Boolean;
    2120    EmptyCellsNeutral: Boolean;
     21    UnitsMoveImmediately: Boolean;
    2222    constructor Create;
    2323    destructor Destroy; override;
     
    2727    procedure LoadFromFile(FileName: string);
    2828    procedure SaveToFile(FileName: string);
     29    procedure LoadConfig(Config: TXmlConfig; Path: string);
     30    procedure SaveConfig(Config: TXmlConfig; Path: string);
    2931  end;
    3032
     
    6264begin
    6365  Name := Source.Name;
     66  UnitsMoveImmediately := Source.UnitsMoveImmediately;
    6467  MaxPlayerCount := Source.MaxPlayerCount;
    65   CanSplitMerge := Source.CanSplitMerge;
     68  UnitsSplitMerge := Source.UnitsSplitMerge;
    6669  EmptyCellsNeutral := Source.EmptyCellsNeutral;
    6770end;
     
    7275begin
    7376  Name := ReadString(Node, 'Name', '');
    74   CanSplitMerge := ReadBoolean(Node, 'CanSplitMerge', False);
     77  UnitsSplitMerge := ReadBoolean(Node, 'UnitsSplitMerge', False);
    7578  EmptyCellsNeutral := ReadBoolean(Node, 'EmptyCellsNeutral', False);
     79  UnitsMoveImmediately := ReadBoolean(Node, 'UnitsMoveImmediately', False);
    7680
    7781  NewNode := Node.FindNode('UnitKinds');
     
    8589begin
    8690  WriteString(Node, 'Name', Name);
    87   WriteBoolean(Node, 'CanSplitMerge', CanSplitMerge);
     91  WriteBoolean(Node, 'UnitsSplitMerge', UnitsSplitMerge);
    8892  WriteBoolean(Node, 'EmptyCellsNeutral', EmptyCellsNeutral);
     93  WriteBoolean(Node, 'UnitsMoveImmediately', UnitsMoveImmediately);
    8994
    9095  NewNode := Node.OwnerDocument.CreateElement('UnitKinds');
     
    103108end;
    104109
     110procedure TGameSystem.LoadConfig(Config: TXmlConfig; Path: string);
     111begin
     112  with Config do begin
     113    Self.Name := string(GetValue(DOMString(Path + '/Name'), DOMString('')));
     114    UnitsSplitMerge := GetValue(DOMString(Path + '/UnitsSplitMerge'), True);
     115    EmptyCellsNeutral := GetValue(DOMString(Path + '/EmptyCellsNeutral'), False);
     116    UnitsMoveImmediately := GetValue(DOMString(Path + '/UnitsMoveImmediately'), False);
     117  end;
     118end;
     119
     120procedure TGameSystem.SaveConfig(Config: TXmlConfig; Path: string);
     121begin
     122  with Config do begin
     123    SetValue(DOMString(Path + '/Name'), DOMString(Self.Name));
     124    SetValue(DOMString(Path + '/UnitsSplitMerge'), UnitsSplitMerge);
     125    SetValue(DOMString(Path + '/EmptyCellsNeutral'), EmptyCellsNeutral);
     126    SetValue(DOMString(Path + '/UnitsMoveImmediately'), UnitsMoveImmediately);
     127  end;
     128end;
     129
    105130end.
    106131
Note: See TracChangeset for help on using the changeset viewer.