Changeset 294


Ignore:
Timestamp:
Mar 29, 2019, 8:40:42 AM (6 years ago)
Author:
chronos
Message:
  • Modified: Change terrain type ttCity to map cell building with special type stCity.
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Languages/xtactics.cs.po

    r290 r294  
    877877msgstr "Obecné"
    878878
    879 #: tformunitkind.buttoncancel.caption
    880 msgctxt "tformunitkind.buttoncancel.caption"
    881 msgid "Cancel"
    882 msgstr "Zrušit"
    883 
    884 #: tformunitkind.buttonok.caption
    885 msgctxt "tformunitkind.buttonok.caption"
    886 msgid "OK"
    887 msgstr "OK"
    888 
    889 #: tformunitkind.caption
    890 msgid "Unit kind"
    891 msgstr "Druh jednotky"
    892 
    893 #: tformunitkind.labelhealth.caption
    894 msgid "Health:"
    895 msgstr "Zdraví:"
    896 
    897 #: tformunitkind.labelname.caption
    898 msgctxt "tformunitkind.labelname.caption"
    899 msgid "Name:"
    900 msgstr "Jméno:"
    901 
    902 #: tformunitkinds.aadd.caption
    903 msgctxt "tformunitkinds.aadd.caption"
    904 msgid "Add"
    905 msgstr "Přidat"
    906 
    907 #: tformunitkinds.aclone.caption
    908 msgctxt "tformunitkinds.aclone.caption"
    909 msgid "Clone"
    910 msgstr "Klonovat"
    911 
    912 #: tformunitkinds.amodify.caption
    913 msgctxt "tformunitkinds.amodify.caption"
    914 msgid "Modify"
    915 msgstr "Upravit"
    916 
    917 #: tformunitkinds.aremove.caption
    918 msgctxt "tformunitkinds.aremove.caption"
    919 msgid "Remove"
    920 msgstr "Odstranit"
    921 
    922 #: tformunitkinds.aselectall.caption
    923 msgctxt "tformunitkinds.aselectall.caption"
    924 msgid "Select all"
    925 msgstr "Vybrat vše"
    926 
    927 #: tformunitkinds.caption
    928 msgid "Unit kinds"
    929 msgstr "Druhy jednotek"
    930 
    931 #: tformunitkinds.listview1.columns[0].caption
    932 msgctxt "tformunitkinds.listview1.columns[0].caption"
    933 msgid "Name"
    934 msgstr "Jméno"
    935 
    936879#: ubuilding.sbuildingkind
    937880msgctxt "ubuilding.sbuildingkind"
     
    940883
    941884#: ubuilding.scost
     885msgctxt "ubuilding.scost"
    942886msgid "Cost"
    943887msgstr "Cena"
     888
     889#: ubuilding.sspecialtype
     890msgid "Special type"
     891msgstr "Speciální typ"
    944892
    945893#: uclientgui.swrongarrowangle
     
    12001148msgstr "Opravdu chcete odstranit vybrané položky?"
    12011149
    1202 #: uformunitkinds.snewunitkind
    1203 msgid "New unit kind"
    1204 msgstr "Nový druh jednotky"
    1205 
    1206 #: uformunitkinds.sremoveitems
    1207 msgctxt "uformunitkinds.sremoveitems"
    1208 msgid "Remove items"
    1209 msgstr "Odstranit položky"
    1210 
    1211 #: uformunitkinds.sremoveitemsquery
    1212 msgctxt "uformunitkinds.sremoveitemsquery"
    1213 msgid "Do you want to remove selected items?"
    1214 msgstr "Opravdu chcete odstranit vybrané položky?"
    1215 
    12161150#: ugame.scomputer
    12171151msgctxt "ugame.scomputer"
     
    13411275msgstr "Neukončená bitva"
    13421276
     1277#: uunit.scost
     1278msgctxt "uunit.scost"
     1279msgid "Cost"
     1280msgstr "Cena"
     1281
     1282#: uunit.smoves
     1283msgid "Moves"
     1284msgstr "Pohyby"
     1285
     1286#: uunit.spowerattack
     1287msgid "Attack power"
     1288msgstr "Síla útoku"
     1289
     1290#: uunit.spowerdefense
     1291msgid "Defense power"
     1292msgstr "Síla obrany"
     1293
     1294#: uunit.sstack
     1295msgid "Stack"
     1296msgstr "Sada"
     1297
     1298#: uunit.sunitkind
     1299msgctxt "uunit.sunitkind"
     1300msgid "Unit kind"
     1301msgstr "Druh jednotky"
     1302
     1303#: uunit.sviewrange
     1304msgid "View range"
     1305msgstr "Dohled"
  • trunk/Languages/xtactics.po

    r290 r294  
    863863msgstr ""
    864864
    865 #: tformunitkind.buttoncancel.caption
    866 msgctxt "tformunitkind.buttoncancel.caption"
    867 msgid "Cancel"
    868 msgstr ""
    869 
    870 #: tformunitkind.buttonok.caption
    871 msgctxt "tformunitkind.buttonok.caption"
    872 msgid "OK"
    873 msgstr ""
    874 
    875 #: tformunitkind.caption
    876 msgid "Unit kind"
    877 msgstr ""
    878 
    879 #: tformunitkind.labelhealth.caption
    880 msgid "Health:"
    881 msgstr ""
    882 
    883 #: tformunitkind.labelname.caption
    884 msgctxt "tformunitkind.labelname.caption"
    885 msgid "Name:"
    886 msgstr ""
    887 
    888 #: tformunitkinds.aadd.caption
    889 msgctxt "tformunitkinds.aadd.caption"
    890 msgid "Add"
    891 msgstr ""
    892 
    893 #: tformunitkinds.aclone.caption
    894 msgctxt "tformunitkinds.aclone.caption"
    895 msgid "Clone"
    896 msgstr ""
    897 
    898 #: tformunitkinds.amodify.caption
    899 msgctxt "tformunitkinds.amodify.caption"
    900 msgid "Modify"
    901 msgstr ""
    902 
    903 #: tformunitkinds.aremove.caption
    904 msgctxt "tformunitkinds.aremove.caption"
    905 msgid "Remove"
    906 msgstr ""
    907 
    908 #: tformunitkinds.aselectall.caption
    909 msgctxt "tformunitkinds.aselectall.caption"
    910 msgid "Select all"
    911 msgstr ""
    912 
    913 #: tformunitkinds.caption
    914 msgid "Unit kinds"
    915 msgstr ""
    916 
    917 #: tformunitkinds.listview1.columns[0].caption
    918 msgctxt "tformunitkinds.listview1.columns[0].caption"
    919 msgid "Name"
    920 msgstr ""
    921 
    922865#: ubuilding.sbuildingkind
    923866msgctxt "ubuilding.sbuildingkind"
     
    926869
    927870#: ubuilding.scost
     871msgctxt "ubuilding.scost"
    928872msgid "Cost"
     873msgstr ""
     874
     875#: ubuilding.sspecialtype
     876msgid "Special type"
    929877msgstr ""
    930878
     
    11781126msgstr ""
    11791127
    1180 #: uformunitkinds.snewunitkind
    1181 msgid "New unit kind"
    1182 msgstr ""
    1183 
    1184 #: uformunitkinds.sremoveitems
    1185 msgctxt "uformunitkinds.sremoveitems"
    1186 msgid "Remove items"
    1187 msgstr ""
    1188 
    1189 #: uformunitkinds.sremoveitemsquery
    1190 msgctxt "uformunitkinds.sremoveitemsquery"
    1191 msgid "Do you want to remove selected items?"
    1192 msgstr ""
    1193 
    11941128#: ugame.scomputer
    11951129msgctxt "ugame.scomputer"
     
    13101244msgstr ""
    13111245
     1246#: uunit.scost
     1247msgctxt "uunit.scost"
     1248msgid "Cost"
     1249msgstr ""
     1250
     1251#: uunit.smoves
     1252msgid "Moves"
     1253msgstr ""
     1254
     1255#: uunit.spowerattack
     1256msgid "Attack power"
     1257msgstr ""
     1258
     1259#: uunit.spowerdefense
     1260msgid "Defense power"
     1261msgstr ""
     1262
     1263#: uunit.sstack
     1264msgid "Stack"
     1265msgstr ""
     1266
     1267#: uunit.sunitkind
     1268msgctxt "uunit.sunitkind"
     1269msgid "Unit kind"
     1270msgstr ""
     1271
     1272#: uunit.sviewrange
     1273msgid "View range"
     1274msgstr ""
     1275
  • trunk/Systems/HexWars.xts

    r292 r294  
    1717    </UnitKind>
    1818  </UnitKinds>
    19   <BuildingKinds/>
     19  <BuildingKinds>
     20    <BuildingKind>
     21      <Id>0</Id>
     22      <Name>City</Name>
     23      <Cost>0</Cost>
     24      <SpecialType>9515521</SpecialType>
     25    </BuildingKind>
     26  </BuildingKinds>
    2027  <Nations>
    2128    <Nation>
  • trunk/UBuilding.pas

    r290 r294  
    99
    1010type
     11  TBuildingSpecialType = (stNone, stCity);
    1112
    1213  { TBuildingKind }
     
    1415  TBuildingKind = class(TItem)
    1516    Cost: Integer;
     17    SpecialType: TBuildingSpecialType;
    1618    class function GetFields: TItemFields; override;
    1719    procedure GetValue(Index: Integer; out Value); override;
     
    2527  TBuildingKinds = class(TItemList)
    2628    class function GetItemClass: TItemClass; override;
     29    function FindBySpecialType(SpecialType: TBuildingSpecialType): TItem;
    2730  end;
    2831
    29   TBuilding = class
     32  { TBuilding }
     33
     34  TBuilding = class(TItem)
     35  private
     36    FMapCell: TObject;
     37    procedure SetMapCell(AValue: TObject);
     38  public
    3039    Kind: TBuildingKind;
     40    property MapCell: TObject read FMapCell write SetMapCell; // TMapCell;
     41  end;
     42
     43  { TBuildings }
     44
     45  TBuildings = class(TItemList)
     46    Game: TObject; // TGame;
     47    class function GetItemClass: TItemClass; override;
    3148  end;
    3249
     
    3451  SBuildingKind = 'Building';
    3552  SCost = 'Cost';
     53  SSpecialType = 'Special type';
    3654
    3755
    3856implementation
     57
     58uses
     59  UMap;
     60
     61{ TBuildings }
     62
     63class function TBuildings.GetItemClass: TItemClass;
     64begin
     65  Result := TBuilding;
     66end;
     67
     68{ TBuilding }
     69
     70procedure TBuilding.SetMapCell(AValue: TObject);
     71var
     72  OldValue: TCell;
     73begin
     74  if FMapCell = AValue then Exit;
     75  OldValue := TCell(FMapCell);
     76  FMapCell := nil;
     77  if Assigned(OldValue) then TCell(OldValue).Building := nil;
     78  FMapCell := AValue;
     79  if Assigned(FMapCell) then TCell(FMapCell).Building := Self;
     80end;
    3981
    4082{ TBuildingKind }
     
    4486  Result := inherited;
    4587  Result.AddField(2, 'Cost', SCost, dtInteger);
     88  Result.AddField(3, 'SpecialType', SSpecialType, dtInteger);
    4689end;
    4790
     
    5093  if Index = 1 then string(Value) := Name
    5194  else if Index = 2 then Integer(Value) := Cost
     95  else if Index = 3 then TBuildingSpecialType(Value) := SpecialType
    5296  else raise Exception.Create('Unsupported value index ' + IntToStr(Index));
    5397end;
     
    57101  if Index = 1 then Name := string(Value)
    58102  else if Index = 2 then Cost := Integer(Value)
     103  else if Index = 3 then SpecialType := TBuildingSpecialType(Value)
    59104  else raise Exception.Create('Unsupported value index ' + IntToStr(Index));
    60105end;
     
    77122end;
    78123
     124function TBuildingKinds.FindBySpecialType(SpecialType: TBuildingSpecialType
     125  ): TItem;
     126var
     127  I: Integer;
     128begin
     129  I := 0;
     130  while (I < Count) and (TBuildingKind(Items[I]).SpecialType <> SpecialType) do Inc(I);
     131  if I < Count then Result := Items[I]
     132    else Result := nil;
     133end;
     134
    79135end.
    80136
  • trunk/UClientGUI.pas

    r275 r294  
    7070implementation
    7171
     72uses
     73  UBuilding;
     74
    7275resourcestring
    7376  SZeroZoomNotAlowed = 'Zero zoom not allowed';
     
    179182      Pen.Width := 1;
    180183    end else
    181     if Cell.Terrain = ttCity then begin
     184    if Assigned(Cell.Building) and (Cell.Building.Kind.SpecialType = stCity) then begin
    182185      // Cannot set clear border as it will display shifted on gtk2
    183186      //Pen.Style := psClear;
     
    441444      for Cell in ControlPlayer.PlayerMap.Cells do begin
    442445        if (Cell.MapCell.Terrain <> ttVoid) and View.IsCellVisible(Cell.MapCell) then begin
    443           if Cell.MapCell.Terrain = ttCity then begin
     446          if Assigned(Cell.MapCell.Building) and (Cell.MapCell.Building.Kind.SpecialType = stCity) then begin
    444447            // Cannot set clear border as it will display shifted on gtk2
    445448            //Pen.Style := psClear;
     
    461464        if (MapCell.Terrain <> ttVoid) and View.IsCellVisible(MapCell) then begin
    462465          if View.IsCellVisible(MapCell) and (MapCell.Terrain <> ttVoid) then begin
    463             if MapCell.Terrain = ttCity then begin
     466            if Assigned(MapCell.Building) and (MapCell.Building.Kind.SpecialType = stCity) then begin
    464467              // Cannot set clear border as it will display shifted on gtk2
    465468              //Pen.Style := psClear;
  • trunk/UGame.pas

    r291 r294  
    77uses
    88  Classes, SysUtils, ExtCtrls, Graphics, XMLConf, XMLRead, XMLWrite, Forms,
    9   DOM, Math, LazFileUtils, UXMLUtils, Dialogs, LCLType, LCLIntf, fgl,
     9  DOM, Math, LazFileUtils, UXMLUtils, Dialogs, LCLType, LCLIntf, fgl, UBuilding,
    1010  UGeometry, UPlayer, UMap, UMapType, UUnit, UGameSystem;
    1111
     
    6464    Players: TPlayers;
    6565    Units: TUnits;
     66    Buildings: TBuildings;
    6667    Map: TMap;
    6768    MapImageFileName: string;
     
    315316  for Cell in Map.Cells do
    316317  with Cell do begin
    317     if (Terrain = ttNormal) and CityEnabled and (Random < CityPercentage / 100) then
    318       Terrain := ttCity;
     318    if (Terrain = ttNormal) and CityEnabled and (Random < CityPercentage / 100) then begin
     319      Building := TBuilding(Buildings.AddItem('City'));
     320      Building.Kind := TBuildingKind(GameSystem.BuildingKinds.FindBySpecialType(stCity));
     321    end;
    319322  end;
    320323end;
     
    341344          StartCell := Map.Cells[Map.Cells.Count - 1 - Map.Cells.IndexOf(Players[0].StartCell)];
    342345
    343         if CityEnabled then StartCell.Terrain := ttCity;
     346        if CityEnabled then begin
     347          StartCell.Building := TBuilding(Buildings.AddItem('City'));
     348          StartCell.Building.Kind := TBuildingKind(GameSystem.BuildingKinds.FindBySpecialType(stCity));
     349        end;
    344350        StartCell.Player := Player;
    345351        if not Assigned(StartCell.OneUnit) then
     
    855861  Units := TUnits.Create;
    856862  Units.Game := Self;
     863  Buildings := TBuildings.Create;
     864  Buildings.Game := Self;
    857865  Map := TMap.Create;
    858866  Map.Game := Self;
     
    878886  FreeAndNil(Players);
    879887  FreeAndNil(Map);
     888  FreeAndNil(Buildings);
    880889  FreeAndNil(Units);
    881890  inherited Destroy;
  • trunk/UItemList.pas

    r290 r294  
    1010type
    1111  TDataType = (dtNone, dtString, dtBoolean, dtInteger, dtFloat, dtColor,
    12     dtTime, dtDate, dtDateTime);
     12    dtTime, dtDate, dtDateTime, dtEnumeration);
    1313
    1414  { TItemField }
  • trunk/UMap.pas

    r265 r294  
    66
    77uses
    8   Classes, SysUtils, Graphics, ExtCtrls, UGeometry, DOM, fgl,
     8  Classes, SysUtils, Graphics, ExtCtrls, UGeometry, DOM, fgl, UBuilding,
    99  UXMLUtils, UUnit;
    1010
     
    1818  TCellLinks = class;
    1919
    20   TTerrainType = (ttVoid, ttNormal, ttCity);
     20  TTerrainType = (ttVoid, ttNormal, ttCityUnused);
    2121  TExtraType = (etNone, etObjectiveTarget, etAttack, etDefense, etLookout,
    2222    etGrowLow, etGrowMedium, etGrowHigh);
     
    2727  private
    2828    FArea: TMapArea;
     29    FBuilding: TBuilding;
    2930    FId: Integer;
    3031    FMap: TMap;
     
    3334    function GetPower: Integer;
    3435    procedure SetArea(AValue: TMapArea);
     36    procedure SetBuilding(AValue: TBuilding);
    3537    procedure SetId(AValue: Integer);
    3638    procedure SetPower(AValue: Integer);
     
    6769    property Area: TMapArea read FArea write SetArea;
    6870    property OneUnit: TUnit read FUnit write SetUnit;
     71    property Building: TBuilding read FBuilding write SetBuilding;
    6972    //property Power: Integer read GetPower;
    7073  end;
     
    619622      if Assigned(OneUnit) then
    620623        Inc(TotalUnits, OneUnit.Power);
    621       if Terrain = ttCity then
     624      if Assigned(Building) and (Building.Kind.SpecialType = stCity) then
    622625        Inc(TotalCities);
    623626      if Extra = etObjectiveTarget then
     
    968971end;
    969972
     973procedure TCell.SetBuilding(AValue: TBuilding);
     974var
     975  OldValue: TBuilding;
     976begin
     977  if FBuilding = AValue then Exit;
     978  OldValue := FBuilding;
     979  FBuilding := nil;
     980  if Assigned(OldValue) then OldValue.MapCell := nil;
     981  FBuilding := AValue;
     982  if Assigned(FBuilding) then FBuilding.MapCell := Self;
     983end;
     984
    970985function TCell.GetPower: Integer;
    971986begin
  • trunk/UPlayer.pas

    r291 r294  
    210210
    211211uses
    212   UGame, UGameSystem;
     212  UGame, UGameSystem, UBuilding;
    213213
    214214resourcestring
     
    13161316  with TCell(Cells[I]) do begin
    13171317    if (Player = Self) and ((TGame(Game).GrowCells = gcPlayerAll) or
    1318     ((TGame(Game).GrowCells = gcPlayerCities) and (Terrain = ttCity))) then begin
     1318    ((TGame(Game).GrowCells = gcPlayerCities) and (Assigned(Building) and (Building.Kind.SpecialType = stCity)))) then begin
    13191319      if not Assigned(OneUnit) then begin
    13201320        NewUnit := TGame(Game).Units.AddNew(TUnitKind(TGame(Game).GameSystem.UnitKinds.First), 0);
Note: See TracChangeset for help on using the changeset viewer.