Changeset 70 for trunk/UGame.pas


Ignore:
Timestamp:
Sep 28, 2014, 6:04:57 PM (10 years ago)
Author:
chronos
Message:
  • Added: Support for symetric map usable for two players game.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UGame.pas

    r69 r70  
    190190    TotalCities: Integer;
    191191    StartUnits: Integer;
     192    StartCell: TCell;
    192193    procedure LoadFromNode(Node: TDOMNode);
    193194    procedure SaveToNode(Node: TDOMNode);
     
    278279    VoidEnabled: Boolean;
    279280    VoidPercentage: Integer;
     281    SymetricMap: Boolean;
    280282    GrowCells: TGrowCells;
    281283    GrowAmount: TGrowAmount;
     
    291293    FileName: string;
    292294    function AttackProbability(AttackCount, DefendCount, Depth: Integer): Double;
     295    procedure LoadConfig(Config: TXmlConfig; Path: string);
    293296    procedure SaveConfig(Config: TXmlConfig; Path: string);
    294     procedure LoadConfig(Config: TXmlConfig; Path: string);
    295297    procedure LoadFromFile(FileName: string);
    296298    procedure SaveToFile(FileName: string);
     
    14001402  View := TView.Create;
    14011403  StartUnits := DefaultPlayerStartUnits;
     1404  StartCell := nil;
    14021405end;
    14031406
     
    14171420  TotalUnits := Source.TotalUnits;
    14181421  StartUnits := Source.StartUnits;
     1422  StartCell := Source.StartCell;
    14191423  View.Assign(Source.View);
    14201424end;
     
    14311435  AttackerDiceCount: Integer;
    14321436  DefenderDiceCount: Integer;
    1433   AttackerHighestRoll: Integer;
    1434   DefenderHighestRoll: Integer;
    1435   RollResult: Integer;
    14361437  S: string;
    14371438  I: Integer;
     
    16861687  with Config do begin
    16871688    SetValue(Path + '/GridType', Integer(MapType));
     1689    SetValue(Path + '/SymetricMap', SymetricMap);
    16881690    SetValue(Path + '/VoidEnabled', VoidEnabled);
    16891691    SetValue(Path + '/VoidPercentage', VoidPercentage);
     
    17041706  with Config do begin
    17051707    MapType := TMapType(GetValue(Path + '/GridType', Integer(mtHexagon)));
     1708    SymetricMap := GetValue(Path + '/SymetricMap', False);
    17061709    VoidEnabled := GetValue(Path + '/VoidEnabled', True);
    17071710    VoidPercentage := GetValue(Path + '/VoidPercentage', 20);
     
    17311734    RootNode := Doc.DocumentElement;
    17321735    with RootNode do begin
     1736      SymetricMap := ReadBoolean(RootNode, 'SymetricMap', False);
    17331737      VoidEnabled := ReadBoolean(RootNode, 'VoidEnabled', False);
    17341738      VoidPercentage := ReadInteger(RootNode, 'VoidPercentage', 0);
     
    17731777    AppendChild(RootNode);
    17741778    with RootNode do begin
     1779      WriteBoolean(RootNode, 'SymetricMap', SymetricMap);
    17751780      WriteBoolean(RootNode, 'VoidEnabled', VoidEnabled);
    17761781      WriteInteger(RootNode, 'VoidPercentage', VoidPercentage);
     
    19341939procedure TGame.New;
    19351940var
    1936   X, Y: Integer;
    1937   NewCell: TCell;
    19381941  I: Integer;
    19391942  StartCell: TCell;
     
    19561959    Player := nil;
    19571960  end;
     1961
     1962  if SymetricMap then begin
     1963    for C := 0 to Map.Cells.Count div 2 - 1 do begin
     1964      TCell(Map.Cells[C]).Terrain :=
     1965        TCell(Map.Cells[Map.Cells.Count - 1 - C]).Terrain;
     1966      TCell(Map.Cells[C]).Power :=
     1967        TCell(Map.Cells[Map.Cells.Count - 1 - C]).Power;
     1968    end;
     1969  end;
     1970
    19581971  for I := 0 to Players.Count - 1 do
    19591972  with TPlayer(Players[I]) do begin
     
    19691982          raise Exception.Create(SCannotSetPlayerStartCells);
    19701983      end;
     1984      if SymetricMap and (I = 1) then
     1985        StartCell := TCell(Map.Cells[Map.Cells.Count - 1 - Map.Cells.IndexOf(TPlayer(Players[0]).StartCell)]);
     1986
    19711987      StartCell.Terrain := ttCity;
    19721988      StartCell.Player := TPlayer(Players[I]);
Note: See TracChangeset for help on using the changeset viewer.