Changeset 337 for trunk/Player.pas


Ignore:
Timestamp:
Sep 8, 2024, 10:29:37 PM (2 months ago)
Author:
chronos
Message:
  • Added: Game systems action in Tools menu.
  • Modified: TurnStats moved to separate unit.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Player.pas

    r336 r337  
    55uses
    66  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;
    88
    99type
     
    6767    Update: Boolean; var Confirm: Boolean) of object;
    6868  TMoveUpdatedEvent = procedure(UnitMove: TUnitMove) of object;
    69 
    70   { TGameTurnStat }
    71 
    72   TGameTurnStat = class
    73     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;
    8869
    8970  { TPlayer }
     
    13201301end;
    13211302
    1322 { TGameTurnStat }
    1323 
    1324 procedure TGameTurnStat.LoadFromNode(Node: TDOMNode);
    1325 begin
    1326   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 begin
    1335   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 var
    1346   Node2: TDOMNode;
    1347   NewTurnStat: TGameTurnStat;
    1348 begin
    1349   Count := 0;
    1350   Node2 := Node.FirstChild;
    1351   while Assigned(Node2) and (Node2.NodeName = 'TurnStat') do begin
    1352     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 var
    1361   I: Integer;
    1362   NewNode: TDOMNode;
    1363 begin
    1364   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 
    13711303end.
    13721304
Note: See TracChangeset for help on using the changeset viewer.