1 | unit UnitKind;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, ItemList;
|
---|
7 |
|
---|
8 | type
|
---|
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 |
|
---|
33 | implementation
|
---|
34 |
|
---|
35 | resourcestring
|
---|
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 |
|
---|
46 | class function TUnitKind.GetFields: TItemFields;
|
---|
47 | begin
|
---|
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);
|
---|
55 | end;
|
---|
56 |
|
---|
57 | procedure TUnitKind.GetValue(Index: Integer; out Value);
|
---|
58 | begin
|
---|
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;
|
---|
67 | end;
|
---|
68 |
|
---|
69 | procedure TUnitKind.SetValue(Index: Integer; var Value);
|
---|
70 | begin
|
---|
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;
|
---|
79 | end;
|
---|
80 |
|
---|
81 | class function TUnitKind.GetClassSysName: string;
|
---|
82 | begin
|
---|
83 | Result := 'UnitKind';
|
---|
84 | end;
|
---|
85 |
|
---|
86 | class function TUnitKind.GetClassName: string;
|
---|
87 | begin
|
---|
88 | Result := SUnitKind;
|
---|
89 | end;
|
---|
90 |
|
---|
91 | { TUnitKinds }
|
---|
92 |
|
---|
93 | constructor TUnitKinds.Create(FreeObjects: Boolean);
|
---|
94 | begin
|
---|
95 | inherited;
|
---|
96 | end;
|
---|
97 |
|
---|
98 | class function TUnitKinds.GetItemClass: TItemClass;
|
---|
99 | begin
|
---|
100 | Result := TUnitKind;
|
---|
101 | end;
|
---|
102 |
|
---|
103 | end.
|
---|
104 |
|
---|