Changeset 198


Ignore:
Timestamp:
May 16, 2018, 1:38:11 PM (6 years ago)
Author:
chronos
Message:
  • Added: Capture all special cells objective is now functional. Number of such cells can be specified. They are randomly spread across map and such cells are marked with "!" symbol after its number of units.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormNew.lfm

    r197 r198  
    505505          'Stay alive for number of turns'
    506506        )
     507        OnChange = ComboBoxWinObjectiveChange
    507508        Style = csDropDownList
    508509        TabOrder = 1
     
    540541        TabOrder = 3
    541542      end
    542       object Label13: TLabel
    543         Left = 8
    544         Height = 20
    545         Top = 280
    546         Width = 111
    547         Caption = 'Number of turns:'
    548         ParentColor = False
    549       end
    550       object SpinEditTurns: TSpinEdit
    551         Left = 236
    552         Height = 28
    553         Top = 278
    554         Width = 159
    555         MaxValue = 1000
    556         MinValue = 1
     543      object PageControl2: TPageControl
     544        Left = 12
     545        Height = 78
     546        Top = 274
     547        Width = 756
     548        ActivePage = TabSheetCaptureCities
     549        Anchors = [akTop, akLeft, akRight]
     550        ShowTabs = False
     551        TabIndex = 1
    557552        TabOrder = 4
    558         Value = 1
     553        object TabSheetDefeatEnemies: TTabSheet
     554        end
     555        object TabSheetCaptureCities: TTabSheet
     556        end
     557        object TabSheetCaptureCells: TTabSheet
     558          ClientHeight = 70
     559          ClientWidth = 748
     560          object Label14: TLabel
     561            Left = 8
     562            Height = 20
     563            Top = 16
     564            Width = 125
     565            Caption = 'Special cells count:'
     566            ParentColor = False
     567          end
     568          object SpinEditSpecialCells: TSpinEdit
     569            Left = 236
     570            Height = 28
     571            Top = 8
     572            Width = 159
     573            MaxValue = 1000
     574            MinValue = 1
     575            TabOrder = 0
     576            Value = 1
     577          end
     578        end
     579        object TabSheetStayAliveTurns: TTabSheet
     580          ClientHeight = 70
     581          ClientWidth = 748
     582          object Label13: TLabel
     583            Left = 8
     584            Height = 20
     585            Top = 16
     586            Width = 111
     587            Caption = 'Number of turns:'
     588            ParentColor = False
     589          end
     590          object SpinEditTurns: TSpinEdit
     591            Left = 236
     592            Height = 28
     593            Top = 8
     594            Width = 159
     595            MaxValue = 1000
     596            MinValue = 1
     597            TabOrder = 0
     598            Value = 1
     599          end
     600        end
    559601      end
    560602    end
  • trunk/Forms/UFormNew.pas

    r197 r198  
    4646    Label12: TLabel;
    4747    Label13: TLabel;
     48    Label14: TLabel;
    4849    Label2: TLabel;
    4950    Label3: TLabel;
     
    6465    OpenPictureDialog1: TOpenPictureDialog;
    6566    PageControl1: TPageControl;
     67    PageControl2: TPageControl;
    6668    PanelButtons: TPanel;
    6769    PanelChat: TPanel;
     
    7375    RadioGroupGrowAmount: TRadioGroup;
    7476    RadioGroupGrowCells: TRadioGroup;
    75     SpinEditTurns: TSpinEdit;
    7677    SpinEditMaxPower: TSpinEdit;
    7778    SpinEditServerPort: TSpinEdit;
     
    8081    SpinEditMapSizeY: TSpinEdit;
    8182    SpinEditNeutralUnits: TSpinEdit;
     83    SpinEditSpecialCells: TSpinEdit;
     84    SpinEditTurns: TSpinEdit;
    8285    SpinEditVoidPercent: TSpinEdit;
    8386    Splitter1: TSplitter;
     
    8588    TabSheet2: TTabSheet;
    8689    TabSheet3: TTabSheet;
     90    TabSheetStayAliveTurns: TTabSheet;
     91    TabSheetCaptureCells: TTabSheet;
     92    TabSheetDefeatEnemies: TTabSheet;
     93    TabSheetCaptureCities: TTabSheet;
    8794    TabSheetMode: TTabSheet;
    8895    TrackBarSizeX: TTrackBar;
     
    98105    procedure CheckBoxVoidChange(Sender: TObject);
    99106    procedure ComboBoxMapShapeChange(Sender: TObject);
     107    procedure ComboBoxWinObjectiveChange(Sender: TObject);
    100108    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    101109    procedure FormCreate(Sender: TObject);
     
    151159  SWinObjectiveDefeatAllOponents = 'Defeat all oponents';
    152160  SWinObjectiveDefeatAllCities = 'Defeat all oponents cities';
    153   SWinObjectiveCapturePosition = 'Capture position';
     161  SWinObjectiveCapturePosition = 'Capture all special cells';
    154162  SWinObjectiveStayAliveForTurns = 'Stay alive for number of turns';
    155163  SGrowNone = 'None';
     
    371379begin
    372380  ReloadView;
     381end;
     382
     383procedure TFormNew.ComboBoxWinObjectiveChange(Sender: TObject);
     384begin
     385  PageControl2.TabIndex := ComboBoxWinObjective.ItemIndex;
    373386end;
    374387
     
    504517    SpinEditMaxPower.Value := Game.MaxPower;
    505518    SpinEditTurns.Value := Game.StayAliveForDefinedTurns;
     519    SpinEditSpecialCells.Value := Game.SpecialCaptureCellCount;
    506520  end;
    507521end;
     
    540554    Game.MaxPower := SpinEditMaxPower.Value;
    541555    Game.StayAliveForDefinedTurns := SpinEditTurns.Value;
     556    Game.SpecialCaptureCellCount := SpinEditSpecialCells.Value;
    542557  end;
    543558end;
  • trunk/Languages/xtactics.cs.po

    r197 r198  
    402402msgid "Number of turns:"
    403403msgstr "Počet tahů:"
     404
     405#: tformnew.label14.caption
     406msgid "Special cells count:"
     407msgstr "Počet speciálních buněk:"
    404408
    405409#: tformnew.label2.caption
     
    848852
    849853#: uformnew.swinobjectivecaptureposition
    850 msgid "Capture position"
    851 msgstr "Dobít pozici"
     854msgid "Capture all special cells"
     855msgstr "Dobít všechny speciální buňky"
    852856
    853857#: uformnew.swinobjectivedefeatallcities
     
    960964msgid "64-bit UInt read overflow."
    961965msgstr "Přetečení při čtení 64-bit UInt"
     966
  • trunk/Languages/xtactics.po

    r197 r198  
    387387#: tformnew.label13.caption
    388388msgid "Number of turns:"
     389msgstr ""
     390
     391#: tformnew.label14.caption
     392msgid "Special cells count:"
    389393msgstr ""
    390394
     
    827831
    828832#: uformnew.swinobjectivecaptureposition
    829 msgid "Capture position"
     833msgid "Capture all special cells"
    830834msgstr ""
    831835
  • trunk/UGame.pas

    r197 r198  
    3030
    3131  TTerrainType = (ttVoid, ttNormal, ttCity);
     32  TExtraType = (etNone, etObjectiveTarget, etAttack, etDefense, etLookout,
     33    etGrowLow, etGrowMedium, etGrowHigh);
    3234
    3335  { TCell }
     
    5557    Angle: Double; // Temporary value
    5658    Links: TCellLinks;
     59    Extra: TExtraType;
    5760    procedure ConnectTo(Cell: TCell);
    5861    procedure DisconnectFrom(Cell: TCell);
     
    8588    function FindById(Id: Integer): TCell;
    8689    procedure GetCellsWithWeight(List: TCells; Low, High: Integer);
     90    procedure GetCellsWithExtra(List: TCells; Extra: TExtraType);
    8791    procedure LoadFromNode(Node: TDOMNode);
    8892    procedure SaveToNode(Node: TDOMNode);
     
    439443    procedure PropagatePlayerDistance(List: TCells);
    440444    procedure InitDefaultPlayersSetting;
     445    procedure WinObjectiveMapPrepare;
    441446  public
    442447    DevelMode: Boolean;
     
    455460    TurnCounter: Integer;
    456461    WinObjective: TWinObjective;
    457     SpecialCaptureCell: TCell;
     462    SpecialCaptureCellCount: Integer;
    458463    StayAliveForDefinedTurns: Integer;
    459464    MaxNeutralUnits: Integer;
     
    10201025    if (Cell.Terrain <> ttVoid) and (Cell.Weight >= Low) and
    10211026      (Cell.Weight <= High) then List.Add(Cell);
     1027end;
     1028
     1029procedure TCells.GetCellsWithExtra(List: TCells; Extra: TExtraType);
     1030var
     1031  Cell: TCell;
     1032begin
     1033  List.Clear;
     1034  for Cell in Self do
     1035    if Cell.Extra = Extra then List.Add(Cell);
    10221036end;
    10231037
     
    14961510  TextSize: TSize;
    14971511begin
     1512  if Cell.Extra = etObjectiveTarget then begin
     1513    Text := Text + '!';
     1514  end;
    14981515  with Canvas do begin
    14991516    if Assigned(View.FocusedCell) and (View.FocusedCell = Cell) then begin
     
    15261543
    15271544    // Show cell text
    1528     if Text <> '0' then begin
     1545    if Cell.GetAvialPower <> 0 then begin
    15291546      Pen.Style := psSolid;
    15301547      Font.Color := clWhite;
     
    18901907  Power := ReadInteger(Node, 'Power', 0);
    18911908  Terrain := TTerrainType(ReadInteger(Node, 'Terrain', Integer(ttVoid)));
     1909  Extra := TExtraType(ReadInteger(Node, 'Extra', Integer(etNone)));
    18921910  PosPx.X := ReadInteger(Node, 'PosX', 0);
    18931911  PosPx.Y := ReadInteger(Node, 'PosY', 0);
     
    19251943  WriteInteger(Node, 'Power', Power);
    19261944  WriteInteger(Node, 'Terrain', Integer(Terrain));
     1945  WriteInteger(Node, 'Extra', Integer(Extra));
    19271946  WriteInteger(Node, 'PosX', PosPx.X);
    19281947  WriteInteger(Node, 'PosY', PosPx.Y);
     
    29662985        PaintCell(Canvas, Cell.PosPx, IntToStr(Cell.GetAvialPower), View, Cell);
    29672986      end;
    2968 
    29692987    end;
    29702988
     
    31883206end;
    31893207
     3208procedure TGame.WinObjectiveMapPrepare;
     3209var
     3210  Cell: TCell;
     3211  Cells: TCells;
     3212  I: Integer;
     3213begin
     3214  if WinObjective = woSpecialCaptureCell then begin
     3215    Cells := TCells.Create(False);
     3216    for I := 0 to Map.Cells.Count - 1 do
     3217    if (Map.Cells[I].Terrain <> ttVoid) and (Map.Cells[I].Extra <> etObjectiveTarget) then
     3218      Cells.Add(Map.Cells[I]);
     3219
     3220    for I := 0 to SpecialCaptureCellCount - 1 do begin
     3221      if Cells.Count = 0 then Break;
     3222      Cell := Cells[Random(Cells.Count)];
     3223      Cell.Extra := etObjectiveTarget;
     3224      Cells.Remove(Cell);
     3225    end;
     3226    Cells.Free;
     3227  end;
     3228end;
     3229
    31903230procedure TGame.SaveConfig(Config: TXmlConfig; Path: string);
    31913231begin
     
    32073247    SetValue(DOMString(Path + '/WinObjective'), Integer(WinObjective));
    32083248    SetValue(DOMString(Path + '/StayAliveForDefinedTurns'), StayAliveForDefinedTurns);
     3249    SetValue(DOMString(Path + '/SpecialCaptureCellCount'), SpecialCaptureCellCount);
    32093250    PlayersSetting.SaveConfig(Config, Path + '/Players');
    32103251  end;
     
    32403281      WinObjective := TWinObjective(Value) else WinObjective := Low(TWinObjective);
    32413282    StayAliveForDefinedTurns := GetValue(DOMString(Path + '/StayAliveForDefinedTurns'), 20);
     3283    SpecialCaptureCellCount := GetValue(DOMString(Path + '/SpecialCaptureCellCount'), 1);
    32423284    PlayersSetting.LoadConfig(Config, Path + '/Players');
    32433285  end;
     
    34123454  AlivePlayers: TPlayerArray;
    34133455  Winner: TPlayer;
     3456  Cells: TCells;
     3457  Player: TPlayer;
     3458  R: Boolean;
     3459  I: Integer;
    34143460begin
    34153461  Winner := nil;
     
    34293475  end else
    34303476  if WinObjective = woSpecialCaptureCell then begin
    3431     if Assigned(SpecialCaptureCell) and Assigned(SpecialCaptureCell.Player) then
    3432       EndGame(SpecialCaptureCell.Player);
     3477    Cells := TCells.Create(False);
     3478    Map.Cells.GetCellsWithExtra(Cells, etObjectiveTarget);
     3479    R := True;
     3480    for I := 0 to Cells.Count - 1 do begin
     3481      if I = 0 then Player := Cells[I].Player;
     3482      if not Assigned(Cells[I].Player) or (Cells[I].Player <> Player) then begin
     3483        R := False;
     3484        Break;
     3485      end;
     3486    end;
     3487    if R then EndGame(Player);
     3488    Cells.Free;
    34333489  end else
    34343490  if WinObjective = woStayAliveForDefinedTurns then begin
     
    34853541  Map.MaxPower := MaxPower;
    34863542  BuildTerrain;
     3543  WinObjectiveMapPrepare;
    34873544
    34883545  // Build bridges
  • trunk/xtactics.lpi

    r196 r198  
    244244        <IsPartOfProject Value="True"/>
    245245        <ComponentName Value="FormServer"/>
     246        <HasResources Value="True"/>
    246247        <ResourceBaseClass Value="Form"/>
    247248      </Unit24>
     
    278279    <Linking>
    279280      <Debugging>
    280         <UseHeaptrc Value="True"/>
    281281        <UseExternalDbgSyms Value="True"/>
    282282      </Debugging>
  • trunk/xtactics.lpr

    r196 r198  
    2525  // Heap trace
    2626  DeleteFile(ExtractFilePath(ParamStr(0)) + HeapTraceLog);
    27   SetHeapTraceOutput(ExtractFilePath(ParamStr(0)) + HeapTraceLog);
     27  //SetHeapTraceOutput(ExtractFilePath(ParamStr(0)) + HeapTraceLog);
    2828  {$ENDIF}
    2929
Note: See TracChangeset for help on using the changeset viewer.