Changeset 183 for trunk/UGame.pas


Ignore:
Timestamp:
Feb 9, 2018, 10:33:18 AM (7 years ago)
Author:
chronos
Message:
  • Modified: Units move handling was moved from Core to FormClient as it is game client related functionality.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UGame.pas

    r180 r183  
    415415  end;
    416416
     417  TMoveEvent = procedure(CellFrom, CellTo: TCell; var CountOnce, CountRepeat: Integer;
     418    Update: Boolean; var Confirm: Boolean) of object;
     419
    417420  { TClient }
    418421
    419422  TClient = class
    420423  private
     424    FForm: TForm;
    421425    FGame: TGame;
    422426    FControlPlayer: TPlayer;
    423427    FOnChange: TNotifyEvent;
    424428    FOnReceive: TReceiveEvent;
     429    FOnMove: TMoveEvent;
    425430    procedure SetControlPlayer(AValue: TPlayer);
     431    procedure SetForm(AValue: TForm);
    426432    procedure SetGame(AValue: TGame);
    427433    procedure DoChange;
    428434  public
    429     Form: TForm;
    430435    Name: string;
    431436    View: TView;
     
    436441    property ControlPlayer: TPlayer read FControlPlayer write SetControlPlayer;
    437442    property Game: TGame read FGame write SetGame;
     443    property Form: TForm read FForm write SetForm;
     444    property OnMove: TMoveEvent read FOnMove write FOnMove;
    438445    property OnReceive: TReceiveEvent read FOnReceive write FOnReceive;
    439446    property OnChange: TNotifyEvent read FOnChange write FOnChange;
     
    450457  { TGame }
    451458
    452   TMoveEvent = procedure(CellFrom, CellTo: TCell; var CountOnce, CountRepeat: Integer;
    453     Update: Boolean; var Confirm: Boolean) of object;
    454459  TMoveUpdatedEvent = procedure(UnitMove: TUnitMove) of object;
    455460
     
    464469  private
    465470    FMapType: TMapType;
    466     FOnMove: TMoveEvent;
    467471    FOnMoveUpdated: TMoveUpdatedEvent;
    468472    FOnNewTurn: TNotifyEvent;
     
    519523    property MapType: TMapType read FMapType write SetMapType;
    520524  published
    521     property OnMove: TMoveEvent read FOnMove write FOnMove;
    522525    property OnMoveUpdated: TMoveUpdatedEvent read FOnMoveUpdated write FOnMoveUpdated;
    523526    property OnWin: TWinEvent read FOnWin write FOnWin;
     
    697700  if Assigned(FControlPlayer) then
    698701     FControlPlayer.FClient := Self;
     702end;
     703
     704procedure TClient.SetForm(AValue: TForm);
     705begin
     706  if FForm = AValue then Exit;
     707  FForm := AValue;
    699708end;
    700709
     
    29212930    CountRepeat := Result.CountRepeat;
    29222931    if (Mode = pmHuman) and Confirmation and
    2923       Assigned(Game.FOnMove) then Game.FOnMove(CellFrom, CellTo, CountOnce, CountRepeat, True, Confirm);
     2932      Assigned(Client) and Assigned(Client.FOnMove) then
     2933        Client.FOnMove(CellFrom, CellTo, CountOnce, CountRepeat, True, Confirm);
    29242934  end else begin
    29252935    CountOnce := Power;
    29262936    CountRepeat := 0;
    29272937    if (Mode = pmHuman) and Confirmation and
    2928       Assigned(Game.FOnMove) then Game.FOnMove(CellFrom, CellTo, CountOnce, CountRepeat, False, Confirm);
     2938      Assigned(Client) and Assigned(Client.FOnMove) then
     2939        Client.FOnMove(CellFrom, CellTo, CountOnce, CountRepeat, False, Confirm);
    29292940  end;
    29302941  if Confirm then begin
Note: See TracChangeset for help on using the changeset viewer.