Changeset 345 for trunk/Map.pas


Ignore:
Timestamp:
Dec 23, 2024, 11:25:36 AM (9 hours ago)
Author:
chronos
Message:
  • Modified: Improved test cases.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Map.pas

    r343 r345  
    4848    Extra: TExtraType;
    4949    OneUnitId: Integer; // Temporary value
     50    function Compare(Cell: TCell): Boolean;
    5051    procedure ConnectTo(Cell: TCell);
    5152    procedure DisconnectFrom(Cell: TCell);
     
    8081    procedure LoadFromNode(Node: TDOMNode);
    8182    procedure SaveToNode(Node: TDOMNode);
     83    function Compare(Cells: TCells): Boolean;
    8284    procedure ClearMark;
    8385    procedure ClearWeight;
     
    409411end;
    410412
     413function TCells.Compare(Cells: TCells): Boolean;
     414var
     415  I: Integer;
     416begin
     417  Result := True;
     418  for I := 0 to Count - 1 do
     419  with Items[I] do begin
     420    if not Items[I].Compare(Cells[I]) then begin
     421      Result := False;
     422      Break;
     423    end;
     424  end;
     425end;
     426
    411427procedure TCells.ClearMark;
    412428var
     
    543559function TMap.Compare(Map: TMap): Boolean;
    544560begin
    545   Result := True;
     561  Result := (MaxPower = Map.MaxPower) and
     562    (Cyclic = Map.Cyclic) and
     563    (Size = Map.Size) and
     564    (DefaultCellSize = Map.DefaultCellSize) and
     565    (Shape = Map.Shape) and
     566    Cells.Compare(Map.Cells);
    546567end;
    547568
     
    942963end;
    943964
     965function TCell.Compare(Cell: TCell): Boolean;
     966begin
     967  Result := (Id = Cell.Id) and
     968    (PosPx = Cell.PosPx) and
     969    (Terrain = Cell.Terrain) and
     970    Polygon.Compare(Cell.Polygon) and
     971    (Player = Cell.Player) and
     972    (Mark = Cell.Mark) and
     973    (Extra = Cell.Extra);
     974end;
     975
    944976procedure TCell.ConnectTo(Cell: TCell);
    945977begin
Note: See TracChangeset for help on using the changeset viewer.