Changeset 38


Ignore:
Timestamp:
Mar 8, 2014, 10:34:55 PM (11 years ago)
Author:
chronos
Message:
  • Added: Support for cities. Cities can be used as only growing cells.
  • Added: Allow to set grow rate as square root of cell power.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormNew.lfm

    r36 r38  
    11object FormNew: TFormNew
    22  Left = 706
    3   Height = 516
     3  Height = 526
    44  Top = 455
    55  Width = 716
    66  Caption = 'New game'
    7   ClientHeight = 516
     7  ClientHeight = 526
    88  ClientWidth = 716
    99  OnCreate = FormCreate
     
    1414    Left = 632
    1515    Height = 25
    16     Top = 479
     16    Top = 490
    1717    Width = 75
     18    Anchors = [akRight, akBottom]
    1819    Caption = 'Ok'
    1920    ModalResult = 1
     
    2324    Left = 544
    2425    Height = 25
    25     Top = 480
     26    Top = 491
    2627    Width = 75
     28    Anchors = [akBottom]
    2729    Caption = 'Cancel'
    2830    ModalResult = 2
     
    3234    Left = 16
    3335    Height = 24
    34     Top = 172
    35     Width = 175
     36    Top = 276
     37    Width = 194
    3638    Caption = 'Inaccessible places'
    3739    OnChange = CheckBoxVoidChange
     
    8991    Left = 16
    9092    Height = 22
    91     Top = 224
    92     Width = 88
     93    Top = 184
     94    Width = 99
    9395    Caption = 'Map width:'
    9496    ParentColor = False
     
    9799    Left = 136
    98100    Height = 32
    99     Top = 219
     101    Top = 179
    100102    Width = 98
    101103    MinValue = 2
     
    107109    Left = 136
    108110    Height = 32
    109     Top = 270
     111    Top = 230
    110112    Width = 98
    111113    MinValue = 2
     
    127129    Left = 224
    128130    Height = 32
    129     Top = 168
     131    Top = 272
    130132    Width = 106
    131133    MinValue = 1
     
    136138    Left = 339
    137139    Height = 22
    138     Top = 173
    139     Width = 15
     140    Top = 277
     141    Width = 17
    140142    Caption = '%'
    141143    ParentColor = False
     
    144146    Left = 248
    145147    Height = 43
    146     Top = 216
     148    Top = 176
    147149    Width = 451
    148150    Max = 100
     
    157159    Left = 248
    158160    Height = 43
    159     Top = 264
     161    Top = 224
    160162    Width = 451
    161163    Max = 100
     
    170172    Left = 16
    171173    Height = 22
     174    Top = 232
     175    Width = 106
     176    Caption = 'Map height:'
     177    ParentColor = False
     178  end
     179  object CheckBoxCity: TCheckBox
     180    Left = 16
     181    Height = 24
     182    Top = 316
     183    Width = 73
     184    Caption = 'Cities'
     185    OnChange = CheckBoxCityChange
     186    TabOrder = 12
     187  end
     188  object SpinEditCityPercent: TSpinEdit
     189    Left = 224
     190    Height = 32
     191    Top = 312
     192    Width = 106
     193    MinValue = 1
     194    TabOrder = 13
     195    Value = 1
     196  end
     197  object Label4: TLabel
     198    Left = 339
     199    Height = 22
     200    Top = 317
     201    Width = 17
     202    Caption = '%'
     203    ParentColor = False
     204  end
     205  object RadioGroupGrowAmount: TRadioGroup
     206    Left = 376
     207    Height = 76
    172208    Top = 272
    173     Width = 94
    174     Caption = 'Map height:'
    175     ParentColor = False
     209    Width = 241
     210    AutoFill = True
     211    Caption = 'Per turn grow amount'
     212    ChildSizing.LeftRightSpacing = 6
     213    ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
     214    ChildSizing.EnlargeVertical = crsHomogenousChildResize
     215    ChildSizing.ShrinkHorizontal = crsScaleChilds
     216    ChildSizing.ShrinkVertical = crsScaleChilds
     217    ChildSizing.Layout = cclLeftToRightThenTopToBottom
     218    ChildSizing.ControlsPerLine = 1
     219    ClientHeight = 52
     220    ClientWidth = 237
     221    Items.Strings = (
     222      'By one'
     223      'By square root'
     224    )
     225    TabOrder = 14
     226  end
     227  object RadioGroupGrowCells: TRadioGroup
     228    Left = 16
     229    Height = 105
     230    Top = 360
     231    Width = 185
     232    AutoFill = True
     233    Caption = 'Growing cells'
     234    ChildSizing.LeftRightSpacing = 6
     235    ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
     236    ChildSizing.EnlargeVertical = crsHomogenousChildResize
     237    ChildSizing.ShrinkHorizontal = crsScaleChilds
     238    ChildSizing.ShrinkVertical = crsScaleChilds
     239    ChildSizing.Layout = cclLeftToRightThenTopToBottom
     240    ChildSizing.ControlsPerLine = 1
     241    ClientHeight = 81
     242    ClientWidth = 181
     243    Items.Strings = (
     244      'None'
     245      'Player cities'
     246      'Player all'
     247    )
     248    TabOrder = 15
    176249  end
    177250end
  • trunk/Forms/UFormNew.lrt

    r36 r38  
    1313TFORMNEW.LABEL3.CAPTION=%
    1414TFORMNEW.LABEL2.CAPTION=Map height:
     15TFORMNEW.CHECKBOXCITY.CAPTION=Cities
     16TFORMNEW.LABEL4.CAPTION=%
     17TFORMNEW.RADIOGROUPGROWAMOUNT.CAPTION=Per turn grow amount
     18TFORMNEW.RADIOGROUPGROWCELLS.CAPTION=Growing cells
  • trunk/Forms/UFormNew.pas

    r36 r38  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ComCtrls, Spin, UGame;
     9  ComCtrls, Spin, ExtCtrls, UGame;
    1010
    1111type
     
    2020    ButtonPlayerModify: TButton;
    2121    CheckBoxVoid: TCheckBox;
     22    CheckBoxCity: TCheckBox;
    2223    Label1: TLabel;
    2324    Label2: TLabel;
    2425    Label3: TLabel;
     26    Label4: TLabel;
    2527    ListView1: TListView;
     28    RadioGroupGrowCells: TRadioGroup;
     29    RadioGroupGrowAmount: TRadioGroup;
    2630    SpinEditVoidPercent: TSpinEdit;
    2731    SpinEditMapSizeX: TSpinEdit;
    2832    SpinEditMapSizeY: TSpinEdit;
     33    SpinEditCityPercent: TSpinEdit;
    2934    TrackBarSizeX: TTrackBar;
    3035    TrackBarSizeY: TTrackBar;
     
    3338    procedure ButtonPlayerModifyClick(Sender: TObject);
    3439    procedure ButtonPlayerRemoveClick(Sender: TObject);
     40    procedure CheckBoxCityChange(Sender: TObject);
    3541    procedure CheckBoxVoidChange(Sender: TObject);
    3642    procedure FormCreate(Sender: TObject);
     
    128134end;
    129135
     136procedure TFormNew.CheckBoxCityChange(Sender: TObject);
     137begin
     138  SpinEditCityPercent.Enabled := CheckBoxCity.Checked;
     139end;
     140
    130141procedure TFormNew.CheckBoxVoidChange(Sender: TObject);
    131142begin
     
    177188    TPlayer(Players[I]).Assign(TPlayer(Game.Players[I]));
    178189  end;
     190  CheckBoxCity.Checked := Game.CityEnabled;
     191  SpinEditCityPercent.Value := Game.CityPercentage;
    179192  SpinEditMapSizeX.Value := Game.Map.Size.X;
    180193  SpinEditMapSizeY.Value := Game.Map.Size.Y;
     194  RadioGroupGrowAmount.ItemIndex := Integer(Game.GrowAmount);
     195  RadioGroupGrowCells.ItemIndex := Integer(Game.GrowCells);
    181196end;
    182197
     
    195210  Game.VoidEnabled := CheckBoxVoid.Checked;
    196211  Game.VoidPercentage := SpinEditVoidPercent.Value;
     212  Game.CityEnabled := CheckBoxCity.Checked;
     213  Game.CityPercentage := SpinEditCityPercent.Value;
    197214  Game.Map.Size := Point(SpinEditMapSizeX.Value, SpinEditMapSizeY.Value);
     215  Game.GrowAmount := TGrowAmount(RadioGroupGrowAmount.ItemIndex);
     216  Game.GrowCells := TGrowCells(RadioGroupGrowCells.ItemIndex);
    198217end;
    199218
  • trunk/Languages/xtactics.cs.po

    r36 r38  
    149149msgstr "Nová hra"
    150150
     151#: tformnew.checkboxcity.caption
     152msgid "Cities"
     153msgstr "Města"
     154
    151155#: tformnew.checkboxvoid.caption
    152156msgid "Inaccessible places"
     
    154158
    155159#: tformnew.label1.caption
    156 #, fuzzy
    157160#| msgid "Map size:"
    158161msgid "Map width:"
    159 msgstr "Velikost mapy:"
     162msgstr "Šířka mapy:"
    160163
    161164#: tformnew.label2.caption
    162 #, fuzzy
    163165#| msgid "x"
    164166msgid "Map height:"
    165 msgstr "x"
     167msgstr "Výška mapy:"
    166168
    167169#: tformnew.label3.caption
     170msgctxt "tformnew.label3.caption"
     171msgid "%"
     172msgstr "%"
     173
     174#: tformnew.label4.caption
     175msgctxt "tformnew.label4.caption"
    168176msgid "%"
    169177msgstr "%"
     
    184192msgid "Start units"
    185193msgstr "Počátečních jednotek"
     194
     195#: tformnew.radiogroupgrowamount.caption
     196msgid "Per turn grow amount"
     197msgstr "Množství růstu za tah"
     198
     199#: tformnew.radiogroupgrowcells.caption
     200msgid "Growing cells"
     201msgstr "Rostoucí buňky:"
    186202
    187203#: tformplayer.buttoncancel.caption
     
    256272msgid "You need at least two players"
    257273msgstr "Potřebujete alespoň dva hráče"
    258 
  • trunk/Languages/xtactics.po

    r36 r38  
    139139msgstr ""
    140140
     141#: tformnew.checkboxcity.caption
     142msgid "Cities"
     143msgstr ""
     144
    141145#: tformnew.checkboxvoid.caption
    142146msgid "Inaccessible places"
     
    152156
    153157#: tformnew.label3.caption
     158msgctxt "tformnew.label3.caption"
     159msgid "%"
     160msgstr ""
     161
     162#: tformnew.label4.caption
     163msgctxt "TFORMNEW.LABEL4.CAPTION"
    154164msgid "%"
    155165msgstr ""
     
    169179#: tformnew.listview1.columns[3].caption
    170180msgid "Start units"
     181msgstr ""
     182
     183#: tformnew.radiogroupgrowamount.caption
     184msgid "Per turn grow amount"
     185msgstr ""
     186
     187#: tformnew.radiogroupgrowcells.caption
     188msgid "Growing cells"
    171189msgstr ""
    172190
  • trunk/UGame.pas

    r37 r38  
    2424  TPointArray = array of TPoint;
    2525
    26   TTerrainType = (ttVoid, ttNormal);
     26  TTerrainType = (ttVoid, ttNormal, ttCity);
    2727
    2828  { TCell }
     
    160160    Update: Boolean; var Confirm: Boolean) of object;
    161161  TWinEvent = procedure(Player: TPlayer) of object;
     162  TGrowAmount = (gaByOne, gaBySquareRoot);
     163  TGrowCells = (gcNone, gcPlayerCities, gcPlayerAll);
    162164
    163165  TGame = class
     
    177179    VoidEnabled: Boolean;
    178180    VoidPercentage: Integer;
     181    GrowCells: TGrowCells;
     182    GrowAmount: TGrowAmount;
     183    CityEnabled: Boolean;
     184    CityPercentage: Integer;
    179185    CurrentPlayer: TPlayer;
    180186    Moves: TObjectList; // TList<TMove>
     
    499505      CanAttack := 0;
    500506      for I := 0 to Length(Cells) - 1 do
    501       if (Cells[I].Player <> Self) then begin
     507      if (Cells[I].Player <> Self) and (Cells[I].Terrain <> ttVoid) then begin
    502508        Inc(CanAttack);
    503509      end;
     
    729735    SetValue(Path + '/MapSizeX', Map.Size.X);
    730736    SetValue(Path + '/MapSizeY', Map.Size.Y);
     737    SetValue(Path + '/CityEnabled', CityEnabled);
     738    SetValue(Path + '/CityPercentage', CityPercentage);
     739    SetValue(Path + '/GrowAmount', Integer(GrowAmount));
     740    SetValue(Path + '/GrowCells', Integer(GrowCells));
    731741  end;
    732742end;
     
    739749    Map.Size := Point(GetValue(Path + '/MapSizeX', 15),
    740750      GetValue(Path + '/MapSizeY', 15));
     751    CityEnabled := GetValue(Path + '/CityEnabled', True);
     752    CityPercentage := GetValue(Path + '/CityPercentage', 10);
     753    GrowAmount := TGrowAmount(GetValue(Path + '/GrowAmount', Integer(gaBySquareRoot)));
     754    GrowCells := TGrowCells(GetValue(Path + '/GrowCells', Integer(gcPlayerAll)));
    741755  end;
    742756end;
     
    841855  with Map.Cells[Y, X] do begin
    842856    if VoidEnabled and (Random < VoidPercentage / 100) then Terrain := ttVoid
    843       else Terrain := ttNormal;
     857      else begin
     858        if CityEnabled and (Random < CityPercentage / 100) then Terrain := ttCity
     859          else Terrain := ttNormal;
     860      end;
    844861    Power := Random(4);
    845862    Player := nil;
     
    858875          raise Exception.Create('Cannot choose start cell for player');
    859876      end;
    860       StartCell.Terrain := ttNormal;
     877      if CityEnabled then StartCell.Terrain := ttCity
     878        else StartCell.Terrain := ttNormal;
    861879      StartCell.Player := TPlayer(Players[I]);
    862880      StartCell.Power := TPlayer(Players[I]).StartUnits;
     
    950968      end;
    951969      if (CX >= 0) and (CY >= 0) and (CY < Size.Y) and (CX < Size.X) then
    952       if Cells[CY, CX].Terrain = ttNormal then begin
     970      if Cells[CY, CX].Terrain <> ttVoid then begin
    953971        Points := GetHexagonPolygon(Point(Trunc(X * CellSize.X),
    954972          Trunc(Y * CellSize.Y)),
     
    10041022      Pen.Style := psSolid;
    10051023      Pen.Width := 1;
     1024    end else
     1025    if TCell(Cells[CY, CX]).Terrain = ttCity then begin
     1026      // Cannot set clear border as it will display shifted on gtk2
     1027      //Pen.Style := psClear;
     1028      Pen.Color := clBlack;
     1029      Pen.Style := psSolid;
     1030      Pen.Width := 3;
    10061031    end else begin
    1007       Pen.Color := clBlack;
    10081032      // Cannot set clear border as it will display shifted on gtk2
    10091033      //Pen.Style := psClear;
     
    10381062      if (CX >= 0) and (CY >= 0) and (CY < Size.Y) and (CX < Size.X) then begin
    10391063        Cell := Cells[CY, CX];
    1040         if Cell.Terrain = ttNormal then begin
     1064        if Cell.Terrain <> ttVoid then begin
    10411065          if Assigned(SelectedCell) and (SelectedCell = TCell(Cells[CY, CX])) then Brush.Color := clGreen
    10421066            else if Assigned(SelectedCell) and IsCellsNeighbor(SelectedCell, TCell(Cells[CY, CX])) then Brush.Color := clPurple
     
    10821106var
    10831107  X, Y: Integer;
     1108  Addition: Integer;
    10841109begin
    10851110  for Y := 0 to Size.Y - 1 do
    10861111  for X := 0 to Size.X - 1 do
    10871112  with TCell(Cells[Y, X]) do begin
    1088     if Player = APlayer then begin
    1089       Power := Power + 1;
     1113    if (Player = APlayer) and ((Game.GrowCells = gcPlayerAll) or
     1114    ((Game.GrowCells = gcPlayerCities) and (Terrain = ttCity))) then begin
     1115      if Game.GrowAmount = gaByOne then Addition := 1
     1116        else if Game.GrowAmount = gaBySquareRoot then begin
     1117          Addition := Trunc(Sqrt(Power));
     1118          if Addition = 0 then Addition := 1;
     1119        end;
     1120      Power := Power + Addition;
    10901121      if Power > MaxPower then Power := MaxPower;
    10911122    end;
Note: See TracChangeset for help on using the changeset viewer.