Changeset 148 for trunk/UCore.pas


Ignore:
Timestamp:
Nov 12, 2017, 11:06:20 PM (7 years ago)
Author:
chronos
Message:
  • Modified: Unit moves moved from TGame to TPlayer. Moves belong to player rather then to game so one player can't see and change moves of other players.
  • Added: New Unit moves window available from Tools menu.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r145 r148  
    1616  TCore = class(TDataModule)
    1717    AAbout: TAction;
     18    AShowUnitMoves: TAction;
    1819    AShowCharts: TAction;
    1920    AHelp: TAction;
     
    4849    procedure ASettingsExecute(Sender: TObject);
    4950    procedure AShowChartsExecute(Sender: TObject);
     51    procedure AShowUnitMovesExecute(Sender: TObject);
    5052    procedure CoolTranslator1Translate(Sender: TObject);
    5153    procedure DataModuleCreate(Sender: TObject);
     
    6062    procedure StartNewGame;
    6163    procedure DoPlayerChange(Sender: TObject);
     64    procedure DoMoveUpdated(UnitMove: TUnitMove);
    6265    procedure DoOnMove(CellFrom, CellTo: TCell; var CountOnce,
    6366      CountRepeat: Integer; Update: Boolean; var Confirm: Boolean);
     
    9598uses
    9699  UFormMove, UFormMain, UFormNew, UFormSettings, UFormAbout, UFormPlayer,
    97   UFormHelp, UFormCharts;
     100  UFormHelp, UFormCharts, UFormUnitMoves;
    98101
    99102const
     
    278281
    279282procedure TCore.ProcessComputerTurns;
    280 var
    281   Computer: TComputer;
    282283begin
    283284  while Game.Running and (Game.CurrentPlayer.Mode <> pmHuman) do begin
    284285    if Game.CurrentPlayer.Mode = pmComputer then begin
    285       Computer := TComputer.Create;
    286       try
    287         Computer.Game := Game;
    288         Computer.Process;
    289       finally
    290         Computer.Free;
    291       end;
     286      Game.CurrentPlayer.Computer.Process;
    292287      FormMain.Redraw;
    293288      Delay(Trunc((100 - AnimationSpeed) / 100 * 2000));
     
    374369end;
    375370
     371procedure TCore.AShowUnitMovesExecute(Sender: TObject);
     372begin
     373  FormUnitMoves.Show;
     374end;
     375
    376376procedure TCore.CoolTranslator1Translate(Sender: TObject);
    377377begin
     
    385385  Game := TGame.Create;
    386386  Game.OnMove := DoOnMove;
     387  Game.OnMoveUpdated := DoMoveUpdated;
    387388  Game.OnWin := DoOnWin;
    388389  Game.OnNewTurn := GameNewTurnExecute;
     
    421422  FormMain.Redraw;
    422423  if FormCharts.Visible then FormCharts.Redraw;
     424  if FormUnitMoves.Visible then FormUnitMoves.ReloadList;
    423425end;
    424426
     
    430432  FormMain.Redraw;
    431433  if FormCharts.Visible then FormCharts.Redraw;
     434  if FormUnitMoves.Visible then FormUnitMoves.ReloadList;
    432435  ProcessComputerTurns;
    433436  UpdateActions;
     
    439442    CurrentClient := Game.CurrentPlayer.Client;
    440443  if FormCharts.Visible then FormCharts.Redraw;
     444  if FormUnitMoves.Visible then FormUnitMoves.ReloadList;
     445end;
     446
     447procedure TCore.DoMoveUpdated(UnitMove: TUnitMove);
     448begin
     449  if FormUnitMoves.Visible then FormUnitMoves.ReloadList;
    441450end;
    442451
Note: See TracChangeset for help on using the changeset viewer.