Changeset 18 for trunk/UGame.pas


Ignore:
Timestamp:
Feb 26, 2014, 9:45:23 PM (11 years ago)
Author:
chronos
Message:
  • Add: Player start units setting.
  • Add: Allow add and remove players in new game dialog.
  • Fixed: Do not allow move from to same cell.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UGame.pas

    r17 r18  
    77uses
    88  Classes, SysUtils, ExtCtrls, Graphics, Contnrs;
     9
     10const
     11  DefaultPlayerStartUnits = 5;
    912
    1013type
     
    8083    TotalUnits: Integer;
    8184    TotalCells: Integer;
     85    StartUnits: Integer;
    8286    procedure ComputerTurn;
    8387    procedure SelectCell(Pos: TPoint);
    8488    procedure Paint(PaintBox: TPaintBox);
    8589    constructor Create;
     90    procedure Assign(Source: TPlayer);
     91  end;
     92
     93  TPlayers = class(TObjectList)
     94
    8695  end;
    8796
     
    105114    procedure SetMove(CellFrom, CellTo: TCell);
    106115  public
    107     Players: TObjectList; // TList<TPlayer>
     116    Players: TPlayers;
    108117    Map: THexMap;
    109118    VoidEnabled: Boolean;
     
    171180    not ((DX = -1) and (DY = -1)) and
    172181    not ((DX = 1) and (DY = 1))));
     182  Result := Result and not (Cell1 = Cell2);
    173183end;
    174184
     
    240250  ViewZoom := 1;
    241251  SelectedCell := nil;
     252  StartUnits := DefaultPlayerStartUnits;
     253end;
     254
     255procedure TPlayer.Assign(Source: TPlayer);
     256begin
     257  Name := Source.Name;
     258  Color := Source.Color;
     259  Mode := Source.Mode;
     260  Game := Source.Game;
     261  TotalCells := Source.TotalCells;
     262  TotalUnits := Source.TotalUnits;
     263  StartUnits := Source.StartUnits;
     264  SelectedCell := Source.SelectedCell;
     265  ViewZoom := Source.ViewZoom;
    242266end;
    243267
     
    365389  Randomize;
    366390
    367   Players := TObjectList.Create;
     391  Players := TPlayers.Create;
    368392  Player := TPlayer.Create;
    369393  Player.Name := 'Player 1';
     
    419443      StartCell.Terrain := ttNormal;
    420444      StartCell.Player := TPlayer(Players[I]);
     445      StartCell.Power := TPlayer(Players[I]).StartUnits;
    421446    end;
    422447  end;
Note: See TracChangeset for help on using the changeset viewer.