Changeset 42
- Timestamp:
- Mar 18, 2014, 12:16:04 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMove.lfm
r40 r42 1 1 object FormMove: TFormMove 2 2 Left = 770 3 Height = 2 403 Height = 257 4 4 Top = 484 5 5 Width = 320 6 6 ActiveControl = ButtonOk 7 7 Caption = 'Move' 8 ClientHeight = 2 408 ClientHeight = 257 9 9 ClientWidth = 320 10 10 OnShow = FormShow … … 27 27 end 28 28 object ButtonOk: TButton 29 Left = 1 9229 Left = 184 30 30 Height = 25 31 Top = 20 031 Top = 208 32 32 Width = 75 33 33 Caption = 'Ok' … … 39 39 Left = 72 40 40 Height = 25 41 Top = 20 041 Top = 208 42 42 Width = 75 43 43 Caption = 'Cancel' … … 62 62 end 63 63 object TrackBarOnce: TTrackBar 64 Left = 864 Left = 56 65 65 Height = 43 66 66 Top = 55 67 Width = 2 9667 Width = 208 68 68 OnChange = TrackBarOnceChange 69 69 PageSize = 1 … … 74 74 end 75 75 object TrackBarRepeat: TTrackBar 76 Left = 876 Left = 56 77 77 Height = 43 78 78 Top = 152 79 Width = 30479 Width = 208 80 80 OnChange = TrackBarRepeatChange 81 81 PageSize = 1 … … 85 85 TabOrder = 5 86 86 end 87 object ButtonOnceMin: TButton 88 Left = 8 89 Height = 25 90 Top = 64 91 Width = 48 92 Caption = 'Min' 93 OnClick = uttonOnceMinClick 94 TabOrder = 6 95 end 96 object ButtonOnceMax: TButton 97 Left = 264 98 Height = 25 99 Top = 64 100 Width = 48 101 Anchors = [akTop, akRight] 102 Caption = 'Max' 103 OnClick = ButtonOnceMaxClick 104 TabOrder = 7 105 end 106 object ButtonRepeatMin: TButton 107 Left = 8 108 Height = 25 109 Top = 160 110 Width = 48 111 Caption = 'Min' 112 OnClick = ButtonRepeatMinClick 113 TabOrder = 8 114 end 115 object ButtonRepeatMax: TButton 116 Left = 264 117 Height = 25 118 Top = 160 119 Width = 48 120 Anchors = [akTop, akRight] 121 Caption = 'Max' 122 OnClick = ButtonRepeatMaxClick 123 TabOrder = 9 124 end 87 125 end -
trunk/Forms/UFormMove.lrt
r34 r42 4 4 TFORMMOVE.BUTTONCANCEL.CAPTION=Cancel 5 5 TFORMMOVE.LABEL2.CAPTION=Every turn: 6 TFORMMOVE.BUTTONONCEMIN.CAPTION=Min 7 TFORMMOVE.BUTTONONCEMAX.CAPTION=Max 8 TFORMMOVE.BUTTONREPEATMIN.CAPTION=Min 9 TFORMMOVE.BUTTONREPEATMAX.CAPTION=Max -
trunk/Forms/UFormMove.pas
r40 r42 14 14 15 15 TFormMove = class(TForm) 16 ButtonRepeatMax: TButton; 17 ButtonOnceMin: TButton; 18 ButtonOnceMax: TButton; 16 19 ButtonOk: TButton; 17 20 ButtonCancel: TButton; 21 ButtonRepeatMin: TButton; 18 22 Label1: TLabel; 19 23 Label2: TLabel; … … 22 26 TrackBarOnce: TTrackBar; 23 27 TrackBarRepeat: TTrackBar; 28 procedure ButtonOnceMaxClick(Sender: TObject); 29 procedure ButtonRepeatMinClick(Sender: TObject); 30 procedure uttonOnceMinClick(Sender: TObject); 31 procedure ButtonRepeatMaxClick(Sender: TObject); 24 32 procedure FormShow(Sender: TObject); 25 33 procedure SpinEditOnceChange(Sender: TObject); … … 65 73 end; 66 74 75 procedure TFormMove.ButtonOnceMaxClick(Sender: TObject); 76 begin 77 TrackBarOnce.Position := TrackBarRepeat.Max; 78 end; 79 80 procedure TFormMove.ButtonRepeatMinClick(Sender: TObject); 81 begin 82 TrackBarRepeat.Position := TrackBarRepeat.Min; 83 end; 84 85 procedure TFormMove.uttonOnceMinClick(Sender: TObject); 86 begin 87 TrackBarOnce.Position := TrackBarOnce.Min; 88 end; 89 90 procedure TFormMove.ButtonRepeatMaxClick(Sender: TObject); 91 begin 92 TrackBarRepeat.Position := TrackBarRepeat.Max; 93 end; 94 67 95 procedure TFormMove.SpinEditRepeatChange(Sender: TObject); 68 96 begin -
trunk/Forms/UFormNew.lfm
r41 r42 1 1 object FormNew: TFormNew 2 2 Left = 706 3 Height = 5053 Height = 614 4 4 Top = 455 5 5 Width = 716 6 6 Caption = 'New game' 7 ClientHeight = 5057 ClientHeight = 614 8 8 ClientWidth = 716 9 9 OnCreate = FormCreate … … 97 97 object Panel2: TPanel 98 98 Left = 0 99 Height = 33099 Height = 439 100 100 Top = 175 101 101 Width = 716 102 102 Align = alClient 103 103 BevelOuter = bvNone 104 ClientHeight = 330104 ClientHeight = 439 105 105 ClientWidth = 716 106 106 TabOrder = 2 … … 108 108 Left = 624 109 109 Height = 25 110 Top = 283110 Top = 392 111 111 Width = 75 112 112 Anchors = [akRight, akBottom] … … 118 118 Left = 535 119 119 Height = 25 120 Top = 283120 Top = 392 121 121 Width = 75 122 122 Anchors = [akBottom] … … 286 286 object ComboBoxGridType: TComboBox 287 287 Left = 312 288 Height = 3 4288 Height = 30 289 289 Top = 201 290 290 Width = 208 … … 305 305 ParentColor = False 306 306 end 307 object Label6: TLabel 308 Left = 8 309 Height = 22 310 Top = 313 311 Width = 114 312 Caption = 'Win objective:' 313 ParentColor = False 314 end 315 object ComboBoxWinObjective: TComboBox 316 Left = 160 317 Height = 30 318 Top = 305 319 Width = 208 320 ItemHeight = 0 321 Items.Strings = ( 322 'Defeat all oponents' 323 'Defeat all oponents cities' 324 'Capture position' 325 'Stay alive for number of turns' 326 ) 327 Style = csDropDownList 328 TabOrder = 13 329 end 330 object Label7: TLabel 331 Left = 8 332 Height = 22 333 Top = 348 334 Width = 211 335 Caption = 'Max random neutral units:' 336 ParentColor = False 337 end 338 object SpinEditNeutralUnits: TSpinEdit 339 Left = 272 340 Height = 32 341 Top = 343 342 Width = 98 343 MaxValue = 99 344 OnChange = SpinEditMapSizeYChange 345 TabOrder = 14 346 Value = 12 347 end 307 348 end 308 349 object ActionList1: TActionList -
trunk/Forms/UFormNew.lrt
r41 r42 18 18 TFORMNEW.RADIOGROUPGROWCELLS.CAPTION=Growing cells 19 19 TFORMNEW.LABEL5.CAPTION=Grid type: 20 TFORMNEW.LABEL6.CAPTION=Win objective: 21 TFORMNEW.LABEL7.CAPTION=Max random neutral units: 20 22 TFORMNEW.APLAYERMODIFY.CAPTION=Modify player 21 23 TFORMNEW.APLAYERADD.CAPTION=Add player -
trunk/Forms/UFormNew.pas
r41 r42 26 26 CheckBoxVoid: TCheckBox; 27 27 ComboBoxGridType: TComboBox; 28 ComboBoxWinObjective: TComboBox; 28 29 Label1: TLabel; 29 30 Label2: TLabel; … … 31 32 Label4: TLabel; 32 33 Label5: TLabel; 34 Label6: TLabel; 35 Label7: TLabel; 33 36 ListView1: TListView; 34 37 Panel1: TPanel; … … 39 42 SpinEditMapSizeX: TSpinEdit; 40 43 SpinEditMapSizeY: TSpinEdit; 44 SpinEditNeutralUnits: TSpinEdit; 41 45 SpinEditVoidPercent: TSpinEdit; 42 46 Splitter1: TSplitter; … … 228 232 RadioGroupGrowCells.ItemIndex := Integer(Game.GrowCells); 229 233 ComboBoxGridType.ItemIndex := Integer(Game.MapType) - 1; 234 ComboBoxWinObjective.ItemIndex := Integer(Game.WinObjective); 235 SpinEditNeutralUnits.Value := Game.MaxNeutralUnits; 230 236 end; 231 237 … … 250 256 Game.GrowCells := TGrowCells(RadioGroupGrowCells.ItemIndex); 251 257 Game.MapType := TMapType(ComboBoxGridType.ItemIndex + 1); 258 Game.WinObjective := TWinObjective(ComboBoxWinObjective.ItemIndex); 259 Game.MaxNeutralUnits := SpinEditNeutralUnits.Value; 252 260 end; 253 261 -
trunk/Languages/xtactics.cs.po
r41 r42 118 118 msgstr "Ok" 119 119 120 #: tformmove.buttononcemax.caption 121 msgctxt "tformmove.buttononcemax.caption" 122 msgid "Max" 123 msgstr "" 124 125 #: tformmove.buttononcemin.caption 126 msgctxt "tformmove.buttononcemin.caption" 127 msgid "Min" 128 msgstr "" 129 130 #: tformmove.buttonrepeatmax.caption 131 msgctxt "tformmove.buttonrepeatmax.caption" 132 msgid "Max" 133 msgstr "" 134 135 #: tformmove.buttonrepeatmin.caption 136 msgctxt "tformmove.buttonrepeatmin.caption" 137 msgid "Min" 138 msgstr "" 139 120 140 #: tformmove.caption 121 141 msgid "Move" … … 201 221 msgstr "Typ mřížky:" 202 222 223 #: tformnew.label6.caption 224 msgid "Win objective:" 225 msgstr "" 226 227 #: tformnew.label7.caption 228 msgid "Max random neutral units:" 229 msgstr "" 230 203 231 #: tformnew.listview1.columns[0].caption 204 232 msgid "Name" -
trunk/Languages/xtactics.po
r41 r42 108 108 msgstr "" 109 109 110 #: tformmove.buttononcemax.caption 111 msgctxt "tformmove.buttononcemax.caption" 112 msgid "Max" 113 msgstr "" 114 115 #: tformmove.buttononcemin.caption 116 msgctxt "tformmove.buttononcemin.caption" 117 msgid "Min" 118 msgstr "" 119 120 #: tformmove.buttonrepeatmax.caption 121 msgctxt "TFORMMOVE.BUTTONREPEATMAX.CAPTION" 122 msgid "Max" 123 msgstr "" 124 125 #: tformmove.buttonrepeatmin.caption 126 msgctxt "TFORMMOVE.BUTTONREPEATMIN.CAPTION" 127 msgid "Min" 128 msgstr "" 129 110 130 #: tformmove.caption 111 131 msgid "Move" … … 189 209 msgstr "" 190 210 211 #: tformnew.label6.caption 212 msgid "Win objective:" 213 msgstr "" 214 215 #: tformnew.label7.caption 216 msgid "Max random neutral units:" 217 msgstr "" 218 191 219 #: tformnew.listview1.columns[0].caption 192 220 msgid "Name" -
trunk/UGame.pas
r40 r42 39 39 Terrain: TTerrainType; 40 40 Player: TPlayer; 41 MovesFrom: TObjectList; 42 MovesTo: TObjectList; 41 MovesFrom: TObjectList; // TList<TMove> 42 MovesTo: TObjectList; // TList<TMove> 43 43 function GetColor: TColor; 44 44 function GetAvialPower: Integer; … … 87 87 MaxPower: Integer; 88 88 DefaultCellSize: TPoint; 89 procedure DrawArrow(Canvas: TCanvas; View: TView; Pos: TPoint; Angle: Double; Size: TPoint); 89 procedure DrawArrow(Canvas: TCanvas; View: TView; Pos: TPoint; Angle: Double; 90 Size: TPoint; Text: string); 90 91 function IsCellsNeighbor(Cell1, Cell2: TCell): Boolean; virtual; 91 92 function IsValidIndex(Index: TPoint): Boolean; virtual; … … 169 170 TotalUnits: Integer; 170 171 TotalCells: Integer; 172 TotalCities: Integer; 171 173 StartUnits: Integer; 172 174 procedure ComputerTurn; … … 184 186 end; 185 187 186 { T Move }187 188 T Move = class188 { TUnitMove } 189 190 TUnitMove = class 189 191 private 190 192 FCellFrom: TCell; … … 194 196 procedure SetCellTo(AValue: TCell); 195 197 public 196 List: TObjectList; // TList<T Move>198 List: TObjectList; // TList<TUnitMove> 197 199 CountOnce: Integer; 198 200 CountRepeat: Integer; … … 211 213 TGrowCells = (gcNone, gcPlayerCities, gcPlayerAll); 212 214 TMapType = (mtNone, mtHexagon, mtSquare); 215 TWinObjective = (woDefeatAllOponents, woDefeatAllOponentsCities, 216 woSpecialCaptureCell, woStayAliveForDefinedTurns); 213 217 214 218 TGame = class … … 235 239 CityPercentage: Integer; 236 240 CurrentPlayer: TPlayer; 237 Moves: TObjectList; // TList<T Move>241 Moves: TObjectList; // TList<TUnitMove> 238 242 TurnCounter: Integer; 243 WinObjective: TWinObjective; 244 SpecialCaptureCell: TCell; 245 StayAliveForDefinedTurns: Integer; 246 MaxNeutralUnits: Integer; 239 247 procedure SaveConfig(Config: TXmlConfig; Path: string); 240 248 procedure LoadConfig(Config: TXmlConfig; Path: string); 241 249 procedure ComputePlayerStats; 242 250 function GetAlivePlayers: TPlayerArray; 251 function GetAlivePlayersWithCities: TPlayerArray; 243 252 procedure NextTurn; 253 procedure CheckWinObjective; 244 254 constructor Create; 245 255 destructor Destroy; override; 246 256 procedure New; 257 procedure EndGame(Winner: TPlayer = nil); 247 258 property Running: Boolean read FRunning write SetRunning; 248 259 property MapType: TMapType read FMapType write SetMapType; … … 517 528 for I := 0 to Cell.MovesFrom.Count - 1 do begin 518 529 PosFrom := CellToPos(Cell); 519 PosTo := CellToPos(T Move(Cell.MovesFrom[I]).CellTo);520 if T Move(Cell.MovesFrom[I]).CountRepeat > 0 then Pen.Width := 2530 PosTo := CellToPos(TUnitMove(Cell.MovesFrom[I]).CellTo); 531 if TUnitMove(Cell.MovesFrom[I]).CountRepeat > 0 then Pen.Width := 2 521 532 else Pen.Width := 1; 522 533 Angle := ArcTan((PosTo.Y - PosFrom.Y) / (PosTo.X - PosFrom.X)); … … 524 535 DrawArrow(Canvas, View, View.CellToCanvasPos(Point(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 3), 525 536 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 3))), 526 Angle, Point(Trunc(HexSize.X / 4), Trunc(HexSize.Y / 4))); 537 Angle, Point(Trunc(HexSize.X / 4), Trunc(HexSize.Y / 4)), 538 IntToStr(TUnitMove(Cell.MovesFrom[I]).CountOnce)); 527 539 Pen.Width := 1; 528 540 end; … … 557 569 end; 558 570 559 procedure TMap.DrawArrow(Canvas: TCanvas; View: TView; Pos: TPoint; Angle: Double; Size: TPoint); 571 procedure TMap.DrawArrow(Canvas: TCanvas; View: TView; Pos: TPoint; 572 Angle: Double; Size: TPoint; Text: string); 560 573 var 561 574 Points: array of TPoint; … … 582 595 for I := 0 to Length(Points) - 1 do 583 596 Points[I] := Point(Trunc(FPoints[I].X + Pos.X), Trunc(FPoints[I].Y + Pos.Y)); 584 Canvas.Polygon(Points); 597 with Canvas do begin 598 Polygon(Points); 599 Brush.Style := bsClear; 600 Font.Color := clBlack; 601 Font.Size := Trunc(4 * View.Zoom); 602 TextOut(Pos.X - TextWidth(Text) div 2, 603 Pos.Y - TextHeight(Text) div 2, Text); 604 Pen.Width := 1; 605 end; 585 606 end; 586 607 … … 656 677 Player.TotalCells := Player.TotalCells + 1; 657 678 Player.TotalUnits := Player.TotalUnits + Power; 679 if Terrain = ttCity then 680 Player.TotalCities := Player.TotalCities + 1; 658 681 end; 659 682 end; … … 714 737 end; 715 738 716 { T Move }717 718 procedure T Move.SetCellFrom(AValue: TCell);739 { TUnitMove } 740 741 procedure TUnitMove.SetCellFrom(AValue: TCell); 719 742 begin 720 743 if FCellFrom = AValue then Exit; … … 728 751 end; 729 752 730 procedure T Move.SetCellTo(AValue: TCell);753 procedure TUnitMove.SetCellTo(AValue: TCell); 731 754 begin 732 755 if FCellTo = AValue then Exit; … … 740 763 end; 741 764 742 constructor T Move.Create;765 constructor TUnitMove.Create; 743 766 begin 744 767 FCellFrom := nil; … … 746 769 end; 747 770 748 destructor T Move.Destroy;771 destructor TUnitMove.Destroy; 749 772 var 750 773 LastState: Boolean; … … 831 854 Result := Power; 832 855 for I := 0 to MovesFrom.Count - 1 do 833 Result := Result - T Move(MovesFrom[I]).CountOnce;856 Result := Result - TUnitMove(MovesFrom[I]).CountOnce; 834 857 if Result < 0 then Result := 0; 835 858 end; … … 849 872 begin 850 873 for I := MovesFrom.Count - 1 downto 0 do 851 T Move(MovesFrom[I]).Free;874 TUnitMove(MovesFrom[I]).Free; 852 875 FreeAndNil(MovesFrom); 853 876 for I := MovesTo.Count - 1 downto 0 do 854 T Move(MovesTo[I]).Free;877 TUnitMove(MovesTo[I]).Free; 855 878 FreeAndNil(MovesTo); 856 879 inherited Destroy; … … 1048 1071 I := 0; 1049 1072 while I < Moves.Count do 1050 with T Move(Moves[I]) do begin1073 with TUnitMove(Moves[I]) do begin 1051 1074 if CountOnce > 0 then begin 1052 1075 if CellFrom.Player = Player then begin … … 1078 1101 // Remove empty moves 1079 1102 for I := Moves.Count - 1 downto 0 do 1080 if (T Move(Moves[I]).CellFrom.Player = Player) and1081 (T Move(Moves[I]).CountOnce = 0) and (TMove(Moves[I]).CountRepeat = 0) then1103 if (TUnitMove(Moves[I]).CellFrom.Player = Player) and 1104 (TUnitMove(Moves[I]).CountOnce = 0) and (TUnitMove(Moves[I]).CountRepeat = 0) then 1082 1105 Moves.Delete(I); 1083 1106 end; … … 1088 1111 begin 1089 1112 for I := Moves.Count - 1 downto 0 do 1090 if T Move(Moves[I]).CellFrom = Cell then1113 if TUnitMove(Moves[I]).CellFrom = Cell then 1091 1114 Moves.Delete(I); 1092 1115 end; … … 1110 1133 procedure TGame.SetMove(CellFrom, CellTo: TCell; Power: Integer); 1111 1134 var 1112 NewMove: T Move;1113 OldMove: T Move;1135 NewMove: TUnitMove; 1136 OldMove: TUnitMove; 1114 1137 I: Integer; 1115 1138 CountOnce: Integer; … … 1118 1141 begin 1119 1142 I := 0; 1120 while (I < Moves.Count) and ((T Move(Moves[I]).CellFrom <> CellFrom) or1121 (T Move(Moves[I]).CellTo <> CellTo)) do Inc(I);1122 if I < Moves.Count then OldMove := T Move(Moves[I])1143 while (I < Moves.Count) and ((TUnitMove(Moves[I]).CellFrom <> CellFrom) or 1144 (TUnitMove(Moves[I]).CellTo <> CellTo)) do Inc(I); 1145 if I < Moves.Count then OldMove := TUnitMove(Moves[I]) 1123 1146 else OldMove := nil; 1124 1147 if Assigned(OldMove) then begin … … 1138 1161 if (CountOnce = 0) and (CountRepeat = 0) then Moves.Delete(I) 1139 1162 else begin 1140 T Move(Moves[I]).CountOnce := CountOnce;1141 T Move(Moves[I]).CountRepeat := CountRepeat;1163 TUnitMove(Moves[I]).CountOnce := CountOnce; 1164 TUnitMove(Moves[I]).CountRepeat := CountRepeat; 1142 1165 end; 1143 1166 end else begin 1144 1167 // Add new move 1145 1168 if (CountOnce > 0) or (CountRepeat > 0) then begin 1146 NewMove := T Move(Moves[Moves.Add(TMove.Create)]);1169 NewMove := TUnitMove(Moves[Moves.Add(TUnitMove.Create)]); 1147 1170 NewMove.List := Moves; 1148 1171 NewMove.CellFrom := CellFrom; … … 1177 1200 begin 1178 1201 for I := 0 to Moves.Count - 1 do 1179 with T Move(Moves[I]) do begin1202 with TUnitMove(Moves[I]) do begin 1180 1203 if CellFrom.Player = Player then 1181 1204 if CountRepeat <= CellFrom.GetAvialPower then … … 1197 1220 SetValue(Path + '/GrowAmount', Integer(GrowAmount)); 1198 1221 SetValue(Path + '/GrowCells', Integer(GrowCells)); 1222 SetValue(Path + '/WinObjective', Integer(WinObjective)); 1199 1223 end; 1200 1224 end; … … 1212 1236 GrowAmount := TGrowAmount(GetValue(Path + '/GrowAmount', Integer(gaBySquareRoot))); 1213 1237 GrowCells := TGrowCells(GetValue(Path + '/GrowCells', Integer(gcPlayerAll))); 1238 WinObjective := TWinObjective(GetValue(Path + '/WinObjective', Integer(woDefeatAllOponents))); 1214 1239 end; 1215 1240 end; … … 1223 1248 TotalUnits := 0; 1224 1249 TotalCells := 0; 1250 TotalCities := 0; 1225 1251 end; 1226 1252 Map.ComputePlayerStats; … … 1239 1265 end; 1240 1266 1267 function TGame.GetAlivePlayersWithCities: TPlayerArray; 1268 var 1269 I: Integer; 1270 begin 1271 SetLength(Result, 0); 1272 for I := 0 to Players.Count - 1 do 1273 if TPlayer(Players[I]).TotalCities > 0 then begin 1274 SetLength(Result, Length(Result) + 1); 1275 Result[Length(Result) - 1] := TPlayer(Players[I]); 1276 end; 1277 end; 1278 1241 1279 procedure TGame.NextTurn; 1242 1280 var 1243 1281 PrevPlayer: TPlayer; 1244 AlivePlayers: TPlayerArray;1245 1282 begin 1246 1283 MoveAll(CurrentPlayer); … … 1253 1290 until CurrentPlayer.TotalCells > 0; 1254 1291 if Players.IndexOf(CurrentPlayer) < Players.IndexOf(PrevPlayer) then Inc(TurnCounter); 1255 AlivePlayers := GetAlivePlayers; 1256 if (Length(AlivePlayers) <= 1) then begin 1257 Running := False; 1258 if Assigned(OnWin) and (Length(AlivePlayers) > 0) then OnWin(TPlayer(AlivePlayers[0])); 1259 end; 1292 CheckWinObjective; 1260 1293 UpdateRepeatMoves(CurrentPlayer); 1261 1294 // For computers take view from previous human 1262 1295 if CurrentPlayer.Mode = pmComputer then CurrentPlayer.View.Assign(PrevPlayer.View); 1296 end; 1297 1298 procedure TGame.CheckWinObjective; 1299 var 1300 AlivePlayers: TPlayerArray; 1301 Winner: TPlayer; 1302 begin 1303 Winner := nil; 1304 if WinObjective = woDefeatAllOponents then begin 1305 AlivePlayers := GetAlivePlayers; 1306 if (Length(AlivePlayers) <= 1) then begin 1307 if Length(AlivePlayers) > 0 then Winner := TPlayer(AlivePlayers[0]); 1308 EndGame(Winner); 1309 end; 1310 end else 1311 if WinObjective = woDefeatAllOponentsCities then begin 1312 AlivePlayers := GetAlivePlayersWithCities; 1313 if (Length(AlivePlayers) <= 1) then begin 1314 if Length(AlivePlayers) > 0 then Winner := TPlayer(AlivePlayers[0]); 1315 EndGame(Winner); 1316 end; 1317 end else 1318 if WinObjective = woSpecialCaptureCell then begin 1319 if Assigned(SpecialCaptureCell) and Assigned(SpecialCaptureCell.Player) then 1320 EndGame(SpecialCaptureCell.Player); 1321 end else 1322 if WinObjective = woStayAliveForDefinedTurns then begin 1323 // TODO: Not only one can win but multiple human players can survive. 1324 if TurnCounter > StayAliveForDefinedTurns then 1325 EndGame(nil); 1326 end; 1263 1327 end; 1264 1328 … … 1287 1351 VoidEnabled := True; 1288 1352 VoidPercentage := 20; 1353 MaxNeutralUnits := 4; 1289 1354 1290 1355 Map.Game := Self; … … 1320 1385 else Terrain := ttNormal; 1321 1386 end; 1322 Power := Random( 4);1387 Power := Random(MaxNeutralUnits + 1); 1323 1388 Player := nil; 1324 1389 end; … … 1336 1401 raise Exception.Create(SCannotSetPlayerStartCells); 1337 1402 end; 1338 if CityEnabled then StartCell.Terrain := ttCity 1339 else StartCell.Terrain := ttNormal; 1403 StartCell.Terrain := ttCity; 1340 1404 StartCell.Player := TPlayer(Players[I]); 1341 1405 StartCell.Power := TPlayer(Players[I]).StartUnits; … … 1345 1409 end; 1346 1410 CurrentPlayer := TPlayer(Players[0]); 1411 end; 1412 1413 procedure TGame.EndGame(Winner: TPlayer = nil); 1414 begin 1415 Running := False; 1416 if Assigned(OnWin) and Assigned(Winner) then OnWin(Winner); 1347 1417 end; 1348 1418 … … 1533 1603 PosFrom, PosTo: TPoint; 1534 1604 Angle: Double; 1605 ArrowCenter: TPoint; 1535 1606 1536 1607 procedure PaintHexagon(Pos: TPoint; Text: string); … … 1596 1667 for I := 0 to Cell.MovesFrom.Count - 1 do begin 1597 1668 PosFrom := CellToPos(Cell); 1598 PosTo := CellToPos(T Move(Cell.MovesFrom[I]).CellTo);1599 if T Move(Cell.MovesFrom[I]).CountRepeat > 0 then Pen.Width := 21669 PosTo := CellToPos(TUnitMove(Cell.MovesFrom[I]).CellTo); 1670 if TUnitMove(Cell.MovesFrom[I]).CountRepeat > 0 then Pen.Width := 2 1600 1671 else Pen.Width := 1; 1601 1672 Angle := ArcTan((PosTo.Y - PosFrom.Y) / (PosTo.X - PosFrom.X)); 1602 1673 if Sign(PosTo.X - PosFrom.X) = -1 then Angle := Angle + Pi; 1603 DrawArrow(Canvas, View, View.CellToCanvasPos(Point(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 3), 1604 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 3))), 1605 Angle, Point(Trunc(HexSize.X / 4), Trunc(HexSize.Y / 4))); 1606 Pen.Width := 1; 1674 ArrowCenter := View.CellToCanvasPos(Point(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 3), 1675 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 3))); 1676 DrawArrow(Canvas, View, ArrowCenter, 1677 Angle, Point(Trunc(HexSize.X / 4), Trunc(HexSize.Y / 4)), 1678 IntToStr(TUnitMove(Cell.MovesFrom[I]).CountOnce)); 1607 1679 end; 1608 1680 end;
Note:
See TracChangeset
for help on using the changeset viewer.