Changeset 183 for trunk/UCore.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/UCore.pas

    r182 r183  
    6767    procedure DoPlayerChange(Sender: TObject);
    6868    procedure DoMoveUpdated(UnitMove: TUnitMove);
    69     procedure DoOnMove(CellFrom, CellTo: TCell; var CountOnce,
    70       CountRepeat: Integer; Update: Boolean; var Confirm: Boolean);
    7169    procedure DoOnWin(Player: TPlayer);
    7270    procedure Delay(Time: Integer);
     
    106104
    107105uses
    108   UFormMove, UFormMain, UFormNew, UFormSettings, UFormAbout, UFormPlayer,
     106  UFormMove, UFormMain, UFormNew, UFormSettings, UFormAbout,
    109107  UFormHelp, UFormCharts, UFormUnitMoves, UFormPlayersStats;
    110108
     
    123121
    124122{ TCore }
    125 
    126 procedure TCore.DoOnMove(CellFrom, CellTo: TCell; var CountOnce,
    127   CountRepeat: Integer; Update: Boolean; var Confirm: Boolean);
    128 var
    129   I: Integer;
    130 begin
    131   if Update then FormMove.SpinEditOnce.MaxValue := CellFrom.GetAvialPower + CountOnce
    132     else FormMove.SpinEditOnce.MaxValue := CellFrom.GetAvialPower;
    133   FormMove.SpinEditOnce.Value := CountOnce;
    134   FormMove.TrackBarOnce.Max := FormMove.SpinEditOnce.MaxValue;
    135   FormMove.TrackBarOnce.Position := FormMove.SpinEditOnce.Value;
    136   FormMove.SpinEditRepeat.MaxValue := Game.Map.MaxPower;
    137   FormMove.SpinEditRepeat.Value := CountRepeat;
    138   FormMove.TrackBarRepeat.Max := FormMove.SpinEditRepeat.MaxValue;
    139   FormMove.TrackBarRepeat.Position := FormMove.SpinEditRepeat.Value;
    140   FormMove.DefendCount := CellTo.Power;
    141   // Attack count from other surrounding cells without current move if already exists
    142   FormMove.AttackCount := 0;
    143   for I := 0 to CellTo.MovesTo.Count - 1 do
    144   if TUnitMove(CellTo.MovesTo[I]).CellFrom <> CellFrom then
    145     FormMove.AttackCount := FormMove.AttackCount + TUnitMove(CellTo.MovesTo[I]).CountOnce;
    146   FormMove.ShowWinProbability := CellTo.Player <> CellFrom.Player;
    147 
    148   if FormMove.ShowModal = mrOk then begin
    149     CountOnce := FormMove.SpinEditOnce.Value;
    150     CountRepeat := FormMove.SpinEditRepeat.Value;
    151     Confirm := True;
    152   end else Confirm := False;
    153 end;
    154123
    155124procedure TCore.DoOnWin(Player: TPlayer);
     
    401370begin
    402371  UGame.InitStrings;
    403   FormPlayer.Translate;
    404372end;
    405373
     
    408376  Server := TServer.Create;
    409377  Game := TGame.Create;
    410   Game.OnMove := DoOnMove;
    411378  Game.OnMoveUpdated := DoMoveUpdated;
    412379  Game.OnWin := DoOnWin;
     
    485452  Form.AZoomAll.Execute;
    486453  Form.Show;
     454  FormClients.Add(Form);
    487455end;
    488456
Note: See TracChangeset for help on using the changeset viewer.