Changeset 337 for trunk/Player.pas
- Timestamp:
- Sep 8, 2024, 10:29:37 PM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Player.pas
r336 r337 5 5 uses 6 6 Classes, SysUtils, Graphics, Map, DOM, Generics.Collections, Generics.Defaults, 7 XMLConf, XML, Math, Geometry, &Unit, Nation, ItemList ;7 XMLConf, XML, Math, Geometry, &Unit, Nation, ItemList, TurnStats; 8 8 9 9 type … … 67 67 Update: Boolean; var Confirm: Boolean) of object; 68 68 TMoveUpdatedEvent = procedure(UnitMove: TUnitMove) of object; 69 70 { TGameTurnStat }71 72 TGameTurnStat = class73 OccupiedCells: Integer;74 Units: Integer;75 DiscoveredCells: Integer;76 Cities: Integer;77 WinObjectiveCells: Integer;78 procedure LoadFromNode(Node: TDOMNode);79 procedure SaveToNode(Node: TDOMNode);80 end;81 82 { TGameTurnStats }83 84 TGameTurnStats = class(TObjectList<TGameTurnStat>)85 procedure LoadFromNode(Node: TDOMNode);86 procedure SaveToNode(Node: TDOMNode);87 end;88 69 89 70 { TPlayer } … … 1320 1301 end; 1321 1302 1322 { TGameTurnStat }1323 1324 procedure TGameTurnStat.LoadFromNode(Node: TDOMNode);1325 begin1326 OccupiedCells := ReadInteger(Node, 'OccupiedCells', 0);1327 Units := ReadInteger(Node, 'Units', 0);1328 DiscoveredCells := ReadInteger(Node, 'DiscoveredCells', 0);1329 Cities := ReadInteger(Node, 'Cities', 0);1330 WinObjectiveCells := ReadInteger(Node, 'WinObjectiveCells', 0);1331 end;1332 1333 procedure TGameTurnStat.SaveToNode(Node: TDOMNode);1334 begin1335 WriteInteger(Node, 'OccupiedCells', OccupiedCells);1336 WriteInteger(Node, 'Units', Units);1337 WriteInteger(Node, 'DiscoveredCells', DiscoveredCells);1338 WriteInteger(Node, 'Cities', Cities);1339 WriteInteger(Node, 'WinObjectiveCells', WinObjectiveCells);1340 end;1341 1342 { TGameTurnStats }1343 1344 procedure TGameTurnStats.LoadFromNode(Node: TDOMNode);1345 var1346 Node2: TDOMNode;1347 NewTurnStat: TGameTurnStat;1348 begin1349 Count := 0;1350 Node2 := Node.FirstChild;1351 while Assigned(Node2) and (Node2.NodeName = 'TurnStat') do begin1352 NewTurnStat := TGameTurnStat.Create;1353 NewTurnStat.LoadFromNode(Node2);1354 Add(NewTurnStat);1355 Node2 := Node2.NextSibling;1356 end;1357 end;1358 1359 procedure TGameTurnStats.SaveToNode(Node: TDOMNode);1360 var1361 I: Integer;1362 NewNode: TDOMNode;1363 begin1364 for I := 0 to Count - 1 do begin;1365 NewNode := Node.OwnerDocument.CreateElement('TurnStat');1366 Node.AppendChild(NewNode);1367 Items[I].SaveToNode(NewNode);1368 end;1369 end;1370 1371 1303 end. 1372 1304
Note:
See TracChangeset
for help on using the changeset viewer.