Changeset 37 for trunk


Ignore:
Timestamp:
Oct 13, 2019, 5:20:58 PM (5 years ago)
Author:
chronos
Message:
  • Fixed: Initial tiles in moves history were not correctly initialized.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r36 r37  
    8888  Core.PersistentForm1.Load(Self);
    8989  UpdateInterface;
    90   if Core.Game.Board.GetEmptyTilesCount > Core.Game.Board.Size.X * Core.Game.Board.Size.Y - 2 then
     90  if Core.Game.Board.GetEmptyTilesCount > Core.Game.Board.Size.X * Core.Game.Board.Size.Y -
     91    InitialTileCount then
    9192    Core.Game.New;
    9293end;
  • trunk/UGame.pas

    r36 r37  
    152152  );
    153153  DirectionText: array[TMoveDirection] of string = ('None', 'Left', 'Up', 'Right', 'Down');
     154  InitialTileCount = 2;
    154155
    155156resourcestring
     
    482483    Result := EmptyTiles[Random(EmptyTiles.Count)];
    483484    Result.Value := NewValue;
    484     if RecordHistory then begin
    485       SetLength(History.InitialTilesPos, Length(History.InitialTilesPos) + 1);
    486       History.InitialTilesPos[Length(History.InitialTilesPos) - 1] := Result.Index;
    487     end;
    488485  end;
    489486  EmptyTiles.Free;
     
    529526  Running := True;
    530527  History.Clear;
    531   for I := 0 to 1 do
    532     FillRandomTile(0);
     528  if RecordHistory then begin
     529    for I := 0 to InitialTileCount - 1 do begin
     530      SetLength(History.InitialTilesPos, Length(History.InitialTilesPos) + 1);
     531      History.InitialTilesPos[Length(History.InitialTilesPos) - 1] := FillRandomTile(0).Index;
     532    end;
     533  end else begin
     534    for I := 0 to InitialTileCount - 1 do
     535      FillRandomTile(0);
     536  end;
    533537  DoChange;
    534538end;
Note: See TracChangeset for help on using the changeset viewer.