Changeset 339 for trunk/Unit.pas
- Timestamp:
- Sep 9, 2024, 10:50:10 PM (8 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Unit.pas
r336 r339 4 4 5 5 uses 6 Classes, SysUtils, Generics.Collections, Geometry, DOM, XML, ItemList ;6 Classes, SysUtils, Generics.Collections, Geometry, DOM, XML, ItemList, UnitKind; 7 7 8 8 type 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 33 9 TUnit = class 34 10 private … … 81 57 Player, Map, Game; 82 58 83 resourcestring84 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 begin96 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 begin107 if Index = 1 then string(Value) := Name108 else if Index = 2 then Integer(Value) := Power109 else if Index = 3 then Integer(Value) := Cost110 else if Index = 4 then Integer(Value) := Moves111 else if Index = 5 then Integer(Value) := PowerAttack112 else if Index = 6 then Integer(Value) := PowerDefense113 else if Index = 7 then Integer(Value) := ViewRange114 else inherited;115 end;116 117 procedure TUnitKind.SetValue(Index: Integer; var Value);118 begin119 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 begin131 Result := 'UnitKind';132 end;133 134 class function TUnitKind.GetClassName: string;135 begin136 Result := SUnitKind;137 end;138 139 59 { TUnits } 140 60 … … 309 229 end; 310 230 311 { TUnitKinds }312 313 constructor TUnitKinds.Create(FreeObjects: Boolean);314 begin315 inherited;316 end;317 318 class function TUnitKinds.GetItemClass: TItemClass;319 begin320 Result := TUnitKind;321 end;322 323 231 end. 324 232
Note:
See TracChangeset
for help on using the changeset viewer.