- Timestamp:
- Mar 3, 2014, 11:17:23 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Languages/xtactics.cs.po
r28 r29 88 88 msgstr "" 89 89 90 #: tformnew.buttonplayermodify.caption 91 msgid "Modify" 92 msgstr "" 93 90 94 #: tformnew.buttonplayerremove.caption 91 95 msgid "Remove" … … 124 128 msgstr "" 125 129 130 #: tformplayer.buttoncancel.caption 131 msgctxt "tformplayer.buttoncancel.caption" 132 msgid "Cancel" 133 msgstr "" 134 135 #: tformplayer.buttonok.caption 136 msgctxt "tformplayer.buttonok.caption" 137 msgid "Ok" 138 msgstr "" 139 140 #: tformplayer.caption 141 msgid "Player" 142 msgstr "" 143 144 #: tformplayer.combobox1.text 145 msgid "Human" 146 msgstr "" 147 148 #: tformplayer.label1.caption 149 msgid "Name:" 150 msgstr "" 151 152 #: tformplayer.label2.caption 153 msgid "Mode:" 154 msgstr "" 155 156 #: tformplayer.label3.caption 157 msgid "Color:" 158 msgstr "" 159 126 160 #: ucore.splayerwins 127 161 msgctxt "ucore.splayerwins" -
trunk/Languages/xtactics.po
r28 r29 79 79 msgstr "" 80 80 81 #: tformnew.buttonplayermodify.caption 82 msgid "Modify" 83 msgstr "" 84 81 85 #: tformnew.buttonplayerremove.caption 82 86 msgid "Remove" … … 115 119 msgstr "" 116 120 121 #: tformplayer.buttoncancel.caption 122 msgctxt "TFORMPLAYER.BUTTONCANCEL.CAPTION" 123 msgid "Cancel" 124 msgstr "" 125 126 #: tformplayer.buttonok.caption 127 msgctxt "TFORMPLAYER.BUTTONOK.CAPTION" 128 msgid "Ok" 129 msgstr "" 130 131 #: tformplayer.caption 132 msgid "Player" 133 msgstr "" 134 135 #: tformplayer.combobox1.text 136 msgid "Human" 137 msgstr "" 138 139 #: tformplayer.label1.caption 140 msgid "Name:" 141 msgstr "" 142 143 #: tformplayer.label2.caption 144 msgid "Mode:" 145 msgstr "" 146 147 #: tformplayer.label3.caption 148 msgid "Color:" 149 msgstr "" 150 117 151 #: ucore.splayerwins 118 152 msgctxt "ucore.splayerwins" -
trunk/UCore.pas
r28 r29 98 98 Game.NextTurn; 99 99 FormMain.Redraw; 100 Application.ProcessMessages; 100 101 end; 101 102 end; -
trunk/UFormNew.lfm
r18 r29 119 119 ParentColor = False 120 120 end 121 object ButtonPlayerModify: TButton 122 Left = 616 123 Height = 25 124 Top = 72 125 Width = 83 126 Caption = 'Modify' 127 OnChangeBounds = ButtonPlayerModifyChangeBounds 128 OnClick = ButtonPlayerModifyClick 129 TabOrder = 8 130 end 121 131 end -
trunk/UFormNew.lrt
r28 r29 11 11 TFORMNEW.LABEL1.CAPTION=Map size: 12 12 TFORMNEW.LABEL2.CAPTION=x 13 TFORMNEW.BUTTONPLAYERMODIFY.CAPTION=Modify -
trunk/UFormNew.pas
r28 r29 18 18 ButtonOk: TButton; 19 19 ButtonPlayerRemove: TButton; 20 ButtonPlayerModify: TButton; 20 21 CheckBoxVoid: TCheckBox; 21 22 Label1: TLabel; … … 25 26 SpinEditMapSizeY: TSpinEdit; 26 27 procedure ButtonPlayerAddClick(Sender: TObject); 28 procedure ButtonPlayerModifyChangeBounds(Sender: TObject); 29 procedure ButtonPlayerModifyClick(Sender: TObject); 27 30 procedure ButtonPlayerRemoveClick(Sender: TObject); 28 31 procedure FormCreate(Sender: TObject); … … 46 49 47 50 {$R *.lfm} 51 52 uses 53 UFormPlayer; 48 54 49 55 { TFormNew } … … 73 79 ButtonPlayerRemove.Enabled := Assigned(ListView1.Selected); 74 80 ButtonPlayerAdd.Enabled := Players.Count < MaxPlayerCount; 81 ButtonPlayerModify.Enabled := Assigned(ListView1.Selected); 75 82 end; 76 83 … … 101 108 Players.Add(NewPlayer); 102 109 ReloadView; 110 end; 111 112 procedure TFormNew.ButtonPlayerModifyChangeBounds(Sender: TObject); 113 begin 114 115 end; 116 117 procedure TFormNew.ButtonPlayerModifyClick(Sender: TObject); 118 begin 119 FormPlayer.Load(TPlayer(ListView1.Selected.Data)); 120 if FormPlayer.ShowModal = mrOk then 121 FormPlayer.Save(TPlayer(ListView1.Selected.Data)); 103 122 end; 104 123 -
trunk/UGame.pas
r28 r29 120 120 end; 121 121 122 TPlayerArray = array of TPlayer; 123 122 124 TPlayers = class(TObjectList) 123 125 … … 143 145 FRunning: Boolean; 144 146 procedure MoveAll(Player: TPlayer); 147 procedure ClearMovesFromCell(Cell: TCell); 145 148 procedure SetMove(CellFrom, CellTo: TCell; Power: Integer); 146 149 procedure SetRunning(AValue: Boolean); 150 procedure UpdateRepeatMoves(Player: TPlayer); 147 151 public 148 152 Players: TPlayers; … … 154 158 155 159 procedure ComputePlayerStats; 160 function GetAlivePlayers: TPlayerArray; 156 161 procedure NextTurn; 157 162 constructor Create; … … 333 338 begin 334 339 for Y := 0 to Game.Map.Size.Y - 1 do 335 for X := 0 to Game.Map.Size. Y- 1 do340 for X := 0 to Game.Map.Size.X - 1 do 336 341 with TCell(Game.Map.Cells[Y, X]) do begin 337 342 if (Terrain <> ttVoid) and (Player <> Self) then begin … … 344 349 end; 345 350 // Attack if target is weaker 346 if TotalPower > Power then begin351 if TotalPower >= Power then begin 347 352 TotalAttackPower := 0; 348 353 for I := 0 to Length(Cells) - 1 do … … 434 439 CellTo.Power := CountOnce - CellTo.Power; 435 440 CellTo.Player := Player; 441 ClearMovesFromCell(CellTo); 436 442 end; 437 443 end; … … 448 454 Moves.Delete(I); 449 455 end; 456 end; 457 458 procedure TGame.ClearMovesFromCell(Cell: TCell); 459 var 460 I: Integer; 461 begin 462 for I := Moves.Count - 1 to 0 do 463 if TMove(Moves[I]).CellFrom = Cell then 464 Moves.Delete(I); 450 465 end; 451 466 … … 510 525 end; 511 526 527 procedure TGame.UpdateRepeatMoves(Player: TPlayer); 528 var 529 I: Integer; 530 begin 531 for I := 0 to Moves.Count - 1 do 532 with TMove(Moves[I]) do begin 533 if CellFrom.Player = Player then 534 if CountRepeat <= CellFrom.GetAvialPower then 535 CountOnce := CountRepeat 536 else CountOnce := CellFrom.GetAvialPower; 537 end; 538 end; 539 512 540 procedure TGame.ComputePlayerStats; 513 541 var … … 522 550 end; 523 551 552 function TGame.GetAlivePlayers: TPlayerArray; 553 var 554 I: Integer; 555 begin 556 SetLength(Result, 0); 557 for I := 0 to Players.Count - 1 do 558 if TPlayer(Players[I]).TotalCells > 0 then begin 559 SetLength(Result, Length(Result) + 1); 560 Result[Length(Result) - 1] := TPlayer(Players[I]); 561 end; 562 end; 563 524 564 procedure TGame.NextTurn; 525 565 var 526 AlivePlayers: TObjectList;527 I: Integer;528 566 PrevPlayer: TPlayer; 567 AlivePlayers: TPlayerArray; 529 568 begin 530 569 MoveAll(CurrentPlayer); … … 537 576 until CurrentPlayer.TotalCells > 0; 538 577 if Players.IndexOf(CurrentPlayer) < Players.IndexOf(PrevPlayer) then Inc(TurnCounter); 539 try 540 AlivePlayers := TObjectList.Create; 541 AlivePlayers.OwnsObjects := False; 542 for I := 0 to Players.Count - 1 do 543 if TPlayer(Players[I]).TotalCells > 0 then AlivePlayers.Add(TPlayer(Players[I])); 544 if AlivePlayers.Count <= 1 then begin 545 Running := False; 546 if (AlivePlayers.Count = 1) and Assigned(OnWin) then OnWin(TPlayer(AlivePlayers.First)); 547 end; 548 finally 549 AlivePlayers.Free; 550 end; 578 AlivePlayers := GetAlivePlayers; 579 if (Length(AlivePlayers) <= 1) then begin 580 Running := False; 581 if Assigned(OnWin) and (Length(AlivePlayers) > 0) then OnWin(TPlayer(AlivePlayers[0])); 582 end; 583 UpdateRepeatMoves(CurrentPlayer); 551 584 end; 552 585 … … 574 607 Map := THexMap.Create; 575 608 Map.Game := Self; 576 Map.Size := Point(20, 20);609 Map.Size := Point(20, 16); 577 610 Moves := TObjectList.Create; 578 611 end; … … 758 791 Pen.Color := clYellow; 759 792 Pen.Style := psSolid; 793 Pen.Width := 1; 760 794 end else begin 761 795 Pen.Color := clBlack; … … 764 798 Pen.Color := Brush.Color; 765 799 Pen.Style := psSolid; 800 Pen.Width := 0; 766 801 end; 767 802 Points := GetHexagonPolygon(Point(Trunc(Pos.X), Trunc(Pos.Y)), Point(Trunc(HexSize.X), Trunc(HexSize.Y))); … … 812 847 PosFrom := CellToPos(Cell, View); 813 848 PosTo := CellToPos(TMove(Cell.MovesFrom[I]).CellTo, View); 849 if TMove(Cell.MovesFrom[I]).CountRepeat > 0 then Pen.Width := 2 850 else Pen.Width := 1; 814 851 Line(View.CellToCanvasPos(Point(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 4), 815 852 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 4))), 816 853 View.CellToCanvasPos(Point(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 2), 817 854 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 2)))); 855 Pen.Width := 1; 818 856 end; 819 857 end; -
trunk/xtactics.lpi
r22 r29 77 77 </Item1> 78 78 </RequiredPackages> 79 <Units Count=" 6">79 <Units Count="7"> 80 80 <Unit0> 81 81 <Filename Value="xtactics.lpr"/> … … 120 120 <UnitName Value="UCore"/> 121 121 </Unit5> 122 <Unit6> 123 <Filename Value="Forms/UFormPlayer.pas"/> 124 <IsPartOfProject Value="True"/> 125 <ComponentName Value="FormPlayer"/> 126 <ResourceBaseClass Value="Form"/> 127 <UnitName Value="UFormPlayer"/> 128 </Unit6> 122 129 </Units> 123 130 </ProjectOptions> … … 129 136 <SearchPaths> 130 137 <IncludeFiles Value="$(ProjOutDir)"/> 138 <OtherUnitFiles Value="Forms"/> 131 139 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> 132 140 </SearchPaths> -
trunk/xtactics.lpr
r22 r29 8 8 {$ENDIF}{$ENDIF} 9 9 Interfaces, // this includes the LCL widgetset 10 Forms, UFormMain, UGame, UFormNew, UFormMove, UCore 10 Forms, UFormMain, UGame, UFormNew, UFormMove, UCore, UFormPlayer 11 11 { you can add units after this }; 12 12 … … 20 20 Application.CreateForm(TFormNew, FormNew); 21 21 Application.CreateForm(TFormMove, FormMove); 22 Application.CreateForm(TFormPlayer, FormPlayer); 22 23 Application.Run; 23 24 end.
Note:
See TracChangeset
for help on using the changeset viewer.