- Timestamp:
- Jan 15, 2019, 1:03:40 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormClient.lfm
r249 r265 13 13 OnKeyUp = FormKeyUp 14 14 OnShow = FormShow 15 LCLVersion = '1.8. 2.0'15 LCLVersion = '1.8.4.0' 16 16 WindowState = wsMaximized 17 17 object StatusBar1: TStatusBar 18 18 Left = 0 19 Height = 3020 Top = 59 119 Height = 28 20 Top = 593 21 21 Width = 775 22 22 Panels = < … … 34 34 object ToolBar1: TToolBar 35 35 Left = 0 36 Height = 59 136 Height = 593 37 37 Top = 0 38 38 Width = 32 … … 80 80 object PaintBox1: TPaintBox 81 81 Left = 32 82 Height = 59 182 Height = 593 83 83 Top = 0 84 84 Width = 743 -
trunk/Forms/UFormClient.pas
r249 r265 152 152 FormMove.TrackBarRepeat.Max := FormMove.SpinEditRepeat.MaxValue; 153 153 FormMove.TrackBarRepeat.Position := FormMove.SpinEditRepeat.Value; 154 FormMove.DefendCount := CellTo.MapCell.Power; 154 if Assigned(CellTo.MapCell.OneUnit) then 155 FormMove.DefendCount := CellTo.MapCell.OneUnit.Power 156 else FormMove.DefendCount := 0; 155 157 // Attack count from other surrounding cells without current move if already exists 156 158 FormMove.AttackCount := 0; -
trunk/Forms/UFormNew.lfm
r263 r265 15 15 OnShow = FormShow 16 16 Position = poMainFormCenter 17 LCLVersion = '1.8. 2.0'17 LCLVersion = '1.8.4.0' 18 18 object PageControl1: TPageControl 19 19 Left = 4 … … 21 21 Top = 4 22 22 Width = 749 23 ActivePage = TabSheet Map23 ActivePage = TabSheetRules 24 24 Align = alClient 25 25 BorderSpacing.Around = 4 26 TabIndex = 226 TabIndex = 3 27 27 TabOrder = 0 28 28 object TabSheetMode: TTabSheet 29 29 Caption = 'Mode' 30 ClientHeight = 65 131 ClientWidth = 7 4330 ClientHeight = 655 31 ClientWidth = 739 32 32 object Panel3: TPanel 33 33 Left = 0 … … 113 113 item 114 114 Caption = 'Address' 115 Width = 21 4115 Width = 219 116 116 end> 117 117 MultiSelect = True … … 158 158 object TabSheetPlayers: TTabSheet 159 159 Caption = 'Players' 160 ClientHeight = 65 1161 ClientWidth = 7 43160 ClientHeight = 655 161 ClientWidth = 739 162 162 object Panel2: TPanel 163 163 Left = 0 164 Height = 65 1164 Height = 655 165 165 Top = 0 166 Width = 7 43166 Width = 739 167 167 Align = alClient 168 168 BevelOuter = bvNone 169 ClientHeight = 65 1170 ClientWidth = 7 43169 ClientHeight = 655 170 ClientWidth = 739 171 171 TabOrder = 0 172 172 object ListViewPlayers: TListView 173 173 Left = 4 174 Height = 60 1174 Height = 605 175 175 Top = 4 176 Width = 73 5176 Width = 731 177 177 Align = alTop 178 178 Anchors = [akTop, akLeft, akRight, akBottom] … … 212 212 Left = 16 213 213 Height = 25 214 Top = 61 3214 Top = 617 215 215 Width = 83 216 216 Action = APlayerAdd … … 221 221 Left = 120 222 222 Height = 25 223 Top = 61 3223 Top = 617 224 224 Width = 83 225 225 Action = APlayerModify … … 230 230 Left = 224 231 231 Height = 25 232 Top = 61 3232 Top = 617 233 233 Width = 83 234 234 Action = APlayerRemove … … 240 240 object TabSheetMap: TTabSheet 241 241 Caption = 'Map' 242 ClientHeight = 65 1243 ClientWidth = 7 43242 ClientHeight = 655 243 ClientWidth = 739 244 244 object Panel1: TPanel 245 245 Left = 0 246 Height = 65 1246 Height = 655 247 247 Top = 0 248 Width = 7 43248 Width = 739 249 249 Align = alClient 250 250 BevelOuter = bvNone 251 ClientHeight = 65 1252 ClientWidth = 7 43251 ClientHeight = 655 252 ClientWidth = 739 253 253 TabOrder = 0 254 254 object Label1: TLabel … … 270 270 object SpinEditMapSizeX: TSpinEdit 271 271 Left = 128 272 Height = 36272 Height = 43 273 273 Top = 4 274 274 Width = 98 … … 280 280 object SpinEditMapSizeY: TSpinEdit 281 281 Left = 128 282 Height = 36282 Height = 43 283 283 Top = 55 284 284 Width = 98 … … 290 290 object TrackBarSizeX: TTrackBar 291 291 Left = 240 292 Height = 47292 Height = 58 293 293 Top = 8 294 Width = 4 92294 Width = 488 295 295 Max = 100 296 296 Min = 2 … … 303 303 object TrackBarSizeY: TTrackBar 304 304 Left = 240 305 Height = 47305 Height = 58 306 306 Top = 49 307 Width = 4 92307 Width = 488 308 308 Max = 100 309 309 Min = 2 … … 324 324 object ComboBoxGridType: TComboBox 325 325 Left = 146 326 Height = 36326 Height = 42 327 327 Top = 104 328 328 Width = 208 … … 340 340 object ComboBoxMapShape: TComboBox 341 341 Left = 146 342 Height = 36342 Height = 42 343 343 Top = 144 344 344 Width = 208 … … 365 365 Height = 27 366 366 Top = 110 367 Width = 25 5367 Width = 251 368 368 Anchors = [akTop, akLeft, akRight] 369 369 AutoSize = False … … 373 373 object SpinEditVoidPercent: TSpinEdit 374 374 Left = 216 375 Height = 36375 Height = 43 376 376 Top = 224 377 377 Width = 106 … … 384 384 Height = 30 385 385 Top = 232 386 Width = 18 7386 Width = 189 387 387 Caption = 'Inaccessible places' 388 388 OnChange = CheckBoxVoidChange … … 393 393 Height = 30 394 394 Top = 272 395 Width = 7 1395 Width = 73 396 396 Caption = 'Cities' 397 397 OnChange = CheckBoxCityChange … … 400 400 object SpinEditCityPercent: TSpinEdit 401 401 Left = 216 402 Height = 36402 Height = 43 403 403 Top = 272 404 404 Width = 106 … … 425 425 object SpinEditNeutralUnits: TSpinEdit 426 426 Left = 408 427 Height = 36427 Height = 43 428 428 Top = 384 429 429 Width = 98 … … 442 442 object EditImageFile: TEdit 443 443 Left = 144 444 Height = 36444 Height = 43 445 445 Top = 184 446 Width = 47 6446 Width = 472 447 447 Anchors = [akTop, akLeft, akRight] 448 448 TabOrder = 12 449 449 end 450 450 object ButtonImageBrowse: TButton 451 Left = 62 8451 Left = 624 452 452 Height = 25 453 453 Top = 192 … … 470 470 Height = 30 471 471 Top = 310 472 Width = 21 0472 Width = 212 473 473 Caption = 'Bridges between cells' 474 474 TabOrder = 14 … … 476 476 object SpinEditMaxPower: TSpinEdit 477 477 Left = 408 478 Height = 36478 Height = 43 479 479 Top = 344 480 480 Width = 98 … … 497 497 Height = 27 498 498 Top = 137 499 Width = 25 5499 Width = 251 500 500 Anchors = [akTop, akLeft, akRight] 501 501 AutoSize = False … … 507 507 object TabSheetRules: TTabSheet 508 508 Caption = 'Rules' 509 ClientHeight = 65 1510 ClientWidth = 7 43509 ClientHeight = 655 510 ClientWidth = 739 511 511 object Panel4: TPanel 512 512 Left = 0 513 Height = 65 1513 Height = 655 514 514 Top = 0 515 Width = 7 43515 Width = 739 516 516 Align = alClient 517 517 BevelOuter = bvNone 518 ClientHeight = 65 1519 ClientWidth = 7 43518 ClientHeight = 655 519 ClientWidth = 739 520 520 TabOrder = 0 521 521 object RadioGroupGrowCells: TRadioGroup … … 533 533 ChildSizing.Layout = cclLeftToRightThenTopToBottom 534 534 ChildSizing.ControlsPerLine = 1 535 ClientHeight = 7 7536 ClientWidth = 3 08535 ClientHeight = 78 536 ClientWidth = 310 537 537 Items.Strings = ( 538 538 'None' … … 552 552 object ComboBoxWinObjective: TComboBox 553 553 Left = 224 554 Height = 3 6554 Height = 38 555 555 Top = 244 556 556 Width = 328 … … 580 580 ChildSizing.Layout = cclLeftToRightThenTopToBottom 581 581 ChildSizing.ControlsPerLine = 1 582 ClientHeight = 4 8583 ClientWidth = 30 1582 ClientHeight = 49 583 ClientWidth = 303 584 584 Items.Strings = ( 585 585 'By one' … … 592 592 Height = 30 593 593 Top = 24 594 Width = 11 3594 Width = 115 595 595 Caption = 'Fog of war' 596 596 TabOrder = 3 … … 600 600 Height = 78 601 601 Top = 290 602 Width = 7 20602 Width = 716 603 603 ActivePage = TabSheetCaptureCities 604 604 Anchors = [akTop, akLeft, akRight] … … 611 611 end 612 612 object TabSheetCaptureCells: TTabSheet 613 ClientHeight = 7 2614 ClientWidth = 7 14613 ClientHeight = 74 614 ClientWidth = 706 615 615 object Label14: TLabel 616 616 Left = 8 … … 633 633 end 634 634 object TabSheetStayAliveTurns: TTabSheet 635 ClientHeight = 7 2636 ClientWidth = 7 14635 ClientHeight = 74 636 ClientWidth = 706 637 637 object Label13: TLabel 638 638 Left = 8 … … 659 659 Height = 30 660 660 Top = 62 661 Width = 36 0661 Width = 362 662 662 Caption = 'Set cells without player units as neutral' 663 663 TabOrder = 5 -
trunk/Forms/UFormNew.pas
r263 r265 163 163 SGridTypeRandom = 'Random'; 164 164 SGridTypeIsometric = 'Isometric'; 165 SWinObjectiveNone = 'None'; 165 166 SWinObjectiveDefeatAllOponents = 'Defeat all oponents'; 166 167 SWinObjectiveDefeatAllCities = 'Defeat all oponents cities'; 167 168 SWinObjectiveCapturePosition = 'Capture all special cells'; 168 169 SWinObjectiveStayAliveForTurns = 'Stay alive for number of turns'; 170 SWinObjectiveCaptureEntireMap = 'Capture entire map'; 169 171 SGrowNone = 'None'; 170 172 SGrowPlayerCities = 'Player cities'; … … 283 285 LastIndex := ItemIndex; 284 286 Clear; 287 Items.Add(SWinObjectiveNone); 285 288 Items.Add(SWinObjectiveDefeatAllOponents); 286 289 Items.Add(SWinObjectiveDefeatAllCities); 287 290 Items.Add(SWinObjectiveCapturePosition); 288 291 Items.Add(SWinObjectiveStayAliveForTurns); 292 Items.Add(SWinObjectiveCaptureEntireMap); 289 293 ItemIndex := LastIndex; 290 294 end; … … 327 331 procedure TFormNew.UpdateInterface; 328 332 begin 329 APlayerRemove.Enabled := Assigned(ListViewPlayers.Selected) and (Players.Count > 2);333 APlayerRemove.Enabled := Assigned(ListViewPlayers.Selected) and (Players.Count > MinPlayerCount); 330 334 APlayerAdd.Enabled := Players.Count < MaxPlayerCount; 331 335 APlayerModify.Enabled := Assigned(ListViewPlayers.Selected); … … 427 431 if ListViewPlayers.Items[I].Selected then begin 428 432 Players.Remove(ListViewPlayers.Items[I].Data); 433 if Players.Count <= MinPlayerCount then Break; 429 434 end; 430 435 ReloadView; … … 487 492 if Players.Count <= (MaxPlayerCount - 1) then begin 488 493 NewPlayer := TPlayer.Create; 489 NewPlayer.Id := Players.GetNew PlayerId;494 NewPlayer.Id := Players.GetNewId; 490 495 NewPlayer.Name := SPlayer + ' ' + IntToStr(NewPlayer.Id); 491 496 NewPlayer.Color := PlayerColors[Players.Count]; … … 539 544 SpinEditTurns.Value := StayAliveForDefinedTurns; 540 545 SpinEditSpecialCells.Value := SpecialCaptureCellCount; 541 CheckBoxEmptyCellsNeutral.Checked := EmptyCellsNeutral;546 CheckBoxEmptyCellsNeutral.Checked := GameSystem.EmptyCellsNeutral; 542 547 end; 543 548 end; … … 582 587 StayAliveForDefinedTurns := SpinEditTurns.Value; 583 588 SpecialCaptureCellCount := SpinEditSpecialCells.Value; 584 EmptyCellsNeutral := CheckBoxEmptyCellsNeutral.Checked;589 GameSystem.EmptyCellsNeutral := CheckBoxEmptyCellsNeutral.Checked; 585 590 end; 586 591 end; -
trunk/Languages/xtactics.cs.po
r263 r265 9 9 "MIME-Version: 1.0\n" 10 10 "Content-Transfer-Encoding: 8bit\n" 11 "X-Generator: Poedit 2. 0.6\n"11 "X-Generator: Poedit 2.1.1\n" 12 12 "Language: cs\n" 13 13 … … 924 924 925 925 #: uformnew.sgrownone 926 msgctxt "uformnew.sgrownone" 926 927 msgid "None" 927 928 msgstr "Nikde" … … 951 952 msgstr "Zakulacený" 952 953 954 #: uformnew.swinobjectivecaptureentiremap 955 msgid "Capture entire map" 956 msgstr "Obsadit celou mapu" 957 953 958 #: uformnew.swinobjectivecaptureposition 954 959 msgid "Capture all special cells" … … 962 967 msgid "Defeat all oponents" 963 968 msgstr "Porazit všechny nepřátele" 969 970 #: uformnew.swinobjectivenone 971 msgctxt "uformnew.swinobjectivenone" 972 msgid "None" 973 msgstr "Žádný" 964 974 965 975 #: uformnew.swinobjectivestayaliveforturns … … 1000 1010 1001 1011 #: ugame.sminimumplayers 1002 msgid "You need at least two players"1003 msgstr "Potřebujete alespoň dvahráče"1012 msgid "You need at least one player" 1013 msgstr "Potřebujete alespoň jednoho hráče" 1004 1014 1005 1015 #: ugame.snewgamefile -
trunk/Languages/xtactics.po
r263 r265 901 901 902 902 #: uformnew.sgrownone 903 msgctxt "uformnew.sgrownone" 903 904 msgid "None" 904 905 msgstr "" … … 928 929 msgstr "" 929 930 931 #: uformnew.swinobjectivecaptureentiremap 932 msgid "Capture entire map" 933 msgstr "" 934 930 935 #: uformnew.swinobjectivecaptureposition 931 936 msgid "Capture all special cells" … … 938 943 #: uformnew.swinobjectivedefeatalloponents 939 944 msgid "Defeat all oponents" 945 msgstr "" 946 947 #: uformnew.swinobjectivenone 948 msgctxt "uformnew.swinobjectivenone" 949 msgid "None" 940 950 msgstr "" 941 951 … … 977 987 978 988 #: ugame.sminimumplayers 979 msgid "You need at least two players"989 msgid "You need at least one player" 980 990 msgstr "" 981 991 -
trunk/UClientAI.pas
r231 r265 44 44 TotalAttackPower: Integer; 45 45 CanAttack: Integer; 46 TargetPower: Integer; 46 47 TargetCells: TPlayerCells; 47 48 Cell: TPlayerCell; … … 81 82 82 83 // Attack if target is weaker 83 if TotalPower >= (MapCell.Power + AttackDiff) then begin 84 if Assigned(MapCell.OneUnit) then TargetPower := MapCell.OneUnit.Power 85 else TargetPower := 0; 86 if TotalPower >= (TargetPower + AttackDiff) then begin 84 87 TotalAttackPower := 0; 85 88 for NeighborCell in Neighbors do 86 89 if NeighborCell.MapCell.Player = ControlPlayer then begin 87 90 // Use only necessary power 88 AttackPower := MapCell.Power - TotalAttackPower + AttackDiff;91 AttackPower := TargetPower - TotalAttackPower + AttackDiff; 89 92 if NeighborCell.GetAvialPower < AttackPower then 90 93 AttackPower := NeighborCell.GetAvialPower; … … 141 144 end; 142 145 // Attack if target is weaker 143 if Game.AttackProbability(TotalPower, TargetCell.MapCell. Power) >=146 if Game.AttackProbability(TotalPower, TargetCell.MapCell.OneUnit.Power) >= 144 147 ComputerAggroProbability[ControlPlayer.Agressivity] then begin 145 148 // Try to limit total attacking power to necessary minimum 146 while Game.AttackProbability(TotalPower - 1, TargetCell.MapCell. Power) >=149 while Game.AttackProbability(TotalPower - 1, TargetCell.MapCell.OneUnit.Power) >= 147 150 ComputerAggroProbability[ControlPlayer.Agressivity] do 148 151 Dec(TotalPower); … … 306 309 for I := 0 to Neighbors.Count - 1 do 307 310 if (Neighbors[I].MapCell.Player <> ControlPlayer) and (Neighbors[I].MapCell.Player <> nil) then begin 308 Inc(EnemyPower, Neighbors[I].MapCell. Power);311 Inc(EnemyPower, Neighbors[I].MapCell.OneUnit.Power); 309 312 end; 310 313 if EnemyPower > (GetAvialPower + GetAttackPower) then begin -
trunk/UClientGUI.pas
r257 r265 190 190 191 191 // Show cell text 192 if (Cell. Power <> 0) or (Cell.Extra = etObjectiveTarget) then begin192 if (Cell.OneUnit.Power <> 0) or (Cell.Extra = etObjectiveTarget) then begin 193 193 Pen.Style := psSolid; 194 194 Font.Color := clWhite; … … 319 319 if Cell.MapCell.Player = ControlPlayer then 320 320 CellText := IntToStr(Cell.GetAvialPower) 321 else CellText := IntToStr(Cell.MapCell.Power); 321 else begin 322 if Assigned(Cell.MapCell.OneUnit) then 323 CellText := IntToStr(Cell.MapCell.OneUnit.Power) 324 else CellText := ''; 325 end; 322 326 if Assigned(SelectedCell) and (SelectedCell = Cell) then 323 327 Brush.Color := clGreen … … 349 353 if (MapCell.Terrain <> ttVoid) and View.IsCellVisible(MapCell) then begin 350 354 Brush.Color := MapCell.GetColor; 351 PaintMapCell(Canvas, MapCell.PosPx, IntToStr(MapCell.Power), View, MapCell); 355 if Assigned(Cell.MapCell.OneUnit) then 356 CellText := IntToStr(MapCell.OneUnit.Power) 357 else CellText := ''; 358 PaintMapCell(Canvas, MapCell.PosPx, CellText, View, MapCell); 352 359 end; 353 360 end; … … 514 521 Player.Moves.Remove(SelectedCell.MovesFrom[I]); 515 522 end; 516 TGame(Game).CurrentPlayer.SetMove(SelectedCell, NewSelectedCell, SelectedCell.MapCell. Power, False);523 TGame(Game).CurrentPlayer.SetMove(SelectedCell, NewSelectedCell, SelectedCell.MapCell.OneUnit.Power, False); 517 524 SelectedCell := nil; 518 525 end else … … 522 529 for I := SelectedCell.MovesFrom.Count - 1 downto 0 do 523 530 Player.Moves.Remove(SelectedCell.MovesFrom[I]); 524 UnitMove := TGame(Game).CurrentPlayer.SetMove(SelectedCell, NewSelectedCell, SelectedCell.MapCell. Power, False);531 UnitMove := TGame(Game).CurrentPlayer.SetMove(SelectedCell, NewSelectedCell, SelectedCell.MapCell.OneUnit.Power, False); 525 532 if Assigned(UnitMove) then 526 533 UnitMove.CountRepeat := TGame(Player.Game).Map.MaxPower; … … 528 535 else SelectedCell := nil; 529 536 end else begin 530 TGame(Game).CurrentPlayer.SetMove(SelectedCell, NewSelectedCell, SelectedCell.MapCell. Power);537 TGame(Game).CurrentPlayer.SetMove(SelectedCell, NewSelectedCell, SelectedCell.MapCell.OneUnit.Power); 531 538 SelectedCell := nil; 532 539 end; -
trunk/UCore.pas
r254 r265 9 9 UGame, UApplicationInfo, UPersistentForm, UScaleDPI, UCoolTranslator, 10 10 URegistry, ULastOpenedList, UTheme, Registry, Menus, UFormClient, UPlayer, 11 UGameServer, UGameClient, fgl, UServerList ;11 UGameServer, UGameClient, fgl, UServerList, UGameSystem, UUnit; 12 12 13 13 type … … 87 87 procedure UpdateOtherForms; 88 88 procedure FormClientActions; 89 procedure InitGameSystems; 89 90 public 90 91 Game: TGame; … … 99 100 LocalClients: TClients; 100 101 ServerList: TServerList; 102 GameSystems: TGameSystems; 101 103 procedure ReopenGameOnInit; 102 104 procedure LoadConfig; … … 445 447 procedure TCore.DataModuleCreate(Sender: TObject); 446 448 begin 449 GameSystems := TGameSystems.Create; 450 InitGameSystems; 447 451 Server := TServer.Create; 448 452 LocalClients := TClients.Create; 449 453 GameSettings := TGame.Create; 454 GameSettings.GameSystem := GameSystems.First; 450 455 Game := TGame.Create; 451 456 Game.OnMoveUpdated := DoMoveUpdated; … … 453 458 Game.OnNewTurn := GameNewTurnExecute; 454 459 Game.OnPlayerChange := DoPlayerChange; 460 Game.GameSystem := GameSystems.First; 455 461 Server.Game := Game; 456 462 LocalClients.Game := Game; … … 481 487 FreeAndNil(Game); 482 488 FreeAndNil(GameSettings); 489 FreeAndNil(GameSystems); 483 490 end; 484 491 … … 486 493 begin 487 494 LastOpenedList1.LoadToMenuItem(FormMain.MenuItemLoadRecent, LoadRecentExecute); 495 end; 496 497 procedure TCore.InitGameSystems; 498 begin 499 with GameSystems.AddNew('HexWars') do begin 500 MaxPlayerCount := 3; 501 with UnitKinds.AddNew('Unit') do begin 502 Moves := 1; 503 Stack := 99; 504 end; 505 end; 506 507 with GameSystems.AddNew('Civilization') do begin 508 MaxPlayerCount := 3; 509 with UnitKinds.AddNew('Scout') do begin 510 Moves := 1; 511 Stack := 1; 512 end; 513 with UnitKinds.AddNew('Settler') do begin 514 Moves := 1; 515 Stack := 1; 516 end; 517 end; 518 519 with GameSystems.AddNew('Dune 2') do begin 520 MaxPlayerCount := 3; 521 with UnitKinds.AddNew('Light Infantry') do begin 522 Moves := 1; 523 end; 524 with UnitKinds.AddNew('Heavy Troopers') do begin 525 Moves := 1; 526 end; 527 with UnitKinds.AddNew('Trike') do begin 528 Moves := 1; 529 end; 530 with UnitKinds.AddNew('Quad') do begin 531 Moves := 1; 532 end; 533 end; 534 535 with GameSystems.AddNew('Battle Isle 2') do begin 536 MaxPlayerCount := 8; 537 with UnitKinds.AddNew('Demon 132') do begin 538 Moves := 4; 539 Stack := 10; 540 end; 541 with UnitKinds.AddNew('Troll 142') do begin 542 Moves := 3; 543 Stack := 10; 544 end; 545 with UnitKinds.AddNew('Ranger 132') do begin 546 Moves := 10; 547 Stack := 10; 548 end; 549 with UnitKinds.AddNew('Buggy') do begin 550 Moves := 10; 551 Stack := 10; 552 end; 553 end; 488 554 end; 489 555 -
trunk/UGame.pas
r263 r265 8 8 Classes, SysUtils, ExtCtrls, Graphics, XMLConf, XMLRead, XMLWrite, Forms, 9 9 DOM, Math, LazFileUtils, UXMLUtils, Dialogs, LCLType, LCLIntf, fgl, 10 UGeometry, UPlayer, UMap, UMapType ;10 UGeometry, UPlayer, UMap, UMapType, UUnit, UGameSystem; 11 11 12 12 const 13 13 DefaultPlayerStartUnits = 5; 14 MinPlayerCount = 1; 14 15 MaxPlayerCount = 8; 15 16 … … 28 29 TGrowCells = (gcNone, gcPlayerCities, gcPlayerAll); 29 30 TMapType = (mtNone, mtHexagon, mtSquare, mtTriangle, mtRandom, mtIsometric); 30 TWinObjective = (wo DefeatAllOponents, woDefeatAllOponentsCities,31 woSpecialCaptureCell, woStayAliveForDefinedTurns );31 TWinObjective = (woNone, woDefeatAllOponents, woDefeatAllOponentsCities, 32 woSpecialCaptureCell, woStayAliveForDefinedTurns, woCaptureEntireMap); 32 33 33 34 { TGame } … … 35 36 TGame = class 36 37 private 38 FGameSystem: TGameSystem; 37 39 FMapType: TMapType; 38 40 FOnChange: TNotifyEvent; … … 46 48 ProbabilityMatrix: array of array of Single; 47 49 procedure RecordTurnStats; 50 procedure SetGameSystem(AValue: TGameSystem); 48 51 procedure SetMapType(AValue: TMapType); 49 52 procedure SetRunning(AValue: Boolean); … … 57 60 DevelMode: Boolean; 58 61 Players: TPlayers; 62 Units: TUnits; 59 63 Map: TMap; 60 64 MapImageFileName: string; … … 77 81 BridgeEnabled: Boolean; 78 82 MaxPower: Integer; 79 EmptyCellsNeutral: Boolean;80 83 procedure PostConfig; 81 84 procedure Assign(Source: TGame); … … 95 98 property Running: Boolean read FRunning write SetRunning; 96 99 property MapType: TMapType read FMapType write SetMapType; 100 property GameSystem: TGameSystem read FGameSystem write SetGameSystem; 97 101 published 98 102 property OnMoveUpdated: TMoveUpdatedEvent read FOnMoveUpdated write FOnMoveUpdated; … … 123 127 124 128 resourcestring 125 SMinimumPlayers = 'You need at least two players';129 SMinimumPlayers = 'You need at least one player'; 126 130 SHuman = 'Human'; 127 131 SComputer = 'Computer'; … … 263 267 if FRunning = AValue then Exit; 264 268 if AValue then begin 265 if Players.Count < 2then raise Exception.Create(SMinimumPlayers);269 if Players.Count < 1 then raise Exception.Create(SMinimumPlayers); 266 270 FRunning := AValue; 267 271 end else begin … … 284 288 else Terrain := ttNormal; 285 289 end; 286 Power := Random(MaxNeutralUnits + 1); 290 if not Assigned(OneUnit) then 291 OneUnit := Units.AddNew(GameSystem.UnitKinds[0], Random(MaxNeutralUnits + 1)); 287 292 Player := nil; 288 293 end; … … 428 433 BridgeEnabled := Source.BridgeEnabled; 429 434 MaxPower := Source.MaxPower; 430 EmptyCellsNeutral := Source.EmptyCellsNeutral;435 GameSystem := Source.GameSystem; 431 436 end; 432 437 … … 452 457 SetValue(DOMString(Path + '/StayAliveForDefinedTurns'), StayAliveForDefinedTurns); 453 458 SetValue(DOMString(Path + '/SpecialCaptureCellCount'), SpecialCaptureCellCount); 454 SetValue(DOMString(Path + '/EmptyCellsNeutral'), EmptyCellsNeutral);455 459 Players.SaveConfig(Config, Path + '/Players'); 456 460 end; … … 488 492 StayAliveForDefinedTurns := GetValue(DOMString(Path + '/StayAliveForDefinedTurns'), 20); 489 493 SpecialCaptureCellCount := GetValue(DOMString(Path + '/SpecialCaptureCellCount'), 1); 490 EmptyCellsNeutral := GetValue(DOMString(Path + '/EmptyCellsNeutral'), False);491 494 Players.LoadConfig(Config, Path + '/Players'); 492 495 end; … … 524 527 WinObjective := TWinObjective(ReadInteger(RootNode, 'WinObjective', Integer(woDefeatAllOponents))); 525 528 StayAliveForDefinedTurns := ReadInteger(RootNode, 'StayAliveForDefinedTurns', 10); 526 EmptyCellsNeutral := ReadBoolean(RootNode, 'EmptyCellsNeutral', False); 529 530 NewNode := FindNode('GameSystem'); 531 if Assigned(NewNode) then 532 GameSystem.LoadFromNode(NewNode); 527 533 528 534 NewNode := FindNode('Map'); … … 536 542 else CurrentPlayer := nil; 537 543 544 NewNode := FindNode('Units'); 545 if Assigned(NewNode) then 546 Units.LoadFromNode(NewNode); 547 538 548 Map.Cells.FixRefId; 549 Units.FixRefId; 539 550 540 551 for I := 0 to Players.Count - 1 do begin … … 578 589 WriteInteger(RootNode, 'WinObjective', Integer(WinObjective)); 579 590 WriteInteger(RootNode, 'StayAliveForDefinedTurns', StayAliveForDefinedTurns); 580 WriteBoolean(RootNode, 'EmptyCellsNeutral', EmptyCellsNeutral);581 591 WriteBoolean(RootNode, 'Running', Running); 592 593 NewNode := OwnerDocument.CreateElement('GameSystem'); 594 AppendChild(NewNode); 595 GameSystem.SaveToNode(NewNode); 582 596 583 597 NewNode := OwnerDocument.CreateElement('Map'); … … 588 602 AppendChild(NewNode); 589 603 Players.SaveToNode(NewNode); 604 605 NewNode := OwnerDocument.CreateElement('Units'); 606 AppendChild(NewNode); 607 Units.SaveToNode(NewNode); 590 608 end; 591 609 if ExtractFileDir(FileName) <> '' then … … 633 651 TurnStats.Add(NewStat); 634 652 end; 653 end; 654 655 procedure TGame.SetGameSystem(AValue: TGameSystem); 656 begin 657 if FGameSystem = AValue then Exit; 658 FGameSystem := AValue; 635 659 end; 636 660 … … 687 711 R: Boolean; 688 712 I: Integer; 713 PlayersCount: Integer; 689 714 begin 690 715 Winner := nil; … … 724 749 if TurnCounter > StayAliveForDefinedTurns then 725 750 EndGame(nil); 751 end else 752 if WinObjective = woCaptureEntireMap then begin 753 Player := nil; 754 for I := 0 to Map.Cells.Count - 1 do 755 if TCell(Map.Cells[I]).Terrain <> ttVoid then begin 756 if (TCell(Map.Cells[I]).Player <> nil) then begin 757 if Player = nil then begin 758 // First player found 759 Player := TPlayer(TCell(Map.Cells[I]).Player); 760 end else 761 if Player <> TCell(Map.Cells[I]).Player then begin 762 // Multiple players still alive 763 Player := nil; 764 Break; 765 end; 766 end else begin 767 // Neutral cell 768 Player := nil; 769 Break; 770 end; 771 end; 772 if Player <> nil then 773 EndGame(Player); 726 774 end; 727 775 end; … … 729 777 constructor TGame.Create; 730 778 begin 779 Units := TUnits.Create; 780 Units.Game := Self; 731 781 Map := TMap.Create; 782 Map.Game := Self; 732 783 Players := TPlayers.Create; 733 784 Players.Game := Self; … … 742 793 MaxNeutralUnits := Min(4, MaxPower); 743 794 744 Map.Game := Self;745 795 Map.Size := TPoint.Create(3, 3); 746 796 end; … … 750 800 FreeAndNil(Players); 751 801 FreeAndNil(Map); 802 FreeAndNil(Units); 752 803 inherited Destroy; 753 804 end; … … 784 835 end; 785 836 786 for Player in Players do Player.StartCell := nil; 837 for Player in Players do begin 838 Player.Reset; 839 Player.StartCell := nil; 840 end; 787 841 I := 0; 788 842 for Player in Players do … … 797 851 StartCell.Terrain := ttCity; 798 852 StartCell.Player := Player; 799 StartCell.Power := Player.StartUnits; 853 if not Assigned(StartCell.OneUnit) then 854 StartCell.OneUnit := Units.AddNew(GameSystem.UnitKinds[0], Player.StartUnits); 855 StartCell.OneUnit.Power := Player.StartUnits; 856 StartCell.OneUnit.Kind := GameSystem.UnitKinds[0]; 800 857 end; 801 858 end; -
trunk/UMap.pas
r258 r265 7 7 uses 8 8 Classes, SysUtils, Graphics, ExtCtrls, UGeometry, DOM, fgl, 9 UXMLUtils ;9 UXMLUtils, UUnit; 10 10 11 11 const … … 30 30 FMap: TMap; 31 31 FPower: Integer; 32 FUnit: TUnit; 33 function GetPower: Integer; 32 34 procedure SetArea(AValue: TMapArea); 33 35 procedure SetId(AValue: Integer); 34 36 procedure SetPower(AValue: Integer); 37 procedure SetUnit(AValue: TUnit); 35 38 public 36 39 PosPx: TPoint; 37 40 Polygon: TPolygon; 38 41 Terrain: TTerrainType; 39 PlayerId: Integer; 42 PlayerId: Integer; // Temporary value 40 43 Player: TObject; // TPlayer; 41 44 NeighborsId: array of Integer; … … 44 47 Weight: Integer; // Temporary value 45 48 Angle: Double; // Temporary value 46 PlayerCell: Pointer; // Temporary value49 PlayerCell: TObject; // Temporary value 47 50 Links: TCellLinks; 48 51 Extra: TExtraType; 49 property Id: Integer read FId write SetId;52 OneUnitId: Integer; // Temporary value 50 53 procedure ConnectTo(Cell: TCell); 51 54 procedure DisconnectFrom(Cell: TCell); … … 60 63 constructor Create; 61 64 destructor Destroy; override; 62 property Power: Integer read FPower write SetPower;65 property Id: Integer read FId write SetId; 63 66 property Map: TMap read FMap write FMap; 64 67 property Area: TMapArea read FArea write SetArea; 68 property OneUnit: TUnit read FUnit write SetUnit; 69 //property Power: Integer read GetPower; 65 70 end; 66 71 … … 612 617 with TPlayer(Player) do begin 613 618 Inc(TotalCells); 614 Inc(TotalUnits, Power); 619 if Assigned(OneUnit) then 620 Inc(TotalUnits, OneUnit.Power); 615 621 if Terrain = ttCity then 616 622 Inc(TotalCities); … … 656 662 for C := 0 to (Cells.Count div 2) - 1 do begin 657 663 Cells[C].Terrain := Cells[Cells.Count - 1 - C].Terrain; 658 Cells[C]. Power := Cells[Cells.Count - 1 - C].Power;664 Cells[C].OneUnit.Power := Cells[Cells.Count - 1 - C].OneUnit.Power; 659 665 660 666 for I := Cells[C].Links.Count - 1 downto 0 do begin … … 908 914 end; 909 915 916 procedure TCell.SetUnit(AValue: TUnit); 917 var 918 OldValue: TUnit; 919 begin 920 if FUnit = AValue then Exit; 921 OldValue := FUnit; 922 FUnit := nil; 923 if Assigned(OldValue) then OldValue.MapCell := nil; 924 FUnit := AValue; 925 if Assigned(FUnit) then FUnit.MapCell := Self; 926 end; 927 910 928 procedure TCell.ConnectTo(Cell: TCell); 911 929 begin … … 950 968 end; 951 969 970 function TCell.GetPower: Integer; 971 begin 972 if Assigned(OneUnit) then Result := OneUnit.Power 973 else Result := 0; 974 end; 975 952 976 procedure TCell.SetId(AValue: Integer); 953 977 begin … … 973 997 begin 974 998 Player := TGame(Map.Game).Players.FindById(PlayerId); 999 OneUnit := TGame(Map.Game).Units.FindById(OneUnitId); 975 1000 976 1001 Neighbors.Count := Length(NeighborsId); … … 993 1018 begin 994 1019 Id := ReadInteger(Node, 'Id', 0); 995 Power := ReadInteger(Node, 'Power', 0);1020 OneUnitId := ReadInteger(Node, 'Unit', 0); 996 1021 Terrain := TTerrainType(ReadInteger(Node, 'Terrain', Integer(ttVoid))); 997 1022 Extra := TExtraType(ReadInteger(Node, 'Extra', Integer(etNone))); … … 1029 1054 begin 1030 1055 WriteInteger(Node, 'Id', Id); 1031 WriteInteger(Node, 'Power', Power); 1056 if Assigned(OneUnit) then 1057 WriteInteger(Node, 'Unit', OneUnit.Id) 1058 else WriteInteger(Node, 'Unit', 0); 1032 1059 WriteInteger(Node, 'Terrain', Integer(Terrain)); 1033 1060 WriteInteger(Node, 'Extra', Integer(Extra)); … … 1090 1117 I: Integer; 1091 1118 begin 1119 OneUnit := nil; 1092 1120 for I := Links.Count - 1 downto 0 do 1093 1121 FMap.CellLinks.Remove(Links[I]); -
trunk/UPlayer.pas
r262 r265 6 6 7 7 uses 8 Classes, SysUtils, Graphics, UMap, DOM, fgl, XMLConf, 9 U XMLUtils, Math, UGeometry;8 Classes, SysUtils, Graphics, UMap, DOM, fgl, XMLConf, UXMLUtils, Math, 9 UGeometry, UUnit; 10 10 11 11 type … … 96 96 FMode: TPlayerMode; 97 97 FOnMove: TMoveEvent; 98 procedure MoveUnit(UnitMove: TUnitMove); 98 99 procedure SetGame(AValue: TObject); // TGame 99 100 procedure Attack(var AttackPower, DefendPower: Integer); … … 118 119 TurnStats: TGameTurnStats; 119 120 Moves: TUnitMoves; 121 Units: TUnits; 120 122 procedure ReduceMovesPower; 121 123 procedure RemoveInvalidMoves; … … 148 150 public 149 151 Game: TObject; //TGame; 150 New PlayerId: Integer;152 NewId: Integer; 151 153 function FindById(Id: Integer): TPlayer; 152 154 procedure New(Name: string; Color: TColor; Mode: TPlayerMode); 153 function GetNew PlayerId: Integer;155 function GetNewId: Integer; 154 156 procedure LoadFromNode(Node: TDOMNode); 155 157 procedure SaveToNode(Node: TDOMNode); … … 259 261 UnitMove: TUnitMove; 260 262 begin 261 Result := MapCell.Power; 263 if Assigned(MapCell.OneUnit) then Result := MapCell.OneUnit.Power 264 else Result := 0; 262 265 for UnitMove in MovesFrom do 263 266 Result := Result - UnitMove.CountOnce; … … 433 436 with TPlayerCell(Cells[I]) do begin 434 437 for J := 0 to MapCell.Neighbors.Count - 1 do 435 ConnectTo(T Cell(MapCell.Neighbors[J]).PlayerCell);438 ConnectTo(TPlayerCell(TCell(MapCell.Neighbors[J]).PlayerCell)); 436 439 end; 437 440 end; … … 511 514 NewPlayer.Color := Color; 512 515 NewPlayer.Mode := Mode; 513 NewPlayer.Id := GetNew PlayerId;516 NewPlayer.Id := GetNewId; 514 517 if Mode = pmComputer then 515 518 NewPlayer.Agressivity := caMedium; … … 517 520 end; 518 521 519 function TPlayers.GetNew PlayerId: Integer;520 begin 521 Result := New PlayerId;522 Inc(New PlayerId);522 function TPlayers.GetNewId: Integer; 523 begin 524 Result := NewId; 525 Inc(NewId); 523 526 end; 524 527 … … 554 557 begin 555 558 inherited; 556 New PlayerId := 1;559 NewId := 1; 557 560 end; 558 561 … … 579 582 Items[I].Game := Game; 580 583 end; 581 New PlayerId := Source.NewPlayerId;584 NewId := Source.NewId; 582 585 end; 583 586 … … 589 592 with Config do begin 590 593 NewCount := GetValue(DOMString(Path + '/Count'), -1); 591 New PlayerId := 1;592 if NewCount >= 2then begin594 NewId := 1; 595 if NewCount >= MinPlayerCount then begin 593 596 Self.Clear; 594 597 Count := NewCount; 595 598 for I := 0 to Count - 1 do begin 596 599 Items[I] := TPlayer.Create; 597 Items[I].Id := GetNew PlayerId;600 Items[I].Id := GetNewId; 598 601 Items[I].Game := Game; 599 602 Items[I].LoadConfig(Config, Path + '/Player' + IntToStr(I)); … … 683 686 684 687 procedure TUnitMove.SetCellFrom(AValue: TPlayerCell); 688 var 689 OldValue: TPlayerCell; 685 690 begin 686 691 if FCellFrom = AValue then Exit; 687 if Assigned(AValue) and not Assigned(FCellFrom) then begin 688 if AValue.MovesFrom.IndexOf(Self) = -1 then 689 AValue.MovesFrom.Add(Self) 692 OldValue := FCellFrom; 693 FCellFrom := nil; 694 if Assigned(OldValue) then begin 695 if OldValue.MovesFrom.IndexOf(Self) <> -1 then 696 OldValue.MovesFrom.Remove(Self) 697 else raise Exception.Create('Unit move not found'); 698 end; 699 FCellFrom := AValue; 700 if Assigned(FCellFrom) then begin 701 if FCellFrom.MovesFrom.IndexOf(Self) = -1 then 702 FCellFrom.MovesFrom.Add(Self) 690 703 else raise Exception.Create('Unit move already exists'); 691 704 end else 692 if not Assigned(AValue) and Assigned(FCellFrom) then begin 693 if FCellFrom.MovesFrom.IndexOf(Self) <> -1 then 694 FCellFrom.MovesFrom.Remove(Self) 705 end; 706 707 procedure TUnitMove.SetCellTo(AValue: TPlayerCell); 708 var 709 OldValue: TPlayerCell; 710 begin 711 if FCellTo = AValue then Exit; 712 OldValue := FCellTo; 713 FCellTo := nil; 714 if Assigned(OldValue) then begin 715 if OldValue.MovesTo.IndexOf(Self) <> -1 then 716 OldValue.MovesTo.Remove(Self) 695 717 else raise Exception.Create('Unit move not found'); 696 718 end; 697 FCellFrom := AValue; 698 end; 699 700 procedure TUnitMove.SetCellTo(AValue: TPlayerCell); 701 begin 702 if FCellTo = AValue then Exit; 703 if Assigned(AValue) and not Assigned(FCellTo) then begin 704 AValue.MovesTo.Add(Self); 719 FCellTo := AValue; 720 if Assigned(FCellTo) then begin 721 if FCellTo.MovesTo.IndexOf(Self) = -1 then 722 FCellTo.MovesTo.Add(Self) 723 else raise Exception.Create('Unit move already exists'); 705 724 end else 706 if not Assigned(AValue) and Assigned(FCellTo) then begin707 FCellTo.MovesTo.Remove(Self);708 end;709 FCellTo := AValue;710 725 end; 711 726 … … 829 844 constructor TPlayer.Create; 830 845 begin 846 Units := TUnits.Create(False); 831 847 Moves := TUnitMoves.Create; 832 848 Moves.Player := Self; … … 844 860 FreeAndNil(PlayerMap); 845 861 FreeAndNil(Moves); 862 FreeAndNil(Units); 846 863 inherited Destroy; 847 864 end; … … 937 954 938 955 function CellCompare(const Item1, Item2: TPlayerCell): Integer; 939 begin 940 if Item1.MapCell.Power > Item2.MapCell.Power then Result := 1 941 else if Item1.MapCell.Power < Item2.MapCell.Power then Result := -1 956 var 957 Stack1, Stack2: Integer; 958 begin 959 if Assigned(Item1.MapCell.OneUnit) then Stack1 := Item1.MapCell.OneUnit.Power 960 else Stack1 := 0; 961 if Assigned(Item2.MapCell.OneUnit) then Stack2 := Item2.MapCell.OneUnit.Power 962 else Stack2 := 0; 963 if Stack1 > Stack1 then Result := 1 964 else if Stack1 < Stack2 then Result := -1 942 965 else Result := 0; 943 966 end; 944 967 945 968 function CellCompareDescending(const Item1, Item2: TPlayerCell): Integer; 946 begin 947 if Item1.MapCell.Power > Item2.MapCell.Power then Result := -1 948 else if Item1.MapCell.Power < Item2.MapCell.Power then Result := 1 969 var 970 Stack1, Stack2: Integer; 971 begin 972 if Assigned(Item1.MapCell.OneUnit) then Stack1 := Item1.MapCell.OneUnit.Power 973 else Stack1 := 0; 974 if Assigned(Item2.MapCell.OneUnit) then Stack2 := Item2.MapCell.OneUnit.Power 975 else Stack2 := 0; 976 if Stack1 > Stack2 then Result := -1 977 else if Stack1 < Stack2 then Result := 1 949 978 else Result := 0; 950 979 end; 951 980 952 procedure TPlayer.Move All;981 procedure TPlayer.MoveUnit(UnitMove: TUnitMove); 953 982 var 954 983 AttackerPower: Integer; 955 984 DefenderPower: Integer; 956 985 UnitCount: Integer; 986 begin 987 with UnitMove do begin 988 UnitCount := CountOnce; 989 if CountOnce > CellFrom.MapCell.OneUnit.Power then 990 UnitCount := CellFrom.MapCell.OneUnit.Power; 991 CountOnce := 0; 992 if not Assigned(CellTo.MapCell.OneUnit) then begin 993 CellTo.MapCell.OneUnit := TGame(Game).Units.AddNew(CellFrom.MapCell.OneUnit.Kind, 0); 994 CellTo.MapCell.Player := Self; 995 end; 996 997 if CellTo.MapCell.OneUnit.Player = Self then begin 998 // Inner move 999 CellTo.MapCell.OneUnit.Power := CellTo.MapCell.OneUnit.Power + UnitCount; 1000 end else begin 1001 AttackerPower := UnitCount; 1002 if Assigned(CellTo.MapCell.OneUnit) then 1003 DefenderPower := CellTo.MapCell.OneUnit.Power 1004 else DefenderPower := 0; 1005 Attack(AttackerPower, DefenderPower); 1006 if DefenderPower = 0 then begin 1007 // Attacker wins with possible loses 1008 ClearMovesFromCell(CellTo); 1009 CellTo.MapCell.Player := Self; 1010 CellTo.MapCell.OneUnit.Player := Self; 1011 CellTo.MapCell.OneUnit.Power := AttackerPower; 1012 end else 1013 if AttackerPower = 0 then begin 1014 // Defender wins with possible loses 1015 CellTo.MapCell.OneUnit.Power := DefenderPower; 1016 end else 1017 raise Exception.Create(SUnfinishedBattle); 1018 end; 1019 CellFrom.MapCell.OneUnit.Power := CellFrom.MapCell.OneUnit.Power - UnitCount; 1020 end; 1021 end; 1022 1023 procedure TPlayer.MoveAll; 1024 var 957 1025 UnitMove: TUnitMove; 958 1026 begin 959 1027 for UnitMove in Moves do 960 with UnitMove do begin1028 with UnitMove do 961 1029 if CountOnce > 0 then begin 962 1030 if CellFrom.MapCell.Player = Self then begin 963 UnitCount := CountOnce; 964 if CountOnce > CellFrom.MapCell.Power then 965 UnitCount := CellFrom.MapCell.Power; 966 CountOnce := 0; 967 if CellTo.MapCell.Player = Self then begin 968 // Inner move 969 CellTo.MapCell.Power := CellTo.MapCell.Power + UnitCount; 970 end else begin 971 AttackerPower := UnitCount; 972 DefenderPower := CellTo.MapCell.Power; 973 Attack(AttackerPower, DefenderPower); 974 if DefenderPower = 0 then begin 975 // Attacker wins with possible loses 976 ClearMovesFromCell(CellTo); 977 CellTo.MapCell.Player := Self; 978 CellTo.MapCell.Power := AttackerPower; 979 end else 980 if AttackerPower = 0 then begin 981 // Defender wins with possible loses 982 CellTo.MapCell.Power := DefenderPower; 983 end else 984 raise Exception.Create(SUnfinishedBattle); 985 end; 986 CellFrom.MapCell.Power := CellFrom.MapCell.Power - UnitCount; 987 end; 1031 MoveUnit(UnitMove); 988 1032 end; 989 1033 end; … … 1020 1064 var 1021 1065 I: Integer; 1022 begin 1023 for I := Cell.MovesFrom.Count - 1 downto 0 do 1024 Cell.MovesFrom.Delete(I); 1066 OtherPlayerCell: TPlayerCell; 1067 begin 1068 if Assigned(Cell.MapCell.Player) then 1069 with TPlayer(Cell.MapCell.Player) do begin 1070 OtherPlayerCell := PlayerMap.Cells.SearchCell(Cell.MapCell); 1071 if Assigned(OtherPlayerCell) then begin 1072 for I := OtherPlayerCell.MovesFrom.Count - 1 downto 0 do 1073 Moves.Remove(OtherPlayerCell.MovesFrom[I]); 1074 end; 1075 end; 1025 1076 end; 1026 1077 … … 1082 1133 var 1083 1134 Move: TUnitMove; 1135 AvailPower: Integer; 1084 1136 begin 1085 1137 for Move in Moves do 1086 1138 with Move do begin 1087 if CellFrom.MapCell.Player = Self then 1088 if CountRepeat <= CellFrom.GetAvialPower then 1139 if CellFrom.MapCell.Player = Self then begin 1140 AvailPower := CellFrom.GetAvialPower + Move.CountOnce; 1141 if CountRepeat <= AvailPower then 1089 1142 CountOnce := CountRepeat 1090 else CountOnce := CellFrom.GetAvialPower; 1143 else CountOnce := AvailPower; 1144 end; 1091 1145 end; 1092 1146 RemoveEmptyUnitMoves; … … 1097 1151 I: Integer; 1098 1152 begin 1099 if TGame(Game). EmptyCellsNeutral then1153 if TGame(Game).GameSystem.EmptyCellsNeutral then 1100 1154 for I := 0 to PlayerMap.Cells.Count - 1 do 1101 1155 with TPlayerCell(PlayerMap.Cells[I]) do begin 1102 if MapCell. Power = 0 then MapCell.Player := nil;1156 if MapCell.OneUnit.Power = 0 then MapCell.Player := nil; 1103 1157 end; 1104 1158 end; … … 1108 1162 I: Integer; 1109 1163 begin 1110 // Remove empty moves1111 1164 for I := Moves.Count - 1 downto 0 do 1112 1165 if (TUnitMove(Moves[I]).CellFrom.MapCell.Player = Self) and … … 1168 1221 with TGame(Game).Map do 1169 1222 for I := 0 to Cells.Count - 1 do 1170 with Cells[I]do begin1223 with TCell(Cells[I]) do begin 1171 1224 if (Player = Self) and ((TGame(Game).GrowCells = gcPlayerAll) or 1172 1225 ((TGame(Game).GrowCells = gcPlayerCities) and (Terrain = ttCity))) then begin 1173 if Power < MaxPower then begin1226 if OneUnit.Power < MaxPower then begin 1174 1227 // Increase units count 1175 1228 Addition := 0; … … 1178 1231 end else 1179 1232 if TGame(Game).GrowAmount = gaBySquareRoot then begin 1180 Addition := Trunc(Sqrt( Power));1233 Addition := Trunc(Sqrt(OneUnit.Power)); 1181 1234 if Addition = 0 then Addition := 1; 1182 1235 end; 1183 Power := Min(Power + Addition, MaxPower);1236 OneUnit.Power := Min(OneUnit.Power + Addition, MaxPower); 1184 1237 end else 1185 if Power > MaxPower then begin1238 if OneUnit.Power > MaxPower then begin 1186 1239 // Reduce units count 1187 1240 // If cell has more then MaxPower units then additional units dies 1188 1241 // in twice of squeare root of unites over MaxPower 1189 Dies := 2 * Trunc(Sqrt( Power - MaxPower));1190 Power := Max(Power - Dies, 0);1242 Dies := 2 * Trunc(Sqrt(OneUnit.Power - MaxPower)); 1243 OneUnit.Power := Max(OneUnit.Power - Dies, 0); 1191 1244 end; 1192 1245 end; -
trunk/xtactics.lpi
r253 r265 109 109 </Item7> 110 110 </RequiredPackages> 111 <Units Count="3 3">111 <Units Count="36"> 112 112 <Unit0> 113 113 <Filename Value="xtactics.lpr"/> … … 287 287 <IsPartOfProject Value="True"/> 288 288 </Unit32> 289 <Unit33> 290 <Filename Value="UUnit.pas"/> 291 <IsPartOfProject Value="True"/> 292 </Unit33> 293 <Unit34> 294 <Filename Value="UGameSystem.pas"/> 295 <IsPartOfProject Value="True"/> 296 </Unit34> 297 <Unit35> 298 <Filename Value="UBuilding.pas"/> 299 <IsPartOfProject Value="True"/> 300 </Unit35> 289 301 </Units> 290 302 </ProjectOptions>
Note:
See TracChangeset
for help on using the changeset viewer.