Changeset 29


Ignore:
Timestamp:
Mar 3, 2014, 11:17:23 PM (11 years ago)
Author:
chronos
Message:
  • Added: Player customize dialog window.
  • Fixed: Rearm once set move count from predefined repeat move count.
Location:
trunk
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Languages/xtactics.cs.po

    r28 r29  
    8888msgstr ""
    8989
     90#: tformnew.buttonplayermodify.caption
     91msgid "Modify"
     92msgstr ""
     93
    9094#: tformnew.buttonplayerremove.caption
    9195msgid "Remove"
     
    124128msgstr ""
    125129
     130#: tformplayer.buttoncancel.caption
     131msgctxt "tformplayer.buttoncancel.caption"
     132msgid "Cancel"
     133msgstr ""
     134
     135#: tformplayer.buttonok.caption
     136msgctxt "tformplayer.buttonok.caption"
     137msgid "Ok"
     138msgstr ""
     139
     140#: tformplayer.caption
     141msgid "Player"
     142msgstr ""
     143
     144#: tformplayer.combobox1.text
     145msgid "Human"
     146msgstr ""
     147
     148#: tformplayer.label1.caption
     149msgid "Name:"
     150msgstr ""
     151
     152#: tformplayer.label2.caption
     153msgid "Mode:"
     154msgstr ""
     155
     156#: tformplayer.label3.caption
     157msgid "Color:"
     158msgstr ""
     159
    126160#: ucore.splayerwins
    127161msgctxt "ucore.splayerwins"
  • trunk/Languages/xtactics.po

    r28 r29  
    7979msgstr ""
    8080
     81#: tformnew.buttonplayermodify.caption
     82msgid "Modify"
     83msgstr ""
     84
    8185#: tformnew.buttonplayerremove.caption
    8286msgid "Remove"
     
    115119msgstr ""
    116120
     121#: tformplayer.buttoncancel.caption
     122msgctxt "TFORMPLAYER.BUTTONCANCEL.CAPTION"
     123msgid "Cancel"
     124msgstr ""
     125
     126#: tformplayer.buttonok.caption
     127msgctxt "TFORMPLAYER.BUTTONOK.CAPTION"
     128msgid "Ok"
     129msgstr ""
     130
     131#: tformplayer.caption
     132msgid "Player"
     133msgstr ""
     134
     135#: tformplayer.combobox1.text
     136msgid "Human"
     137msgstr ""
     138
     139#: tformplayer.label1.caption
     140msgid "Name:"
     141msgstr ""
     142
     143#: tformplayer.label2.caption
     144msgid "Mode:"
     145msgstr ""
     146
     147#: tformplayer.label3.caption
     148msgid "Color:"
     149msgstr ""
     150
    117151#: ucore.splayerwins
    118152msgctxt "ucore.splayerwins"
  • trunk/UCore.pas

    r28 r29  
    9898    Game.NextTurn;
    9999    FormMain.Redraw;
     100    Application.ProcessMessages;
    100101  end;
    101102end;
  • trunk/UFormNew.lfm

    r18 r29  
    119119    ParentColor = False
    120120  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
    121131end
  • trunk/UFormNew.lrt

    r28 r29  
    1111TFORMNEW.LABEL1.CAPTION=Map size:
    1212TFORMNEW.LABEL2.CAPTION=x
     13TFORMNEW.BUTTONPLAYERMODIFY.CAPTION=Modify
  • trunk/UFormNew.pas

    r28 r29  
    1818    ButtonOk: TButton;
    1919    ButtonPlayerRemove: TButton;
     20    ButtonPlayerModify: TButton;
    2021    CheckBoxVoid: TCheckBox;
    2122    Label1: TLabel;
     
    2526    SpinEditMapSizeY: TSpinEdit;
    2627    procedure ButtonPlayerAddClick(Sender: TObject);
     28    procedure ButtonPlayerModifyChangeBounds(Sender: TObject);
     29    procedure ButtonPlayerModifyClick(Sender: TObject);
    2730    procedure ButtonPlayerRemoveClick(Sender: TObject);
    2831    procedure FormCreate(Sender: TObject);
     
    4649
    4750{$R *.lfm}
     51
     52uses
     53  UFormPlayer;
    4854
    4955{ TFormNew }
     
    7379  ButtonPlayerRemove.Enabled := Assigned(ListView1.Selected);
    7480  ButtonPlayerAdd.Enabled := Players.Count < MaxPlayerCount;
     81  ButtonPlayerModify.Enabled := Assigned(ListView1.Selected);
    7582end;
    7683
     
    101108  Players.Add(NewPlayer);
    102109  ReloadView;
     110end;
     111
     112procedure TFormNew.ButtonPlayerModifyChangeBounds(Sender: TObject);
     113begin
     114
     115end;
     116
     117procedure TFormNew.ButtonPlayerModifyClick(Sender: TObject);
     118begin
     119  FormPlayer.Load(TPlayer(ListView1.Selected.Data));
     120  if FormPlayer.ShowModal = mrOk then
     121    FormPlayer.Save(TPlayer(ListView1.Selected.Data));
    103122end;
    104123
  • trunk/UGame.pas

    r28 r29  
    120120  end;
    121121
     122  TPlayerArray = array of TPlayer;
     123
    122124  TPlayers = class(TObjectList)
    123125
     
    143145    FRunning: Boolean;
    144146    procedure MoveAll(Player: TPlayer);
     147    procedure ClearMovesFromCell(Cell: TCell);
    145148    procedure SetMove(CellFrom, CellTo: TCell; Power: Integer);
    146149    procedure SetRunning(AValue: Boolean);
     150    procedure UpdateRepeatMoves(Player: TPlayer);
    147151  public
    148152    Players: TPlayers;
     
    154158
    155159    procedure ComputePlayerStats;
     160    function GetAlivePlayers: TPlayerArray;
    156161    procedure NextTurn;
    157162    constructor Create;
     
    333338begin
    334339  for Y := 0 to Game.Map.Size.Y - 1 do
    335   for X := 0 to Game.Map.Size.Y - 1 do
     340  for X := 0 to Game.Map.Size.X - 1 do
    336341  with TCell(Game.Map.Cells[Y, X]) do begin
    337342    if (Terrain <> ttVoid) and (Player <> Self) then begin
     
    344349      end;
    345350      // Attack if target is weaker
    346       if TotalPower > Power then begin
     351      if TotalPower >= Power then begin
    347352        TotalAttackPower := 0;
    348353        for I := 0 to Length(Cells) - 1 do
     
    434439          CellTo.Power := CountOnce - CellTo.Power;
    435440          CellTo.Player := Player;
     441          ClearMovesFromCell(CellTo);
    436442        end;
    437443      end;
     
    448454    Moves.Delete(I);
    449455  end;
     456end;
     457
     458procedure TGame.ClearMovesFromCell(Cell: TCell);
     459var
     460  I: Integer;
     461begin
     462  for I := Moves.Count - 1 to 0 do
     463  if TMove(Moves[I]).CellFrom = Cell then
     464    Moves.Delete(I);
    450465end;
    451466
     
    510525end;
    511526
     527procedure TGame.UpdateRepeatMoves(Player: TPlayer);
     528var
     529  I: Integer;
     530begin
     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;
     538end;
     539
    512540procedure TGame.ComputePlayerStats;
    513541var
     
    522550end;
    523551
     552function TGame.GetAlivePlayers: TPlayerArray;
     553var
     554  I: Integer;
     555begin
     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;
     562end;
     563
    524564procedure TGame.NextTurn;
    525565var
    526   AlivePlayers: TObjectList;
    527   I: Integer;
    528566  PrevPlayer: TPlayer;
     567  AlivePlayers: TPlayerArray;
    529568begin
    530569  MoveAll(CurrentPlayer);
     
    537576  until CurrentPlayer.TotalCells > 0;
    538577  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);
    551584end;
    552585
     
    574607  Map := THexMap.Create;
    575608  Map.Game := Self;
    576   Map.Size := Point(20, 20);
     609  Map.Size := Point(20, 16);
    577610  Moves := TObjectList.Create;
    578611end;
     
    758791      Pen.Color := clYellow;
    759792      Pen.Style := psSolid;
     793      Pen.Width := 1;
    760794    end else begin
    761795      Pen.Color := clBlack;
     
    764798      Pen.Color := Brush.Color;
    765799      Pen.Style := psSolid;
     800      Pen.Width := 0;
    766801    end;
    767802    Points := GetHexagonPolygon(Point(Trunc(Pos.X), Trunc(Pos.Y)), Point(Trunc(HexSize.X), Trunc(HexSize.Y)));
     
    812847            PosFrom := CellToPos(Cell, View);
    813848            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;
    814851            Line(View.CellToCanvasPos(Point(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 4),
    815852              Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 4))),
    816853              View.CellToCanvasPos(Point(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 2),
    817854              Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 2))));
     855            Pen.Width := 1;
    818856          end;
    819857        end;
  • trunk/xtactics.lpi

    r22 r29  
    7777      </Item1>
    7878    </RequiredPackages>
    79     <Units Count="6">
     79    <Units Count="7">
    8080      <Unit0>
    8181        <Filename Value="xtactics.lpr"/>
     
    120120        <UnitName Value="UCore"/>
    121121      </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>
    122129    </Units>
    123130  </ProjectOptions>
     
    129136    <SearchPaths>
    130137      <IncludeFiles Value="$(ProjOutDir)"/>
     138      <OtherUnitFiles Value="Forms"/>
    131139      <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
    132140    </SearchPaths>
  • trunk/xtactics.lpr

    r22 r29  
    88  {$ENDIF}{$ENDIF}
    99  Interfaces, // this includes the LCL widgetset
    10   Forms, UFormMain, UGame, UFormNew, UFormMove, UCore
     10  Forms, UFormMain, UGame, UFormNew, UFormMove, UCore, UFormPlayer
    1111  { you can add units after this };
    1212
     
    2020  Application.CreateForm(TFormNew, FormNew);
    2121  Application.CreateForm(TFormMove, FormMove);
     22  Application.CreateForm(TFormPlayer, FormPlayer);
    2223  Application.Run;
    2324end.
Note: See TracChangeset for help on using the changeset viewer.