Changeset 203 for trunk/UClientAI.pas


Ignore:
Timestamp:
May 18, 2018, 12:54:37 AM (6 years ago)
Author:
chronos
Message:
  • Fixed: Player turn start/end signaling from server to clients.
  • Added: Save action to save game without opening save dialog.
  • Fixed: Move dialog was not opened after new game was created.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UClientAI.pas

    r202 r203  
    1717    //Targets: TFPGObjectList<TPlayer>;
    1818    CellProcessDirection: Boolean;
    19     Player: TPlayer;
    2019    procedure AttackNeutral;
    2120    procedure AttackPlayers;
     
    3433procedure TComputer.DoTurnStart(Sender: TObject);
    3534begin
    36   inherited DoTurnStart(Sender);
     35  Process;
     36  Protocol.TurnEnd;
    3737end;
    3838
     
    8989          if NeighborCell.GetAvialPower < AttackPower then
    9090            AttackPower := NeighborCell.GetAvialPower;
    91           Self.Player.SetMove(NeighborCell, Cell, AttackPower, False);
     91          ControlPlayer.SetMove(NeighborCell, Cell, AttackPower, False);
    9292          TotalAttackPower := TotalAttackPower + AttackPower;
    9393        end;
     
    109109  NeighborCell: TCell;
    110110begin
    111   if Player.Defensive then Exit;
     111  if ControlPlayer.Defensive then Exit;
    112112
    113113  AllCells := Game.Map.Cells;
     
    117117  // Get list of all attack target cells
    118118  for TargetCell in AllCells do begin
    119     if (TargetCell.Terrain <> ttVoid) and (TargetCell.Player <> Player) and
     119    if (TargetCell.Terrain <> ttVoid) and (TargetCell.Player <> ControlPlayer) and
    120120      (TargetCell.Player <> nil) then begin
    121121      CanAttack := 0;
    122122      for NeighborCell in TargetCell.Neighbors do
    123       if NeighborCell.Player = Player then begin
     123      if NeighborCell.Player = ControlPlayer then begin
    124124        Inc(CanAttack);
    125125      end;
     
    137137      TotalPower := 0;
    138138      for NeighborCell in TargetCell.Neighbors do
    139       if NeighborCell.Player = Player then begin
     139      if NeighborCell.Player = ControlPlayer then begin
    140140        TotalPower := TotalPower + NeighborCell.GetAvialPower;
    141141      end;
    142142      // Attack if target is weaker
    143143      if Game.AttackProbability(TotalPower, TargetCell.Power) >=
    144         ComputerAggroProbability[Player.Agressivity] then begin
     144        ComputerAggroProbability[ControlPlayer.Agressivity] then begin
    145145        // Try to limit total attacking power to necessary minimum
    146146        while Game.AttackProbability(TotalPower - 1, TargetCell.Power) >=
    147           ComputerAggroProbability[Player.Agressivity] do
     147          ComputerAggroProbability[ControlPlayer.Agressivity] do
    148148          Dec(TotalPower);
    149149
     
    151151        TotalAttackPower := 0;
    152152        for NeighborCell in TargetCell.Neighbors do
    153         if NeighborCell.Player = Player then begin
     153        if NeighborCell.Player = ControlPlayer then begin
    154154          // Use only necessary power
    155155          AttackPower := TotalPower - TotalAttackPower;
    156156          if NeighborCell.GetAvialPower < AttackPower then
    157157            AttackPower := NeighborCell.GetAvialPower;
    158           Self.Player.SetMove(NeighborCell, TargetCell, AttackPower, False);
     158          Self.ControlPlayer.SetMove(NeighborCell, TargetCell, AttackPower, False);
    159159          TotalAttackPower := TotalAttackPower + AttackPower;
    160160          if TotalAttackPower >= TotalPower then Break;
     
    258258begin
    259259  // If available power remains then use all for existed unit moves
    260   for Move in Player.Moves do
     260  for Move in ControlPlayer.Moves do
    261261  with Move do begin
    262262    if CellFrom.GetAvialPower > 0 then begin
Note: See TracChangeset for help on using the changeset viewer.