source: trunk/UnitKind.pas

Last change on this file was 339, checked in by chronos, 3 months ago
  • Modified: Moved unit kinds into separate unit.
File size: 2.5 KB
Line 
1unit UnitKind;
2
3interface
4
5uses
6 Classes, SysUtils, ItemList;
7
8type
9 { TUnitKind }
10
11 TUnitKind = class(TItem)
12 PowerAttack: Integer;
13 PowerDefense: Integer;
14 Moves: Integer;
15 Cost: Integer;
16 Power: Integer;
17 ViewRange: Integer;
18 class function GetFields: TItemFields; override;
19 procedure GetValue(Index: Integer; out Value); override;
20 procedure SetValue(Index: Integer; var Value); override;
21 class function GetClassSysName: string; override;
22 class function GetClassName: string; override;
23 end;
24
25 { TUnitKinds }
26
27 TUnitKinds = class(TItemList)
28 constructor Create(FreeObjects: Boolean = True);
29 class function GetItemClass: TItemClass; override;
30 end;
31
32
33implementation
34
35resourcestring
36 SStack = 'Stack';
37 SCost = 'Cost';
38 SMoves = 'Moves';
39 SPowerAttack = 'Attack power';
40 SPowerDefense = 'Defense power';
41 SViewRange = 'View range';
42 SUnitKind = 'Unit kind';
43
44{ TUnitKind }
45
46class function TUnitKind.GetFields: TItemFields;
47begin
48 Result := inherited;
49 Result.AddField(2, 'Stack', SStack, dtInteger);
50 Result.AddField(3, 'Cost', SCost, dtInteger);
51 Result.AddField(4, 'Moves', SMoves, dtInteger);
52 Result.AddField(5, 'PowerAttack', SPowerAttack, dtInteger);
53 Result.AddField(6, 'PowerDefense', SPowerDefense, dtInteger);
54 Result.AddField(7, 'ViewRange', SViewRange, dtInteger);
55end;
56
57procedure TUnitKind.GetValue(Index: Integer; out Value);
58begin
59 if Index = 1 then string(Value) := Name
60 else if Index = 2 then Integer(Value) := Power
61 else if Index = 3 then Integer(Value) := Cost
62 else if Index = 4 then Integer(Value) := Moves
63 else if Index = 5 then Integer(Value) := PowerAttack
64 else if Index = 6 then Integer(Value) := PowerDefense
65 else if Index = 7 then Integer(Value) := ViewRange
66 else inherited;
67end;
68
69procedure TUnitKind.SetValue(Index: Integer; var Value);
70begin
71 if Index = 1 then Name := string(Value)
72 else if Index = 2 then Power := Integer(Value)
73 else if Index = 3 then Cost := Integer(Value)
74 else if Index = 4 then Moves := Integer(Value)
75 else if Index = 5 then PowerAttack := Integer(Value)
76 else if Index = 6 then PowerDefense := Integer(Value)
77 else if Index = 7 then ViewRange := Integer(Value)
78 else inherited;
79end;
80
81class function TUnitKind.GetClassSysName: string;
82begin
83 Result := 'UnitKind';
84end;
85
86class function TUnitKind.GetClassName: string;
87begin
88 Result := SUnitKind;
89end;
90
91{ TUnitKinds }
92
93constructor TUnitKinds.Create(FreeObjects: Boolean);
94begin
95 inherited;
96end;
97
98class function TUnitKinds.GetItemClass: TItemClass;
99begin
100 Result := TUnitKind;
101end;
102
103end.
104
Note: See TracBrowser for help on using the repository browser.