Changeset 38 for trunk/UGame.pas
- Timestamp:
- Mar 8, 2014, 10:34:55 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r37 r38 24 24 TPointArray = array of TPoint; 25 25 26 TTerrainType = (ttVoid, ttNormal );26 TTerrainType = (ttVoid, ttNormal, ttCity); 27 27 28 28 { TCell } … … 160 160 Update: Boolean; var Confirm: Boolean) of object; 161 161 TWinEvent = procedure(Player: TPlayer) of object; 162 TGrowAmount = (gaByOne, gaBySquareRoot); 163 TGrowCells = (gcNone, gcPlayerCities, gcPlayerAll); 162 164 163 165 TGame = class … … 177 179 VoidEnabled: Boolean; 178 180 VoidPercentage: Integer; 181 GrowCells: TGrowCells; 182 GrowAmount: TGrowAmount; 183 CityEnabled: Boolean; 184 CityPercentage: Integer; 179 185 CurrentPlayer: TPlayer; 180 186 Moves: TObjectList; // TList<TMove> … … 499 505 CanAttack := 0; 500 506 for I := 0 to Length(Cells) - 1 do 501 if (Cells[I].Player <> Self) then begin507 if (Cells[I].Player <> Self) and (Cells[I].Terrain <> ttVoid) then begin 502 508 Inc(CanAttack); 503 509 end; … … 729 735 SetValue(Path + '/MapSizeX', Map.Size.X); 730 736 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)); 731 741 end; 732 742 end; … … 739 749 Map.Size := Point(GetValue(Path + '/MapSizeX', 15), 740 750 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))); 741 755 end; 742 756 end; … … 841 855 with Map.Cells[Y, X] do begin 842 856 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; 844 861 Power := Random(4); 845 862 Player := nil; … … 858 875 raise Exception.Create('Cannot choose start cell for player'); 859 876 end; 860 StartCell.Terrain := ttNormal; 877 if CityEnabled then StartCell.Terrain := ttCity 878 else StartCell.Terrain := ttNormal; 861 879 StartCell.Player := TPlayer(Players[I]); 862 880 StartCell.Power := TPlayer(Players[I]).StartUnits; … … 950 968 end; 951 969 if (CX >= 0) and (CY >= 0) and (CY < Size.Y) and (CX < Size.X) then 952 if Cells[CY, CX].Terrain = ttNormalthen begin970 if Cells[CY, CX].Terrain <> ttVoid then begin 953 971 Points := GetHexagonPolygon(Point(Trunc(X * CellSize.X), 954 972 Trunc(Y * CellSize.Y)), … … 1004 1022 Pen.Style := psSolid; 1005 1023 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; 1006 1031 end else begin 1007 Pen.Color := clBlack;1008 1032 // Cannot set clear border as it will display shifted on gtk2 1009 1033 //Pen.Style := psClear; … … 1038 1062 if (CX >= 0) and (CY >= 0) and (CY < Size.Y) and (CX < Size.X) then begin 1039 1063 Cell := Cells[CY, CX]; 1040 if Cell.Terrain = ttNormalthen begin1064 if Cell.Terrain <> ttVoid then begin 1041 1065 if Assigned(SelectedCell) and (SelectedCell = TCell(Cells[CY, CX])) then Brush.Color := clGreen 1042 1066 else if Assigned(SelectedCell) and IsCellsNeighbor(SelectedCell, TCell(Cells[CY, CX])) then Brush.Color := clPurple … … 1082 1106 var 1083 1107 X, Y: Integer; 1108 Addition: Integer; 1084 1109 begin 1085 1110 for Y := 0 to Size.Y - 1 do 1086 1111 for X := 0 to Size.X - 1 do 1087 1112 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; 1090 1121 if Power > MaxPower then Power := MaxPower; 1091 1122 end;
Note:
See TracChangeset
for help on using the changeset viewer.