- Timestamp:
- Mar 3, 2014, 1:24:06 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UFormMove.lfm
r26 r27 66 66 Width = 296 67 67 OnChange = TrackBarOnceChange 68 PageSize = 1 68 69 Position = 0 69 70 TickStyle = tsNone … … 77 78 Width = 304 78 79 OnChange = TrackBarRepeatChange 80 PageSize = 1 79 81 Position = 0 80 82 TickStyle = tsNone -
trunk/UGame.pas
r26 r27 141 141 FRunning: Boolean; 142 142 procedure MoveAll(Player: TPlayer); 143 procedure SetMove(CellFrom, CellTo: TCell );143 procedure SetMove(CellFrom, CellTo: TCell; Power: Integer); 144 144 procedure SetRunning(AValue: Boolean); 145 145 public … … 316 316 Cells: TCellArray; 317 317 X, Y: Integer; 318 Target: TCell; 319 MinPower: Integer; 318 TotalPower: Integer; 319 AttackPower: Integer; 320 TotalAttackPower: Integer; 320 321 I: Integer; 321 322 begin … … 323 324 for X := 0 to Game.Map.Size.Y - 1 do 324 325 with TCell(Game.Map.Cells[Y, X]) do begin 325 if Player = Selfthen begin326 // Search not own neighbour with lowespower326 if (Terrain <> ttVoid) and (Player <> Self) then begin 327 // Count own possible power 327 328 Cells := Game.Map.GetCellNeighbours(Game.Map.Cells[Y, X]); 328 T arget := nil;329 TotalPower := 0; 329 330 for I := 0 to Length(Cells) - 1 do 330 if (Cells[I].Terrain <> ttVoid) and (Cells[I].Player <> Self) then begin 331 if Target = nil then begin 332 MinPower := Cells[I].Power; 333 Target := Cells[I]; 334 end else if Cells[I].Power < MinPower then begin 335 MinPower := Cells[I].Power; 336 Target := Cells[I]; 331 if (Cells[I].Player = Self) then begin 332 TotalPower := TotalPower + Cells[I].GetAvialPower; 333 end; 334 // Attack if target is weaker 335 if TotalPower > Power then begin 336 TotalAttackPower := 0; 337 for I := 0 to Length(Cells) - 1 do 338 if (Cells[I].Player = Self) then begin 339 // Use only necessary power 340 AttackPower := Power - TotalAttackPower + 1; 341 if Cells[I].Power < AttackPower then 342 AttackPower := Cells[I].Power; 343 Game.SetMove(Cells[I], Game.Map.Cells[Y, X], AttackPower); 344 TotalAttackPower := TotalAttackPower + AttackPower; 337 345 end; 338 346 end; 339 // Attack if target is weaker340 if Assigned(Target) and (Target.Power < Power) then341 Game.SetMove(Game.Map.Cells[Y, X], Target);342 347 end; 343 348 end; … … 353 358 if Assigned(NewSelectedCell) then begin 354 359 if Assigned(SelectedCell) and IsCellsNeighbor(NewSelectedCell, SelectedCell) then begin 355 Game.SetMove(SelectedCell, NewSelectedCell );360 Game.SetMove(SelectedCell, NewSelectedCell, SelectedCell.Power); 356 361 SelectedCell := nil; 357 362 end else … … 433 438 end; 434 439 435 procedure TGame.SetMove(CellFrom, CellTo: TCell );440 procedure TGame.SetMove(CellFrom, CellTo: TCell; Power: Integer); 436 441 var 437 442 NewMove: TMove; … … 449 454 Assigned(FOnMove) then FOnMove(CellFrom, CellTo, CountOnce, CountRepeat, True); 450 455 end else begin 451 CountOnce := CellFrom.Power;456 CountOnce := Power; 452 457 CountRepeat := 0; 453 458 if Assigned(CurrentPlayer) and (CurrentPlayer.Mode = pmHuman) and
Note:
See TracChangeset
for help on using the changeset viewer.