Changeset 343


Ignore:
Timestamp:
Dec 22, 2024, 1:05:11 PM (7 hours ago)
Author:
chronos
Message:
  • Modified: Improved tests.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Map.pas

    r342 r343  
    177177    procedure Clear;
    178178    procedure CheckCells;
     179    function ToString: string; override;
    179180    constructor Create; virtual;
    180181    destructor Destroy; override;
     
    428429  Result := '';
    429430  for C in Self do
    430     Result := Result + IntToStr(C.Id) + ', ';
     431    Result := Result + C.ToString + LineEnding;
    431432end;
    432433
     
    759760end;
    760761
     762function TMap.ToString: string;
     763begin
     764  Result := 'MaxPower: ' + IntToStr(MaxPower) + LineEnding;
     765  Result := Result + 'Cyclic: ' + BoolToStr(Cyclic) + LineEnding;
     766  Result := Result + 'Size: ' + IntToStr(Size.X) + 'x' + IntToStr(Size.Y) + LineEnding;
     767  Result := Result + 'DefaultCellSize: ' + IntToStr(DefaultCellSize.X) + 'x' + IntToStr(DefaultCellSize.Y) + LineEnding;
     768  Result := Result + 'Shape: ' + IntToStr(Integer(Shape)) + LineEnding;
     769  Result := Result + Cells.ToString + LineEnding;
     770end;
     771
    761772constructor TMap.Create;
    762773begin
     
    11001111  Player := Source.Player;
    11011112  Mark := Source.Mark;
     1113  Extra := Source.Extra;
    11021114  // TODO: How to copy neighbours and moves list
    11031115end;
     
    11111123function TCell.ToString: ansistring;
    11121124begin
    1113   Result := IntToStr(Id);
     1125  Result := 'Id: ' + IntToStr(Id) + LineEnding;
     1126  Result := Result + 'PosPx: ' + IntToStr(PosPx.X) + 'x' + IntToStr(PosPx.Y) + LineEnding;
     1127  Result := Result + 'Terrain: ' + IntToStr(Integer(Terrain)) + LineEnding;
     1128  Result := Result + 'Extra: ' + IntToStr(Integer(Extra)) + LineEnding;
     1129  //Result := Result + 'Polygon: ' + IntToStr(Polygon) + LineEnding;
     1130  if Assigned(Player) then
     1131    Result := Result + 'Player: ' + IntToStr(TPlayer(Player).Id) + LineEnding;
     1132  Result := Result + 'Mark:' + BoolToStr(Mark) + LineEnding;
     1133  if Assigned(OneUnit) then
     1134    Result := Result + 'OneUnit:' + IntToStr(OneUnit.Id) + LineEnding;
    11141135end;
    11151136
  • trunk/Tests.pas

    r342 r343  
    5050const
    5151  FileName = 'Test.xtg';
     52  Size = 10;
    5253var
    5354  Game2: TGame;
    5455begin
     56  Game.Map.Size := TPoint.Create(Size, Size);
     57  Game.MapType := mtSquare;
     58  Game.New;
    5559  Game.SaveToFile(FileName);
    5660  Game2 := TGame.Create;
Note: See TracChangeset for help on using the changeset viewer.