Changeset 273 for trunk/UGame.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/UGame.pas

    r271 r273  
    2424    class procedure PolygonEx(Canvas: TCanvas; const Points: array of Classes.TPoint; Winding: Boolean);
    2525    class procedure PolyLineEx(Canvas: TCanvas; const Points: array of Classes.TPoint);
     26    class procedure Ellipse(Canvas: TCanvas; const ARect: TRect);
    2627  end;
    2728
     
    191192end;
    192193
     194class procedure TCanvasEx.Ellipse(Canvas: TCanvas; const ARect: TRect);
     195begin
     196  LCLIntf.Ellipse(Canvas.Handle, ARect.P1.X, ARect.P1.Y, ARect.P2.X, ARect.P2.Y);
     197end;
     198
    193199{ TGame }
    194200
     
    289295var
    290296  Cell: TCell;
     297  NewPower: Integer;
    291298begin
    292299  // Randomize map terrain
     
    296303    (Map.IsOutsideShape(PosPx)) then Terrain := ttVoid
    297304      else Terrain := ttNormal;
    298     if not Assigned(OneUnit) then
    299       OneUnit := Units.AddNew(GameSystem.UnitKinds[0], Random(MaxNeutralUnits + 1));
     305    NewPower := Random(MaxNeutralUnits + 1);
     306    if (NewPower > 0) and not Assigned(OneUnit) then begin
     307      OneUnit := Units.AddNew(GameSystem.UnitKinds[0], NewPower);
     308    end;
    300309    Player := nil;
    301310  end;
     
    512521    SetValue(DOMString(Path + '/StayAliveForDefinedTurns'), StayAliveForDefinedTurns);
    513522    SetValue(DOMString(Path + '/SpecialCaptureCellCount'), SpecialCaptureCellCount);
     523    SetValue(DOMString(Path + '/MaxNeutralUnits'), MaxNeutralUnits);
     524    SetValue(DOMString(Path + '/MaxPower'), MaxPower);
    514525    Players.SaveConfig(Config, Path + '/Players');
    515526  end;
     
    548559    StayAliveForDefinedTurns := GetValue(DOMString(Path + '/StayAliveForDefinedTurns'), 20);
    549560    SpecialCaptureCellCount := GetValue(DOMString(Path + '/SpecialCaptureCellCount'), 1);
     561    MaxNeutralUnits := GetValue(DOMString(Path + '/MaxNeutralUnits'), 5);
     562    MaxPower := GetValue(DOMString(Path + '/MaxPower'), 99);
    550563    Players.LoadConfig(Config, Path + '/Players');
    551564  end;
     
    730743  CurrentPlayer.Grow;
    731744  CurrentPlayer.UpdateEmptyCellsNeutral;
     745  CurrentPlayer.RemoveEmptyUnits;
    732746  CurrentPlayer.UpdateRepeatMoves;
    733747  ComputePlayerStats;
Note: See TracChangeset for help on using the changeset viewer.