Changeset 285 for trunk/UPlayer.pas


Ignore:
Timestamp:
Mar 10, 2019, 11:57:03 PM (6 years ago)
Author:
chronos
Message:
  • Modified: More work on item class with defined form fields.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UPlayer.pas

    r284 r285  
    77uses
    88  Classes, SysUtils, Graphics, UMap, DOM, fgl, XMLConf, UXMLUtils, Math,
    9   UGeometry, UUnit, UNation;
     9  UGeometry, UUnit, UNation, UItemList;
    1010
    1111type
     
    9292  { TPlayer }
    9393
    94   TPlayer = class
     94  TPlayer = class(TItem)
    9595  private
    9696    FGame: TObject; //TGame;
     
    104104    procedure SetMode(AValue: TPlayerMode);
    105105  public
    106     Id: Integer;
    107     Name: string;
    108106    Color: TColor;
    109107    TotalUnits: Integer;
     
    121119    Units: TUnits;
    122120    Nation: TNation;
     121    function GetFields: TItemFields; override;
     122    procedure GetValue(Index: Integer; out Value); override;
     123    procedure SetValue(Index: Integer; var Value); override;
     124    class function GetClassSysName: string; override;
    123125    function IsAllowedMoveTarget(CellFrom, CellTo: TPlayerCell): Boolean;
    124126    procedure ReduceMovesPower;
     
    135137    function IsAlive: Boolean;
    136138    procedure Clear;
    137     procedure LoadFromNode(Node: TDOMNode);
    138     procedure SaveToNode(Node: TDOMNode);
     139    procedure LoadFromNode(Node: TDOMNode); override;
     140    procedure SaveToNode(Node: TDOMNode); override;
    139141    constructor Create;
    140142    destructor Destroy; override;
    141     procedure Assign(Source: TPlayer);
     143    procedure Assign(Source: TItem); override;
    142144    procedure LoadConfig(Config: TXmlConfig; Path: string);
    143145    procedure SaveConfig(Config: TXmlConfig; Path: string);
     
    880882end;
    881883
    882 procedure TPlayer.Assign(Source: TPlayer);
     884procedure TPlayer.Assign(Source: TItem);
    883885begin
    884886  Id := Source.Id;
    885887  Name := Source.Name;
    886   Color := Source.Color;
    887   Mode := Source.Mode;
    888   Game := Source.Game;
    889   TotalCells := Source.TotalCells;
    890   TotalUnits := Source.TotalUnits;
    891   TotalCities := Source.TotalCities;
    892   TotalDiscovered := Source.TotalDiscovered;
    893   TotalWinObjectiveCells := Source.TotalWinObjectiveCells;
    894   StartUnits := Source.StartUnits;
    895   StartCell := Source.StartCell;
    896   Agressivity := Source.Agressivity;
    897   Defensive := Source.Defensive;
    898   Nation := Source.Nation;
     888  Color := TPlayer(Source).Color;
     889  Mode := TPlayer(Source).Mode;
     890  Game := TPlayer(Source).Game;
     891  TotalCells := TPlayer(Source).TotalCells;
     892  TotalUnits := TPlayer(Source).TotalUnits;
     893  TotalCities := TPlayer(Source).TotalCities;
     894  TotalDiscovered := TPlayer(Source).TotalDiscovered;
     895  TotalWinObjectiveCells := TPlayer(Source).TotalWinObjectiveCells;
     896  StartUnits := TPlayer(Source).StartUnits;
     897  StartCell := TPlayer(Source).StartCell;
     898  Agressivity := TPlayer(Source).Agressivity;
     899  Defensive := TPlayer(Source).Defensive;
     900  Nation := TPlayer(Source).Nation;
    899901end;
    900902
     
    12611263  if FMode = AValue then Exit;
    12621264  FMode := AValue;
     1265end;
     1266
     1267function TPlayer.GetFields: TItemFields;
     1268begin
     1269  Result := inherited;
     1270  Result.AddField(2, 'Color', 'Color', dtColor);
     1271  Result.AddField(3, 'Mode', 'Mode', dtInteger);
     1272  Result.AddField(4, 'StartUnits', 'StartUnits', dtInteger);
     1273  Result.AddField(5, 'Agressivity', 'Agressivity', dtInteger);
     1274  Result.AddField(6, 'Defensive', 'Defensive', dtBoolean);
     1275end;
     1276
     1277procedure TPlayer.GetValue(Index: Integer; out Value);
     1278begin
     1279  inherited GetValue(Index, Value);
     1280end;
     1281
     1282procedure TPlayer.SetValue(Index: Integer; var Value);
     1283begin
     1284  inherited SetValue(Index, Value);
     1285end;
     1286
     1287class function TPlayer.GetClassSysName: string;
     1288begin
     1289  Result := 'Player';
    12631290end;
    12641291
Note: See TracChangeset for help on using the changeset viewer.