Changeset 273 for trunk/UPlayer.pas


Ignore:
Timestamp:
Jan 30, 2019, 8:08:44 AM (6 years ago)
Author:
chronos
Message:
  • Added: Show units shape to see in which cell units are placed.
  • Fixed: Do not place units with zero power in zero power cells.
  • Fixed: Better checks of cell power if cell is without unit.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UPlayer.pas

    r265 r273  
    122122    procedure ReduceMovesPower;
    123123    procedure RemoveInvalidMoves;
     124    procedure RemoveEmptyUnits;
    124125    procedure UpdateRepeatMoves;
    125126    procedure UpdateEmptyCellsNeutral;
     
    10591060    if Moves[I].CellFrom.MapCell.Player <> Self then
    10601061      Moves.Delete(I);
     1062end;
     1063
     1064procedure TPlayer.RemoveEmptyUnits;
     1065var
     1066  I: Integer;
     1067  OneUnit: TUnit;
     1068begin
     1069  for I := 0 to PlayerMap.Cells.Count - 1 do
     1070  with TPlayerCell(PlayerMap.Cells[I]) do begin
     1071    if Assigned(MapCell.OneUnit) and (MapCell.OneUnit.Power = 0) then begin
     1072      OneUnit := MapCell.OneUnit;
     1073      MapCell.OneUnit := nil;
     1074      Units.Remove(OneUnit);
     1075    end;
     1076  end;
    10611077end;
    10621078
     
    11541170  for I := 0 to PlayerMap.Cells.Count - 1 do
    11551171  with TPlayerCell(PlayerMap.Cells[I]) do begin
    1156     if MapCell.OneUnit.Power = 0 then MapCell.Player := nil;
     1172    if Assigned(MapCell.OneUnit) and (MapCell.OneUnit.Power = 0) then
     1173      MapCell.Player := nil;
    11571174  end;
    11581175end;
Note: See TracChangeset for help on using the changeset viewer.