- Timestamp:
- Feb 19, 2014, 11:13:36 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UFormMain.pas
r13 r15 102 102 begin 103 103 FormMove.SpinEditOnce.Value := CountOnce; 104 FormMove.SpinEditOnce.MaxValue := CellFrom.GetAvialPower; 104 105 FormMove.SpinEditRepeat.Value := CountRepeat; 106 FormMove.SpinEditRepeat.MaxValue := Game.Map.MaxPower; 105 107 if FormMove.ShowModal = mrOk then begin 106 108 CountOnce := FormMove.SpinEditOnce.Value; -
trunk/UFormNew.lfm
r6 r15 30 30 Height = 24 31 31 Top = 168 32 Width = 1 9432 Width = 175 33 33 Caption = 'Inaccessible places' 34 34 TabOrder = 2 … … 39 39 Top = 8 40 40 Width = 594 41 Columns = <> 41 Columns = < 42 item 43 Caption = 'Name' 44 Width = 200 45 end 46 item 47 Caption = 'Type' 48 Width = 377 49 end> 42 50 TabOrder = 3 51 ViewStyle = vsReport 43 52 end 44 53 object ButtonPlayerAdd: TButton … … 58 67 TabOrder = 5 59 68 end 69 object Label1: TLabel 70 Left = 16 71 Height = 22 72 Top = 206 73 Width = 75 74 Caption = 'Map size:' 75 ParentColor = False 76 end 77 object SpinEditMapSizeX: TSpinEdit 78 Left = 136 79 Height = 32 80 Top = 200 81 Width = 98 82 MinValue = 2 83 TabOrder = 6 84 Value = 2 85 end 86 object SpinEditMapSizeY: TSpinEdit 87 Left = 256 88 Height = 32 89 Top = 200 90 Width = 90 91 MinValue = 2 92 TabOrder = 7 93 Value = 2 94 end 95 object Label2: TLabel 96 Left = 240 97 Height = 22 98 Top = 208 99 Width = 9 100 Caption = 'x' 101 ParentColor = False 102 end 60 103 end -
trunk/UFormNew.pas
r6 r15 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls, UGame;9 ComCtrls, Spin, UGame; 10 10 11 11 type … … 19 19 ButtonPlayerRemove: TButton; 20 20 CheckBoxVoid: TCheckBox; 21 Label1: TLabel; 22 Label2: TLabel; 21 23 ListView1: TListView; 24 SpinEditMapSizeX: TSpinEdit; 25 SpinEditMapSizeY: TSpinEdit; 22 26 private 23 27 { private declarations } … … 37 41 38 42 procedure TFormNew.Load(Game: TGame); 43 var 44 I: Integer; 45 NewItem: TListItem; 39 46 begin 40 47 CheckBoxVoid.Checked := Game.VoidEnabled; 48 ListView1.Items.Clear; 49 for I := 0 to Game.Players.Count - 1 do 50 with TPlayer(Game.Players[I]) do begin 51 NewItem := ListView1.Items.Add; 52 NewItem.Caption := Name; 53 NewItem.SubItems.Add(PlayerModeText[Mode]); 54 end; 55 SpinEditMapSizeX.Value := Game.Map.Size.X; 56 SpinEditMapSizeY.Value := Game.Map.Size.Y; 41 57 end; 42 58 … … 44 60 begin 45 61 Game.VoidEnabled := CheckBoxVoid.Checked; 62 Game.Map.Size := Point(SpinEditMapSizeX.Value, SpinEditMapSizeY.Value); 46 63 end; 47 64 -
trunk/UGame.pas
r14 r15 30 30 MovesTo: TObjectList; 31 31 function GetColor: TColor; 32 function GetAvialPower: Integer; 32 33 constructor Create; 33 34 destructor Destroy; override; … … 112 113 end; 113 114 115 const 116 PlayerModeText: array[TPlayerMode] of string = ('Human', 'Computer'); 117 114 118 115 119 implementation … … 166 170 if Assigned(Player) then Result := Player.Color 167 171 else Result := clGray; 172 end; 173 174 function TCell.GetAvialPower: Integer; 175 var 176 I: Integer; 177 begin 178 Result := Power; 179 for I := 0 to MovesFrom.Count - 1 do 180 Result := Result - TMove(MovesFrom[I]).CountOnce; 181 if Result < 0 then Result := 0; 168 182 end; 169 183 … … 249 263 for I := Moves.Count - 1 downto 0 do 250 264 if (TMove(Moves[I]).CellFrom.Player = Player) and 251 (TMove(Moves[I]).CountOnce = 0) and (TMove(Moves[I]).CountRepeat = 0) then 265 (TMove(Moves[I]).CountOnce = 0) and (TMove(Moves[I]).CountRepeat = 0) then begin 266 TMove(Moves[I]).CellFrom.MovesFrom.Remove(TMove(Moves[I])); 267 TMove(Moves[I]).CellTo.MovesTo.Remove(TMove(Moves[I])); 252 268 Moves.Delete(I); 269 end; 253 270 end; 254 271 … … 276 293 else begin 277 294 TMove(Moves[I]).CountOnce := CountOnce; 278 295 TMove(Moves[I]).CountOnce := CountOnce; 279 296 end; 280 297 end else begin … … 286 303 NewMove.CountOnce := CountOnce; 287 304 NewMove.CountRepeat := CountRepeat; 305 CellFrom.MovesFrom.Add(NewMove); 306 CellTo.MovesTo.Add(NewMove); 288 307 end; 289 308 end; … … 317 336 Map := THexMap.Create; 318 337 Map.Game := Self; 338 Map.Size := Point(20, 20); 319 339 Moves := TObjectList.Create; 320 340 end; … … 335 355 StartCell: TCell; 336 356 begin 337 Map.Size := Point(20, 20); 357 Moves.Clear; 358 Map.ClearCellMoves; 338 359 for Y := 0 to Map.Size.Y - 1 do 339 360 for X := 0 to Map.Size.X - 1 do … … 346 367 with TPlayer(Players[I]) do begin 347 368 SelectedCell := nil; 348 StartCell := Map.Cells[Random(Map.Size.Y), Random(Map.Size.X)]; 349 StartCell.Terrain := ttNormal; 350 StartCell.Player := TPlayer(Players[I]); 369 if (Map.Size.X > 0) and (Map.Size.Y > 0) then begin 370 StartCell := Map.Cells[Random(Map.Size.Y), Random(Map.Size.X)]; 371 StartCell.Terrain := ttNormal; 372 StartCell.Player := TPlayer(Players[I]); 373 end; 351 374 end; 352 375 CurrentPlayer := TPlayer(Players[0]); … … 379 402 for Y := 0 to FSize.Y - 1 do 380 403 for X := 0 to FSize.X - 1 do begin 381 Cells[Y, X].Destroy;404 TCell(Cells[Y, X]).Destroy; 382 405 end; 383 406 FSize := AValue; 384 407 // Allocate and init new 385 SetLength(Cells, FSize. X, FSize.Y);408 SetLength(Cells, FSize.Y, FSize.X); 386 409 for Y := 0 to FSize.Y - 1 do 387 410 for X := 0 to FSize.X - 1 do begin … … 499 522 Pen.Color := clBlack; 500 523 PaintHexagon(X * CellSize.X - Frac(Rect.Left / CellSize.X) * CellSize.X, 501 Y * CellSize.Y - Frac(Rect.Top / CellSize.Y) * CellSize.Y, IntToStr(Cell. Power));524 Y * CellSize.Y - Frac(Rect.Top / CellSize.Y) * CellSize.Y, IntToStr(Cell.GetAvialPower)); 502 525 // Draw arrows 503 526 Pen.Color := clCream; -
trunk/xtactics.lpi
r13 r15 56 56 <IsPartOfProject Value="True"/> 57 57 <ComponentName Value="FormNew"/> 58 <HasResources Value="True"/> 58 59 <ResourceBaseClass Value="Form"/> 59 60 <UnitName Value="UFormNew"/>
Note:
See TracChangeset
for help on using the changeset viewer.