Changeset 153 for trunk/UGame.pas
- Timestamp:
- Nov 15, 2017, 10:20:16 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r152 r153 61 61 Weight: Integer; // Temporary value 62 62 Links: TCellLinks; 63 procedure Check; 63 64 function NeighboringToVoid: Boolean; 64 65 procedure AreaExtend; … … 514 515 SNewGameFile = 'New game.xtg'; 515 516 SZeroZoomNotAlowed = 'Zero zoom not allowed'; 517 SCellRemoveNeighborError = 'Can''t remove cell from neighbour cell'; 518 SNegativeCellPowerNotAllowed = 'Not allowed to substract power under zero to negative value'; 519 SAttackerPowerPositive = 'Attacker power have to be higher then 0.'; 520 SDefenderPowerPositive = 'Defender power have to be higher then or equal to 0.'; 521 SUnitPowerMismatch = 'Unit move power mismatch. Cell power is %d but %d moved away.'; 516 522 517 523 procedure InitStrings; … … 726 732 for I := 0 to Cells.Count - 1 do begin 727 733 if TCell(Cells[I]).Neighbors.Remove(TCell(Cells[1 - I])) = -1 then 728 raise Exception.Create( 'Can''t remove cell from neighbour cell');734 raise Exception.Create(SCellRemoveNeighborError); 729 735 if TCell(Cells[I]).Links.Remove(Self) = -1 then 730 raise Exception.Create( 'Can''t remove cell from neighbour cell');736 raise Exception.Create(SCellRemoveNeighborError); 731 737 end; 732 738 FreeAndNil(Cells); … … 978 984 Cell := TPlayerCell(Cells[C]); 979 985 if (Cell.MapCell.Terrain <> ttVoid) and Cell.MapCell.IsVisible(View) then begin 980 CellText := IntToStr(Cell.MapCell.GetAvialPower); 986 if Cell.MapCell.Player = Player then 987 CellText := IntToStr(Cell.MapCell.GetAvialPower) 988 else CellText := IntToStr(Cell.MapCell.Power); 981 989 if Assigned(SelectedCell) and (SelectedCell = Cell.MapCell) then 982 990 Brush.Color := clGreen … … 1750 1758 if FPower = AValue then Exit; 1751 1759 if AValue < 0 then 1752 raise Exception.Create( 'Not allowed to substract power under zero do negative value');1760 raise Exception.Create(SNegativeCellPowerNotAllowed); 1753 1761 FPower := AValue; 1762 end; 1763 1764 procedure TCell.Check; 1765 var 1766 AvailPower: Integer; 1767 begin 1768 AvailPower := GetAvialPower; 1769 if AvailPower < 0 then 1770 raise Exception.Create(Format(SUnitPowerMismatch, [Power, -(AvailPower - Power)])); 1754 1771 end; 1755 1772 … … 1897 1914 for UnitMove in MovesFrom do 1898 1915 Result := Result - UnitMove.CountOnce; 1899 if Result < 0 then raise Exception.Create('Unit move power mismatch. Cell power is ' +1900 IntToStr(Power) + ' but ' + IntToStr(- (Result - Power)) + ' moved away.');1901 1916 end; 1902 1917 … … 1943 1958 for I := Neighbors.Count - 1 downto 0 do 1944 1959 if TCell(Neighbors[I]).Neighbors.Remove(Self) = -1 then 1945 raise Exception.Create( 'Can''t remove cell from neighbour cell');1960 raise Exception.Create(SCellRemoveNeighborError); 1946 1961 FreeAndNil(Neighbors); 1947 1962 inherited Destroy; … … 2522 2537 DefendRolls := TFPGList<Integer>.Create; 2523 2538 if AttackPower < 1 then 2524 raise Exception.Create( 'Attacker power have to be higher then 0.');2539 raise Exception.Create(SAttackerPowerPositive); 2525 2540 if DefendPower < 0 then 2526 raise Exception.Create( 'Defender power have to be higher then or equal to 0.');2541 raise Exception.Create(SDefenderPowerPositive); 2527 2542 while (AttackPower > 0) and (DefendPower > 0) do begin 2528 2543 // Risk game rules: … … 2654 2669 end; 2655 2670 end; 2671 2656 2672 // Remove empty moves 2657 2673 for I := Moves.Count - 1 downto 0 do … … 2734 2750 end; 2735 2751 end; 2752 CellFrom.Check; 2736 2753 if Assigned(Game.FOnMoveUpdated) then Game.FOnMoveUpdated(Result); 2737 2754 end;
Note:
See TracChangeset
for help on using the changeset viewer.