Changeset 69 for trunk/UGame.pas


Ignore:
Timestamp:
Sep 28, 2014, 5:42:51 PM (10 years ago)
Author:
chronos
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UGame.pas

    r68 r69  
    11481148  S: string;
    11491149const
    1150   AttackDiff = 2;
     1150  AttackDiff = 1;
    11511151begin
    11521152  AllCells := Game.Map.Cells;
     
    12831283  NewTargetCells.OwnsObjects := False;
    12841284
    1285   // Get list of all our cells which can attack
     1285  // Get list of all enemy border cells
    12861286  for C := 0 to AllCells.Count - 1 do
    12871287  with TCell(AllCells[C]) do begin
    1288     if (Player = Game.CurrentPlayer) then begin
     1288    if (Player <> Game.CurrentPlayer) and (Player <> nil) and (Terrain <> ttVoid) then begin
    12891289      Cells := Game.Map.GetCellNeighbors(TCell(AllCells[C]));
    12901290      CanAttack := 0;
    12911291      for I := 0 to Length(Cells) - 1 do
    1292       if (Cells[I].Player <> Game.CurrentPlayer) and (Cells[I].Terrain <> ttVoid) then begin
     1292      if ((Cells[I].Player = Game.CurrentPlayer) or (Cells[I].Player = nil)) and (Cells[I].Terrain <> ttVoid) then begin
    12931293        Inc(CanAttack);
    12941294      end;
     
    13101310    for C := 0 to TargetCells.Count - 1 do
    13111311    with TCell(TargetCells[C]) do begin
    1312       //
    13131312      Cells := Game.Map.GetCellNeighbors(TCell(TargetCells[C]));
    1314       for I := 0 to Length(Cells) - 1 do
    1315       if (Cells[I].Player = Game.CurrentPlayer) and (Cells[I].Terrain <> ttVoid)
    1316       and (not Cells[I].Mark) then begin
    1317         Game.SetMove(Cells[I], TCell(TargetCells[C]), Cells[I].GetAvialPower);
    1318         TCell(TargetCells[C]).Mark := True;
    1319         NewTargetCells.Add(Cells[I]);
     1313      for I := 0 to Length(Cells) - 1 do begin
     1314        if (Cells[I].Terrain <> ttVoid) and (not Cells[I].Mark) then begin
     1315          if (TCell(TargetCells[C]).Player = Game.CurrentPlayer) and
     1316          (Cells[I].Player = Game.CurrentPlayer) then begin
     1317            // Do not take units from front line
     1318            Cells2 := Game.Map.GetCellNeighbors(TCell(Cells[I]));
     1319            CanAttack := 0;
     1320            for J := 0 to Length(Cells2) - 1 do
     1321            if ((Cells2[J].Player <> Game.CurrentPlayer) or (Cells2[J].Player = nil))
     1322            and (Cells2[J].Terrain <> ttVoid) then begin
     1323              Inc(CanAttack);
     1324            end;
     1325            if CanAttack = 0 then
     1326              Game.SetMove(Cells[I], TCell(TargetCells[C]), Cells[I].GetAvialPower);
     1327          end;
     1328          TCell(TargetCells[C]).Mark := True;
     1329          NewTargetCells.Add(Cells[I]);
     1330        end;
    13201331      end;
    13211332    end;
     
    16951706    VoidEnabled := GetValue(Path + '/VoidEnabled', True);
    16961707    VoidPercentage := GetValue(Path + '/VoidPercentage', 20);
    1697     Map.Size := Point(GetValue(Path + '/MapSizeX', 15),
    1698       GetValue(Path + '/MapSizeY', 15));
    1699     CityEnabled := GetValue(Path + '/CityEnabled', True);
     1708    Map.Size := Point(GetValue(Path + '/MapSizeX', 10),
     1709      GetValue(Path + '/MapSizeY', 10));
     1710    CityEnabled := GetValue(Path + '/CityEnabled', False);
    17001711    CityPercentage := GetValue(Path + '/CityPercentage', 10);
    17011712    GrowAmount := TGrowAmount(GetValue(Path + '/GrowAmount', Integer(gaBySquareRoot)));
     
    18391850  MoveAll(CurrentPlayer);
    18401851  Map.Grow(CurrentPlayer);
     1852  UpdateRepeatMoves(CurrentPlayer);
    18411853  ComputePlayerStats;
    18421854  PrevPlayer := CurrentPlayer;
     
    18471859  if Players.IndexOf(CurrentPlayer) < Players.IndexOf(PrevPlayer) then Inc(TurnCounter);
    18481860  CheckWinObjective;
    1849   UpdateRepeatMoves(CurrentPlayer);
    18501861  // For computers take view from previous human
    18511862  if CurrentPlayer.Mode = pmComputer then CurrentPlayer.View.Assign(PrevPlayer.View);
Note: See TracChangeset for help on using the changeset viewer.