Changeset 274
- Timestamp:
- Feb 3, 2019, 8:32:20 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormClient.pas
r273 r274 155 155 FormMove.TrackBarRepeat.Max := FormMove.SpinEditRepeat.MaxValue; 156 156 FormMove.TrackBarRepeat.Position := FormMove.SpinEditRepeat.Value; 157 158 FormMove.AllowChangeOnce := Client.Game.GameSystem.UnitsSplitMerge; 159 157 160 if Assigned(CellTo.MapCell.OneUnit) then 158 161 FormMove.DefendCount := CellTo.MapCell.OneUnit.Power -
trunk/Forms/UFormMove.pas
r272 r274 48 48 AttackCount: Integer; 49 49 ShowWinProbability: Boolean; 50 AllowChangeOnce: Boolean; 50 51 procedure UpdateView; 51 52 end; … … 102 103 SpinEditRepeat.SetFocus; 103 104 end else begin 104 SpinEditOnce.Enabled := True; 105 TrackBarOnce.Enabled := True; 106 SpinEditOnce.SetFocus; 105 SpinEditOnce.Enabled := AllowChangeOnce; 106 TrackBarOnce.Enabled := AllowChangeOnce; 107 ButtonOnceMax.Enabled := AllowChangeOnce; 108 ButtonOnceMin.Enabled := AllowChangeOnce; 109 if SpinEditOnce.Enabled then SpinEditOnce.SetFocus 110 else if SpinEditRepeat.Enabled then SpinEditRepeat.SetFocus 111 else ButtonOk.SetFocus; 107 112 end; 108 113 UpdateView; -
trunk/Forms/UFormNew.lfm
r273 r274 33 33 object Panel3: TPanel 34 34 Left = 0 35 Height = 65 535 Height = 652 36 36 Top = 0 37 Width = 7 3937 Width = 796 38 38 Align = alClient 39 39 BevelOuter = bvNone 40 ClientHeight = 65 541 ClientWidth = 7 3940 ClientHeight = 652 41 ClientWidth = 796 42 42 TabOrder = 0 43 43 object RadioButtonModeLocal: TRadioButton … … 103 103 object ListViewServers: TListView 104 104 Left = 26 105 Height = 42 3105 Height = 420 106 106 Top = 181 107 107 Width = 334 … … 131 131 Left = 27 132 132 Height = 31 133 Top = 61 6133 Top = 613 134 134 Width = 94 135 135 Action = AServerAdd … … 140 140 Left = 240 141 141 Height = 31 142 Top = 61 6142 Top = 613 143 143 Width = 94 144 144 Action = AServerRemove … … 149 149 Left = 136 150 150 Height = 30 151 Top = 61 6151 Top = 613 152 152 Width = 94 153 153 Action = AServerModify … … 326 326 object ComboBoxGridType: TComboBox 327 327 Left = 146 328 Height = 42328 Height = 38 329 329 Top = 104 330 330 Width = 208 … … 343 343 object ComboBoxMapShape: TComboBox 344 344 Left = 146 345 Height = 42345 Height = 38 346 346 Top = 144 347 347 Width = 208 … … 587 587 object ComboBoxWinObjective: TComboBox 588 588 Left = 224 589 Height = 42589 Height = 38 590 590 Top = 244 591 591 Width = 328 … … 702 702 TabOrder = 5 703 703 end 704 object CheckBoxUnitsSplitMerge: TCheckBox 705 Left = 336 706 Height = 30 707 Top = 101 708 Width = 231 709 Caption = 'Units can split or merge' 710 TabOrder = 6 711 end 712 object CheckBoxUnitsMoveImmediately: TCheckBox 713 Left = 336 714 Height = 30 715 Top = 141 716 Width = 234 717 Caption = 'Units move immediately' 718 TabOrder = 7 719 end 704 720 end 705 721 end -
trunk/Forms/UFormNew.pas
r273 r274 32 32 ButtonPlayerModify: TButton; 33 33 ButtonPlayerRemove: TButton; 34 CheckBoxUnitsSplitMerge: TCheckBox; 34 35 CheckBoxEmptyCellsNeutral: TCheckBox; 35 36 CheckBoxBridges: TCheckBox; … … 38 39 CheckBoxFogOfWar: TCheckBox; 39 40 CheckBoxSymetricMap: TCheckBox; 41 CheckBoxUnitsMoveImmediately: TCheckBox; 40 42 CheckBoxVoid: TCheckBox; 41 43 ComboBoxGridType: TComboBox; … … 360 362 SpinEditSpecialCells.Value := SpecialCaptureCellCount; 361 363 CheckBoxEmptyCellsNeutral.Checked := GameSystem.EmptyCellsNeutral; 364 CheckBoxUnitsSplitMerge.Checked := GameSystem.UnitsSplitMerge; 365 CheckBoxUnitsMoveImmediately.Checked := GameSystem.UnitsMoveImmediately; 362 366 end; 363 367 end; … … 389 393 SpecialCaptureCellCount := SpinEditSpecialCells.Value; 390 394 GameSystem.EmptyCellsNeutral := CheckBoxEmptyCellsNeutral.Checked; 395 GameSystem.UnitsSplitMerge := CheckBoxUnitsSplitMerge.Checked; 396 GameSystem.UnitsMoveImmediately := CheckBoxUnitsMoveImmediately.Checked; 391 397 end; 392 398 end; -
trunk/Languages/xtactics.cs.po
r273 r274 438 438 msgid "Symetric map" 439 439 msgstr "Symetrická mapa" 440 441 #: tformnew.checkboxunitsmoveimmediately.caption 442 msgid "Units move immediately" 443 msgstr "Okamžitý pohyb jednotek" 444 445 #: tformnew.checkboxunitssplitmerge.caption 446 msgid "Units can split or merge" 447 msgstr "Dělení nebo slučování jednotek" 440 448 441 449 #: tformnew.checkboxvoid.caption -
trunk/Languages/xtactics.po
r273 r274 424 424 #: tformnew.checkboxsymetricmap.caption 425 425 msgid "Symetric map" 426 msgstr "" 427 428 #: tformnew.checkboxunitsmoveimmediately.caption 429 msgid "Units move immediately" 430 msgstr "" 431 432 #: tformnew.checkboxunitssplitmerge.caption 433 msgid "Units can split or merge" 426 434 msgstr "" 427 435 -
trunk/UClientAI.pas
r273 r274 69 69 70 70 // Sort ascending to attack cells with lower power first 71 // Low power cells are better for expanding our ter itorry71 // Low power cells are better for expanding our territory 72 72 TargetCells.Sort(CellCompare); 73 73 … … 79 79 for NeighborCell in Neighbors do 80 80 if NeighborCell.MapCell.Player = ControlPlayer then 81 TotalPower := TotalPower + NeighborCell.GetAvialPower ;81 TotalPower := TotalPower + NeighborCell.GetAvialPowerForMove; 82 82 83 83 // Attack if target is weaker … … 195 195 for C := 0 to AllCells.Count - 1 do 196 196 with AllCells[C] do begin 197 if (MapCell.Player <> ControlPlayer) and (MapCell. Player <> nil) and (MapCell.Terrain <> ttVoid) then begin197 if (MapCell.Player <> ControlPlayer) and (MapCell.Terrain <> ttVoid) then begin 198 198 CanAttack := 0; 199 199 for I := 0 to Neighbors.Count - 1 do … … 307 307 // Move all units back to inner area from weak border cells 308 308 for C := 0 to BorderCells.Count - 1 do 309 with BorderCells[C]do begin309 with TPlayerCell(BorderCells[C]) do begin 310 310 // Calculate enemy power 311 311 // TODO: Do not sum different enemy power to one value -
trunk/UClientGUI.pas
r273 r274 352 352 if Assigned(SelectedCell) and (SelectedCell = Cell) then 353 353 Brush.Color := clGreen 354 else if Assigned(SelectedCell) and TGame(Game).Map.IsCellsNeighbor(SelectedCell.MapCell, Cell.MapCell) then354 else if Assigned(SelectedCell) and ControlPlayer.IsAllowedMoveTarget(SelectedCell, Cell) then 355 355 Brush.Color := clPurple 356 356 else if TGame(Game).FogOfWar then begin … … 616 616 if Assigned(NewSelectedCell) then begin 617 617 if Assigned(SelectedCell) and (NewSelectedCell <> SelectedCell) and 618 TGame(Game).Map.IsCellsNeighbor(NewSelectedCell.MapCell, SelectedCell.MapCell) then begin618 TGame(Game).CurrentPlayer.IsAllowedMoveTarget(SelectedCell, NewSelectedCell) then begin 619 619 if ssShift in ShiftState then begin 620 620 // Make maximum unit move without confirmation dialog … … 640 640 end; 641 641 end else 642 if (NewSelectedCell <> SelectedCell) and (NewSelectedCell.MapCell.Player = Player) then begin642 if not Assigned(SelectedCell) and (NewSelectedCell <> SelectedCell) and (NewSelectedCell.MapCell.Player = Player) then begin 643 643 SelectedCell := NewSelectedCell 644 644 end else -
trunk/UCore.pas
r273 r274 106 106 procedure LoadConfig; 107 107 procedure SaveConfig; 108 procedure SaveConfigAll; 108 109 procedure Spectate(Player: TPlayer); 109 110 procedure UpdateInterface; … … 225 226 end; 226 227 228 procedure TCore.SaveConfigAll; 229 begin 230 GameSettings.SaveConfig(XMLConfig1, 'Game'); 231 Server.SaveConfig(XMLConfig1, 'Server'); 232 ServerList.SaveConfig(XmlConfig1, 'ServerList'); 233 SaveConfig; 234 XMLConfig1.Flush; 235 end; 236 227 237 procedure TCore.CommandLineParams; 228 238 var … … 348 358 GameSettings.PostConfig; 349 359 Game.Assign(GameSettings); 360 SaveConfigAll; 350 361 StartNewGame; 351 362 GameLoaded := False; … … 758 769 procedure TCore.Done; 759 770 begin 760 GameSettings.SaveConfig(XMLConfig1, 'Game'); 761 Server.SaveConfig(XMLConfig1, 'Server'); 762 ServerList.SaveConfig(XmlConfig1, 'ServerList'); 763 SaveConfig; 764 XMLConfig1.Flush; 771 SaveConfigAll; 765 772 end; 766 773 -
trunk/UGame.pas
r273 r274 349 349 StartCell.OneUnit.Power := Player.StartUnits; 350 350 StartCell.OneUnit.Kind := GameSystem.UnitKinds[0]; 351 StartCell.OneUnit.Player := Player; 351 352 end; 352 353 end; 354 InitUnitMoves; 353 355 PlayerMap.CheckVisibility; 354 356 Inc(I); … … 524 526 SetValue(DOMString(Path + '/MaxPower'), MaxPower); 525 527 Players.SaveConfig(Config, Path + '/Players'); 528 GameSystem.SaveConfig(Config, Path + '/GameSystem'); 526 529 end; 527 530 end; … … 562 565 MaxPower := GetValue(DOMString(Path + '/MaxPower'), 99); 563 566 Players.LoadConfig(Config, Path + '/Players'); 567 GameSystem.LoadConfig(Config, Path + '/GameSystem'); 564 568 end; 565 569 end; … … 771 775 CurrentPlayer.ReduceMovesPower; 772 776 CurrentPlayer.RemoveInvalidMoves; 777 CurrentPlayer.InitUnitMoves; 773 778 if Assigned(FOnChange) then 774 779 FOnChange(Self); -
trunk/UGameSystem.pas
r265 r274 6 6 7 7 uses 8 Classes, SysUtils, fgl, UUnit, DOM, UXMLUtils ;8 Classes, SysUtils, fgl, UUnit, DOM, UXMLUtils, XMLConf; 9 9 10 10 type … … 15 15 TGameSystem = class 16 16 Name: string; 17 ActionExecutionPhase: TActionExecutionPhase;18 17 MaxPlayerCount: Integer; 19 18 UnitKinds: TUnitKinds; 20 CanSplitMerge: Boolean;19 UnitsSplitMerge: Boolean; 21 20 EmptyCellsNeutral: Boolean; 21 UnitsMoveImmediately: Boolean; 22 22 constructor Create; 23 23 destructor Destroy; override; … … 27 27 procedure LoadFromFile(FileName: string); 28 28 procedure SaveToFile(FileName: string); 29 procedure LoadConfig(Config: TXmlConfig; Path: string); 30 procedure SaveConfig(Config: TXmlConfig; Path: string); 29 31 end; 30 32 … … 62 64 begin 63 65 Name := Source.Name; 66 UnitsMoveImmediately := Source.UnitsMoveImmediately; 64 67 MaxPlayerCount := Source.MaxPlayerCount; 65 CanSplitMerge := Source.CanSplitMerge;68 UnitsSplitMerge := Source.UnitsSplitMerge; 66 69 EmptyCellsNeutral := Source.EmptyCellsNeutral; 67 70 end; … … 72 75 begin 73 76 Name := ReadString(Node, 'Name', ''); 74 CanSplitMerge := ReadBoolean(Node, 'CanSplitMerge', False);77 UnitsSplitMerge := ReadBoolean(Node, 'UnitsSplitMerge', False); 75 78 EmptyCellsNeutral := ReadBoolean(Node, 'EmptyCellsNeutral', False); 79 UnitsMoveImmediately := ReadBoolean(Node, 'UnitsMoveImmediately', False); 76 80 77 81 NewNode := Node.FindNode('UnitKinds'); … … 85 89 begin 86 90 WriteString(Node, 'Name', Name); 87 WriteBoolean(Node, ' CanSplitMerge', CanSplitMerge);91 WriteBoolean(Node, 'UnitsSplitMerge', UnitsSplitMerge); 88 92 WriteBoolean(Node, 'EmptyCellsNeutral', EmptyCellsNeutral); 93 WriteBoolean(Node, 'UnitsMoveImmediately', UnitsMoveImmediately); 89 94 90 95 NewNode := Node.OwnerDocument.CreateElement('UnitKinds'); … … 103 108 end; 104 109 110 procedure TGameSystem.LoadConfig(Config: TXmlConfig; Path: string); 111 begin 112 with Config do begin 113 Self.Name := string(GetValue(DOMString(Path + '/Name'), DOMString(''))); 114 UnitsSplitMerge := GetValue(DOMString(Path + '/UnitsSplitMerge'), True); 115 EmptyCellsNeutral := GetValue(DOMString(Path + '/EmptyCellsNeutral'), False); 116 UnitsMoveImmediately := GetValue(DOMString(Path + '/UnitsMoveImmediately'), False); 117 end; 118 end; 119 120 procedure TGameSystem.SaveConfig(Config: TXmlConfig; Path: string); 121 begin 122 with Config do begin 123 SetValue(DOMString(Path + '/Name'), DOMString(Self.Name)); 124 SetValue(DOMString(Path + '/UnitsSplitMerge'), UnitsSplitMerge); 125 SetValue(DOMString(Path + '/EmptyCellsNeutral'), EmptyCellsNeutral); 126 SetValue(DOMString(Path + '/UnitsMoveImmediately'), UnitsMoveImmediately); 127 end; 128 end; 129 105 130 end. 106 131 -
trunk/UPlayer.pas
r273 r274 28 28 procedure DisconnectFrom(Cell: TPlayerCell); 29 29 function GetAvialPower: Integer; 30 function GetAvialPowerForMove: Integer; 30 31 function GetAttackPower: Integer; 31 32 procedure LoadFromNode(Node: TDOMNode); … … 102 103 procedure CheckCounterMove(Move: TUnitMove); 103 104 procedure SetMode(AValue: TPlayerMode); 104 procedure RemoveEmptyUnitMoves;105 105 public 106 106 Id: Integer; … … 120 120 Moves: TUnitMoves; 121 121 Units: TUnits; 122 function IsAllowedMoveTarget(CellFrom, CellTo: TPlayerCell): Boolean; 122 123 procedure ReduceMovesPower; 123 124 procedure RemoveInvalidMoves; 124 125 procedure RemoveEmptyUnits; 126 procedure InitUnitMoves; 125 127 procedure UpdateRepeatMoves; 126 128 procedure UpdateEmptyCellsNeutral; … … 205 207 206 208 uses 207 UGame ;209 UGame, UGameSystem; 208 210 209 211 resourcestring … … 262 264 UnitMove: TUnitMove; 263 265 begin 264 if Assigned(MapCell.OneUnit) then Result := MapCell.OneUnit.Power 265 else Result := 0; 266 Result := 0; 267 if Assigned(MapCell.OneUnit) then 268 Result := MapCell.OneUnit.Power; 269 for UnitMove in MovesFrom do 270 Result := Result - UnitMove.CountOnce; 271 end; 272 273 function TPlayerCell.GetAvialPowerForMove: Integer; 274 var 275 UnitMove: TUnitMove; 276 begin 277 Result := 0; 278 if Assigned(MapCell.OneUnit) then 279 if MapCell.OneUnit.Moves > 0 then Result := MapCell.OneUnit.Power; 266 280 for UnitMove in MovesFrom do 267 281 Result := Result - UnitMove.CountOnce; … … 999 1013 // Inner move 1000 1014 CellTo.MapCell.OneUnit.Power := CellTo.MapCell.OneUnit.Power + UnitCount; 1015 Dec(CellTo.MapCell.OneUnit.Moves); 1001 1016 end else begin 1002 1017 AttackerPower := UnitCount; … … 1015 1030 // Defender wins with possible loses 1016 1031 CellTo.MapCell.OneUnit.Power := DefenderPower; 1032 CellTo.MapCell.OneUnit.Moves := CellFrom.MapCell.OneUnit.Moves - 1; 1017 1033 end else 1018 1034 raise Exception.Create(SUnfinishedBattle); … … 1020 1036 CellFrom.MapCell.OneUnit.Power := CellFrom.MapCell.OneUnit.Power - UnitCount; 1021 1037 end; 1038 1039 // Clean from cell from empty units 1040 if UnitMove.CellFrom.MapCell.OneUnit.Power = 0 then begin 1041 Units.Remove(UnitMove.CellFrom.MapCell.OneUnit); 1042 UnitMove.CellFrom.MapCell.OneUnit := nil; 1043 end; 1044 1045 // Remove empty move 1046 if (UnitMove.CellFrom.MapCell.Player = Self) and 1047 (UnitMove.CountOnce = 0) and (UnitMove.CountRepeat = 0) then 1048 Moves.Remove(UnitMove); 1022 1049 end; 1023 1050 1024 1051 procedure TPlayer.MoveAll; 1025 1052 var 1026 UnitMove: TUnitMove;1027 begin 1028 for UnitMove in Movesdo1029 with UnitMovedo1053 I: Integer; 1054 begin 1055 for I := Moves.Count - 1 downto 0 do 1056 with Moves[I] do 1030 1057 if CountOnce > 0 then begin 1031 1058 if CellFrom.MapCell.Player = Self then begin 1032 MoveUnit(UnitMove); 1033 end; 1034 end; 1035 1036 RemoveEmptyUnitMoves; 1059 MoveUnit(Moves[I]); 1060 end; 1061 end; 1037 1062 end; 1038 1063 … … 1077 1102 end; 1078 1103 1104 procedure TPlayer.InitUnitMoves; 1105 var 1106 I: Integer; 1107 begin 1108 for I := 0 to Units.Count - 1 do 1109 TUnit(Units[I]).Moves := TUnit(Units[I]).Kind.Moves; 1110 end; 1111 1079 1112 procedure TPlayer.ClearMovesFromCell(Cell: TPlayerCell); 1080 1113 var … … 1105 1138 1106 1139 if Assigned(Result) then begin 1140 // Update existing move 1107 1141 CountOnce := Result.CountOnce; 1108 1142 CountRepeat := Result.CountRepeat; … … 1111 1145 FOnMove(CellFrom, CellTo, CountOnce, CountRepeat, True, Confirm); 1112 1146 end else begin 1147 // Create new move 1113 1148 CountOnce := Power; 1114 1149 CountRepeat := 0; … … 1139 1174 Result := NewMove; 1140 1175 CheckCounterMove(NewMove); 1176 if TGame(Game).GameSystem.UnitsMoveImmediately then begin 1177 MoveUnit(NewMove); 1178 end; 1141 1179 end; 1142 1180 end; … … 1160 1198 end; 1161 1199 end; 1162 RemoveEmptyUnitMoves;1163 1200 end; 1164 1201 … … 1173 1210 MapCell.Player := nil; 1174 1211 end; 1175 end;1176 1177 procedure TPlayer.RemoveEmptyUnitMoves;1178 var1179 I: Integer;1180 begin1181 for I := Moves.Count - 1 downto 0 do1182 if (TUnitMove(Moves[I]).CellFrom.MapCell.Player = Self) and1183 (TUnitMove(Moves[I]).CountOnce = 0) and (TUnitMove(Moves[I]).CountRepeat = 0) then1184 Moves.Delete(I);1185 1212 end; 1186 1213 … … 1230 1257 end; 1231 1258 1259 function TPlayer.IsAllowedMoveTarget(CellFrom, CellTo: TPlayerCell): Boolean; 1260 var 1261 CellToHasOwnUnit: Boolean; 1262 UnitHasMoveEnergy: Boolean; 1263 begin 1264 CellToHasOwnUnit := Assigned(CellTo.MapCell.OneUnit) and 1265 (CellTo.MapCell.OneUnit.Player = Self) and (CellTo.MapCell.OneUnit.Power > 0); 1266 UnitHasMoveEnergy := Assigned(CellFrom.MapCell.OneUnit) and 1267 (CellFrom.MapCell.OneUnit.Moves > 0); 1268 Result := UnitHasMoveEnergy and 1269 TGame(Game).Map.IsCellsNeighbor(CellFrom.MapCell, CellTo.MapCell) 1270 and (TGame(Game).GameSystem.UnitsSplitMerge or 1271 (not TGame(Game).GameSystem.UnitsSplitMerge and not CellToHasOwnUnit)); 1272 end; 1273 1232 1274 procedure TPlayer.Grow; 1233 1275 var … … 1235 1277 Addition: Integer; 1236 1278 Dies: Integer; 1279 NewUnit: TUnit; 1237 1280 begin 1238 1281 with TGame(Game).Map do … … 1241 1284 if (Player = Self) and ((TGame(Game).GrowCells = gcPlayerAll) or 1242 1285 ((TGame(Game).GrowCells = gcPlayerCities) and (Terrain = ttCity))) then begin 1286 if not Assigned(OneUnit) then begin 1287 NewUnit := TGame(Game).Units.AddNew(TGame(Game).GameSystem.UnitKinds.First, 0); 1288 NewUnit.Player := Self; 1289 NewUnit.MapCell := TCell(Cells[I]); 1290 Units.Add(NewUnit); 1291 end; 1243 1292 if OneUnit.Power < MaxPower then begin 1244 1293 // Increase units count
Note:
See TracChangeset
for help on using the changeset viewer.