Changeset 30


Ignore:
Timestamp:
Mar 4, 2014, 12:18:22 AM (10 years ago)
Author:
chronos
Message:
Location:
trunk
Files:
7 edited

Legend:

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

    r29 r30  
    5555msgctxt "tformmove.buttoncancel.caption"
    5656msgid "Cancel"
    57 msgstr ""
     57msgstr "Zrušit"
    5858
    5959#: tformmove.buttonok.caption
    6060msgctxt "tformmove.buttonok.caption"
    6161msgid "Ok"
    62 msgstr ""
     62msgstr "Ok"
    6363
    6464#: tformmove.caption
    6565msgid "Move"
    66 msgstr ""
     66msgstr "Přesun"
    6767
    6868#: tformmove.label1.caption
    6969msgid "Once:"
    70 msgstr ""
     70msgstr "Jednou:"
    7171
    7272#: tformmove.label2.caption
    7373msgid "Every turn:"
    74 msgstr ""
     74msgstr "Každý tah:"
    7575
    7676#: tformnew.buttoncancel.caption
    7777msgctxt "tformnew.buttoncancel.caption"
    7878msgid "Cancel"
    79 msgstr ""
     79msgstr "Zrušit"
    8080
    8181#: tformnew.buttonok.caption
    8282msgctxt "tformnew.buttonok.caption"
    8383msgid "Ok"
    84 msgstr ""
     84msgstr "Ok"
    8585
    8686#: tformnew.buttonplayeradd.caption
    8787msgid "Add"
    88 msgstr ""
     88msgstr "Přidat"
    8989
    9090#: tformnew.buttonplayermodify.caption
    9191msgid "Modify"
    92 msgstr ""
     92msgstr "Upravit"
    9393
    9494#: tformnew.buttonplayerremove.caption
    9595msgid "Remove"
    96 msgstr ""
     96msgstr "Odebrat"
    9797
    9898#: tformnew.caption
    9999msgid "New game"
    100 msgstr ""
     100msgstr "Nová hra"
    101101
    102102#: tformnew.checkboxvoid.caption
    103103msgid "Inaccessible places"
    104 msgstr ""
     104msgstr "Nepřístupná políčka"
    105105
    106106#: tformnew.label1.caption
    107107msgid "Map size:"
    108 msgstr ""
     108msgstr "Velikost mapy:"
    109109
    110110#: tformnew.label2.caption
    111111msgid "x"
    112 msgstr ""
     112msgstr "x"
    113113
    114114#: tformnew.listview1.columns[0].caption
    115115msgid "Name"
    116 msgstr ""
     116msgstr "Jméno"
    117117
    118118#: tformnew.listview1.columns[1].caption
    119119msgid "Type"
    120 msgstr ""
     120msgstr "Typ"
    121121
    122122#: tformnew.listview1.columns[2].caption
    123123msgid "Color"
    124 msgstr ""
     124msgstr "Barva"
    125125
    126126#: tformnew.listview1.columns[3].caption
    127127msgid "Start units"
    128 msgstr ""
     128msgstr "Počátečních jednotek"
    129129
    130130#: tformplayer.buttoncancel.caption
    131131msgctxt "tformplayer.buttoncancel.caption"
    132132msgid "Cancel"
    133 msgstr ""
     133msgstr "Zrušit"
    134134
    135135#: tformplayer.buttonok.caption
    136136msgctxt "tformplayer.buttonok.caption"
    137137msgid "Ok"
    138 msgstr ""
     138msgstr "Ok"
    139139
    140140#: tformplayer.caption
    141141msgid "Player"
    142 msgstr ""
     142msgstr "Hráč"
    143143
    144144#: tformplayer.combobox1.text
    145145msgid "Human"
    146 msgstr ""
     146msgstr "Člověk"
    147147
    148148#: tformplayer.label1.caption
    149149msgid "Name:"
    150 msgstr ""
     150msgstr "Jméno:"
    151151
    152152#: tformplayer.label2.caption
    153153msgid "Mode:"
    154 msgstr ""
     154msgstr "Režim:"
    155155
    156156#: tformplayer.label3.caption
    157157msgid "Color:"
    158 msgstr ""
     158msgstr "Barva:"
    159159
    160160#: ucore.splayerwins
     
    165165#: uformmain.sturn
    166166msgid "turn"
    167 msgstr ""
     167msgstr "tah"
    168168
    169169#: ugame.sminimumplayers
    170170msgid "You need at least two players"
    171171msgstr "Potřebujete alespoň dva hráče"
    172 
  • trunk/UCore.lfm

    r28 r30  
    44  OldCreateOrder = False
    55  Height = 542
    6   HorizontalOffset = 485
    7   VerticalOffset = 284
     6  HorizontalOffset = 738
     7  VerticalOffset = 183
    88  Width = 752
    99  object ActionList1: TActionList
  • trunk/UCore.pas

    r29 r30  
    3434  public
    3535    Game: TGame;
     36    UseSingleView: Boolean;
     37    View: TView;
    3638    procedure Init;
    3739    property Initialized: Boolean read FInitialized;
     
    8082procedure TCore.AExitExecute(Sender: TObject);
    8183begin
     84  Game.Running := False;
    8285  Application.Terminate;
    8386end;
     
    99102    FormMain.Redraw;
    100103    Application.ProcessMessages;
     104    Sleep(1);
    101105  end;
    102106end;
  • trunk/UFormMain.lfm

    r28 r30  
    99  Menu = MainMenu1
    1010  OnActivate = FormActivate
     11  OnClose = FormClose
    1112  OnCreate = FormCreate
    1213  OnDestroy = FormDestroy
  • trunk/UFormMain.pas

    r28 r30  
    3434    ToolButton4: TToolButton;
    3535    procedure FormActivate(Sender: TObject);
     36    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    3637    procedure FormCreate(Sender: TObject);
    3738    procedure FormDestroy(Sender: TObject);
     
    132133end;
    133134
     135procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
     136begin
     137  Core.Game.Running := False;
     138end;
     139
    134140procedure TFormMain.FormDestroy(Sender: TObject);
    135141begin
     
    176182    end;
    177183    Cell := nil;
    178     OldCell := Core.Game.CurrentPlayer.FocusedCell;
     184    OldCell := Core.Game.CurrentPlayer.View.FocusedCell;
    179185    with Core.Game do
    180186      Cell := Map.PosToCell(CurrentPlayer.View.CanvasToCellPos(Point(X, Y)), CurrentPlayer.View );
    181187    if Assigned(Cell) then begin
    182       Core.Game.CurrentPlayer.FocusedCell := Cell;
     188      Core.Game.CurrentPlayer.View.FocusedCell := Cell;
    183189      StatusBar1.Panels[0].Text := '[' + IntToStr(Cell.Pos.X) + ', ' + IntToStr(Cell.Pos.Y) + ']';
    184190    end else begin
    185       Core.Game.CurrentPlayer.FocusedCell := nil;
     191      Core.Game.CurrentPlayer.View.FocusedCell := nil;
    186192      StatusBar1.Panels[0].Text := '';
    187193    end;
     
    195201  if (Abs(StartMousePoint.X - X) < 5) and (Abs(StartMousePoint.Y - Y) < 5) then begin
    196202    if Core.Game.Running and (Core.Game.CurrentPlayer.Mode = pmHuman) then begin
    197       Core.Game.CurrentPlayer.SelectCell(Point(X, Y));
     203      Core.Game.CurrentPlayer.View.SelectCell(Point(X, Y), Core.Game.CurrentPlayer);
    198204      Redraw;
    199205    end;
  • trunk/UFormNew.pas

    r29 r30  
    106106  NewPlayer.Name := 'Player ' + IntToStr(Players.Count + 1);
    107107  NewPlayer.Color := PlayerColors[Players.Count];
     108  NewPlayer.Mode := pmComputer;
    108109  Players.Add(NewPlayer);
    109110  ReloadView;
  • trunk/UGame.pas

    r29 r30  
    5858    procedure SetZoom(AValue: Double);
    5959  public
     60    Game: TGame;
    6061    SourceRect: TRect;
     62    FocusedCell: TCell;
     63    SelectedCell: TCell;
     64    procedure Clear;
    6165    constructor Create;
    6266    destructor Destroy; override;
     67    procedure SelectCell(Pos: TPoint; Player: TPlayer);
    6368    function CanvasToCellPos(Pos: TPoint): TPoint;
    6469    function CellToCanvasPos(Pos: TPoint): TPoint;
     
    8691    function CellToPos(Cell: TCell; View: TView): TPoint;
    8792    function GetHexagonPolygon(Pos: TPoint; HexSize: TPoint): TPointArray;
    88     procedure Paint(Canvas: TCanvas; View: TView; SelectedCell: TCell; FocusedCell: TCell);
     93    procedure Paint(Canvas: TCanvas; View: TView);
    8994    constructor Create;
    9095    destructor Destroy; override;
     
    102107
    103108  TPlayer = class
    104     Game: TGame;
     109  private
     110    FGame: TGame;
     111    procedure SetGame(AValue: TGame);
     112  public
    105113    Name: string;
    106114    Color: TColor;
    107115    View: TView;
    108     SelectedCell: TCell;
    109     FocusedCell: TCell;
    110116    Mode: TPlayerMode;
    111117    TotalUnits: Integer;
     
    113119    StartUnits: Integer;
    114120    procedure ComputerTurn;
    115     procedure SelectCell(Pos: TPoint);
    116121    procedure Paint(PaintBox: TPaintBox);
    117122    constructor Create;
    118123    destructor Destroy; override;
    119124    procedure Assign(Source: TPlayer);
     125    property Game: TGame read FGame write SetGame;
    120126  end;
    121127
     
    243249end;
    244250
     251procedure TView.Clear;
     252begin
     253  FocusedCell := nil;
     254  SelectedCell := nil;
     255end;
     256
    245257procedure TView.SetDestRect(AValue: TRect);
    246258begin
     
    254266constructor TView.Create;
    255267begin
    256   Zoom := 1;
     268  Zoom := 1.5;
     269  Clear;
    257270end;
    258271
     
    326339  DestRect := Source.DestRect;
    327340  Zoom := Source.Zoom;
     341  SelectedCell := Source.SelectedCell;
     342  FocusedCell := Source.FocusedCell;
     343end;
     344
     345procedure TPlayer.SetGame(AValue: TGame);
     346begin
     347  if FGame = AValue then Exit;
     348  FGame := AValue;
     349  View.Game := Game;
    328350end;
    329351
     
    336358  TotalAttackPower: Integer;
    337359  I: Integer;
     360  CanAttack: Integer;
    338361begin
    339362  for Y := 0 to Game.Map.Size.Y - 1 do
     
    341364  with TCell(Game.Map.Cells[Y, X]) do begin
    342365    if (Terrain <> ttVoid) and (Player <> Self) then begin
     366      // Attack to not owned cell yet
    343367      // Count own possible power
    344368      Cells := Game.Map.GetCellNeighbours(Game.Map.Cells[Y, X]);
     
    361385        end;
    362386      end;
    363     end;
    364   end;
    365 end;
    366 
    367 procedure TPlayer.SelectCell(Pos: TPoint);
     387    end else
     388    if (Terrain <> ttVoid) and (Player = Self) then begin
     389      // Inner moves
     390      // We need to move available power to borders to be available for attacks
     391      // or defense
     392      Cells := Game.Map.GetCellNeighbours(Game.Map.Cells[Y, X]);
     393      CanAttack := 0;
     394      for I := 0 to Length(Cells) - 1 do
     395      if (Cells[I].Player <> Self) then begin
     396        Inc(CanAttack);
     397      end;
     398      if CanAttack = 0 then begin
     399        // We cannot attack and should do move
     400        // For simplicty just try to balance inner area cells power
     401        for I := 0 to Length(Cells) - 1 do
     402        if (Cells[I].Player = Self) and (Cells[I].Power < Game.Map.Cells[Y, X].GetAvialPower) then begin
     403          Game.SetMove(Game.Map.Cells[Y, X], Cells[I], (Game.Map.Cells[Y, X].GetAvialPower - Cells[I].Power) div 2);
     404        end;
     405      end;
     406    end;
     407  end;
     408end;
     409
     410procedure TView.SelectCell(Pos: TPoint; Player: TPlayer);
    368411var
    369412  NewSelectedCell: TCell;
     
    371414  BottomRight: TPoint;
    372415begin
    373   NewSelectedCell := Game.Map.PosToCell(View.CanvasToCellPos(Pos), View);
     416  NewSelectedCell := Game.Map.PosToCell(CanvasToCellPos(Pos), Self);
    374417  if Assigned(NewSelectedCell) then begin
    375418    if Assigned(SelectedCell) and IsCellsNeighbor(NewSelectedCell, SelectedCell) then begin
     
    377420      SelectedCell := nil;
    378421    end else
    379     if (NewSelectedCell <> SelectedCell) and (NewSelectedCell.Player = Self) then
     422    if (NewSelectedCell <> SelectedCell) and (NewSelectedCell.Player = Player) then
    380423      SelectedCell := NewSelectedCell
    381424    else
    382     if (NewSelectedCell = SelectedCell) and (NewSelectedCell.Player = Self) then
     425    if (NewSelectedCell = SelectedCell) and (NewSelectedCell.Player = Player) then
    383426      SelectedCell := nil;
    384427  end;
     
    387430procedure TPlayer.Paint(PaintBox: TPaintBox);
    388431begin
    389   Game.Map.Paint(PaintBox.Canvas, View, SelectedCell, FocusedCell);
     432  Game.Map.Paint(PaintBox.Canvas, View);
    390433end;
    391434
     
    393436begin
    394437  View := TView.Create;
    395   SelectedCell := nil;
    396   FocusedCell := nil;
    397438  StartUnits := DefaultPlayerStartUnits;
    398439end;
     
    413454  TotalUnits := Source.TotalUnits;
    414455  StartUnits := Source.StartUnits;
    415   SelectedCell := Source.SelectedCell;
    416   FocusedCell := Source.FocusedCell;
    417456  View.Assign(Source.View);
    418457end;
     
    432471      end else begin
    433472        // Fight
     473        //NewPower := CellTo.Power - Trunc(CountOnce / CellTo.Power);
    434474        if CellTo.Power > CountOnce then begin
    435475          // Defender wins
     
    519559    for I := 0 to Players.Count - 1 do
    520560    with TPlayer(Players[I]) do begin
    521       SelectedCell := nil;
    522       FocusedCell := nil;
     561      View.Clear;
    523562    end;
    524563  end;
     
    582621  end;
    583622  UpdateRepeatMoves(CurrentPlayer);
     623  // For computers take view from previous human
     624  if CurrentPlayer.Mode = pmComputer then CurrentPlayer.View.Assign(PrevPlayer.View);
    584625end;
    585626
     
    639680  for I := 0 to Players.Count - 1 do
    640681  with TPlayer(Players[I]) do begin
    641     SelectedCell := nil;
     682    View.Clear;
    642683    if (Map.Size.X > 0) and (Map.Size.Y > 0) then begin
    643684      StartCell := Map.Cells[Random(Map.Size.Y), Random(Map.Size.X)];
     
    771812end;
    772813
    773 procedure THexMap.Paint(Canvas: TCanvas; View: TView; SelectedCell: TCell; FocusedCell: TCell);
     814procedure THexMap.Paint(Canvas: TCanvas; View: TView);
    774815var
    775816  CX, CY: Integer;
     
    788829begin
    789830  with Canvas do begin
    790     if Assigned(FocusedCell) and (FocusedCell = TCell(Cells[CY, CX])) then begin
     831    if Assigned(View.FocusedCell) and (View.FocusedCell = TCell(Cells[CY, CX])) then begin
    791832      Pen.Color := clYellow;
    792833      Pen.Style := psSolid;
Note: See TracChangeset for help on using the changeset viewer.