Changeset 339 for trunk/Unit.pas


Ignore:
Timestamp:
Sep 9, 2024, 10:50:10 PM (8 weeks ago)
Author:
chronos
Message:
  • Modified: Moved unit kinds into separate unit.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Unit.pas

    r336 r339  
    44
    55uses
    6   Classes, SysUtils, Generics.Collections, Geometry, DOM, XML, ItemList;
     6  Classes, SysUtils, Generics.Collections, Geometry, DOM, XML, ItemList, UnitKind;
    77
    88type
    9 
    10   { TUnitKind }
    11 
    12   TUnitKind = class(TItem)
    13     PowerAttack: Integer;
    14     PowerDefense: Integer;
    15     Moves: Integer;
    16     Cost: Integer;
    17     Power: Integer;
    18     ViewRange: Integer;
    19     class function GetFields: TItemFields; override;
    20     procedure GetValue(Index: Integer; out Value); override;
    21     procedure SetValue(Index: Integer; var Value); override;
    22     class function GetClassSysName: string; override;
    23     class function GetClassName: string; override;
    24   end;
    25 
    26   { TUnitKinds }
    27 
    28   TUnitKinds = class(TItemList)
    29     constructor Create(FreeObjects: Boolean = True);
    30     class function GetItemClass: TItemClass; override;
    31   end;
    32 
    339  TUnit = class
    3410  private
     
    8157  Player, Map, Game;
    8258
    83 resourcestring
    84   SStack = 'Stack';
    85   SCost = 'Cost';
    86   SMoves = 'Moves';
    87   SPowerAttack =  'Attack power';
    88   SPowerDefense = 'Defense power';
    89   SViewRange = 'View range';
    90   SUnitKind = 'Unit kind';
    91 
    92 { TUnitKind }
    93 
    94 class function TUnitKind.GetFields: TItemFields;
    95 begin
    96   Result := inherited;
    97   Result.AddField(2, 'Stack', SStack, dtInteger);
    98   Result.AddField(3, 'Cost', SCost, dtInteger);
    99   Result.AddField(4, 'Moves', SMoves, dtInteger);
    100   Result.AddField(5, 'PowerAttack', SPowerAttack, dtInteger);
    101   Result.AddField(6, 'PowerDefense', SPowerDefense, dtInteger);
    102   Result.AddField(7, 'ViewRange', SViewRange, dtInteger);
    103 end;
    104 
    105 procedure TUnitKind.GetValue(Index: Integer; out Value);
    106 begin
    107   if Index = 1 then string(Value) := Name
    108   else if Index = 2 then Integer(Value) := Power
    109   else if Index = 3 then Integer(Value) := Cost
    110   else if Index = 4 then Integer(Value) := Moves
    111   else if Index = 5 then Integer(Value) := PowerAttack
    112   else if Index = 6 then Integer(Value) := PowerDefense
    113   else if Index = 7 then Integer(Value) := ViewRange
    114   else inherited;
    115 end;
    116 
    117 procedure TUnitKind.SetValue(Index: Integer; var Value);
    118 begin
    119   if Index = 1 then Name := string(Value)
    120   else if Index = 2 then Power := Integer(Value)
    121   else if Index = 3 then Cost := Integer(Value)
    122   else if Index = 4 then Moves := Integer(Value)
    123   else if Index = 5 then PowerAttack := Integer(Value)
    124   else if Index = 6 then PowerDefense := Integer(Value)
    125   else if Index = 7 then ViewRange := Integer(Value)
    126   else inherited;
    127 end;
    128 
    129 class function TUnitKind.GetClassSysName: string;
    130 begin
    131   Result := 'UnitKind';
    132 end;
    133 
    134 class function TUnitKind.GetClassName: string;
    135 begin
    136   Result := SUnitKind;
    137 end;
    138 
    13959{ TUnits }
    14060
     
    309229end;
    310230
    311 { TUnitKinds }
    312 
    313 constructor TUnitKinds.Create(FreeObjects: Boolean);
    314 begin
    315   inherited;
    316 end;
    317 
    318 class function TUnitKinds.GetItemClass: TItemClass;
    319 begin
    320   Result := TUnitKind;
    321 end;
    322 
    323231end.
    324232
Note: See TracChangeset for help on using the changeset viewer.