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<TUnitKind>)
|
---|
28 | constructor Create(FreeObjects: Boolean = True);
|
---|
29 | end;
|
---|
30 |
|
---|
31 |
|
---|
32 | implementation
|
---|
33 |
|
---|
34 | resourcestring
|
---|
35 | SStack = 'Stack';
|
---|
36 | SCost = 'Cost';
|
---|
37 | SMoves = 'Moves';
|
---|
38 | SPowerAttack = 'Attack power';
|
---|
39 | SPowerDefense = 'Defense power';
|
---|
40 | SViewRange = 'View range';
|
---|
41 | SUnitKind = 'Unit kind';
|
---|
42 |
|
---|
43 | { TUnitKind }
|
---|
44 |
|
---|
45 | class function TUnitKind.GetFields: TItemFields;
|
---|
46 | begin
|
---|
47 | Result := inherited;
|
---|
48 | Result.AddField(2, 'Stack', SStack, dtInteger);
|
---|
49 | Result.AddField(3, 'Cost', SCost, dtInteger);
|
---|
50 | Result.AddField(4, 'Moves', SMoves, dtInteger);
|
---|
51 | Result.AddField(5, 'PowerAttack', SPowerAttack, dtInteger);
|
---|
52 | Result.AddField(6, 'PowerDefense', SPowerDefense, dtInteger);
|
---|
53 | Result.AddField(7, 'ViewRange', SViewRange, dtInteger);
|
---|
54 | end;
|
---|
55 |
|
---|
56 | procedure TUnitKind.GetValue(Index: Integer; out Value);
|
---|
57 | begin
|
---|
58 | if Index = 1 then string(Value) := Name
|
---|
59 | else if Index = 2 then Integer(Value) := Power
|
---|
60 | else if Index = 3 then Integer(Value) := Cost
|
---|
61 | else if Index = 4 then Integer(Value) := Moves
|
---|
62 | else if Index = 5 then Integer(Value) := PowerAttack
|
---|
63 | else if Index = 6 then Integer(Value) := PowerDefense
|
---|
64 | else if Index = 7 then Integer(Value) := ViewRange
|
---|
65 | else inherited;
|
---|
66 | end;
|
---|
67 |
|
---|
68 | procedure TUnitKind.SetValue(Index: Integer; var Value);
|
---|
69 | begin
|
---|
70 | if Index = 1 then Name := string(Value)
|
---|
71 | else if Index = 2 then Power := Integer(Value)
|
---|
72 | else if Index = 3 then Cost := Integer(Value)
|
---|
73 | else if Index = 4 then Moves := Integer(Value)
|
---|
74 | else if Index = 5 then PowerAttack := Integer(Value)
|
---|
75 | else if Index = 6 then PowerDefense := Integer(Value)
|
---|
76 | else if Index = 7 then ViewRange := Integer(Value)
|
---|
77 | else inherited;
|
---|
78 | end;
|
---|
79 |
|
---|
80 | class function TUnitKind.GetClassSysName: string;
|
---|
81 | begin
|
---|
82 | Result := 'UnitKind';
|
---|
83 | end;
|
---|
84 |
|
---|
85 | class function TUnitKind.GetClassName: string;
|
---|
86 | begin
|
---|
87 | Result := SUnitKind;
|
---|
88 | end;
|
---|
89 |
|
---|
90 | { TUnitKinds }
|
---|
91 |
|
---|
92 | constructor TUnitKinds.Create(FreeObjects: Boolean);
|
---|
93 | begin
|
---|
94 | inherited;
|
---|
95 | end;
|
---|
96 |
|
---|
97 | end.
|
---|
98 |
|
---|