Fix claiming land prior to working a tile.

This commit is contained in:
Mike Pope 2010-12-09 08:21:48 +00:00
parent ba28a866d5
commit a78e9958ac
3 changed files with 16 additions and 2 deletions

View File

@ -4253,7 +4253,8 @@ public final class InGameController implements NetworkConstants {
Tile tile = unit.getTile();
if (player != tile.getOwner()) {
if (!claimLand(tile, null, 0)) return;
if (!claimTile(player, tile, null, player.getLandPrice(tile), 0)
|| player != tile.getOwner()) return;
}
if (askChangeWorkImprovementType(unit, improvementType)) {

View File

@ -1150,6 +1150,19 @@ public class Player extends FreeColGameObject implements Nameable {
return owner == null || owner == this || getLandPrice(tile) == 0;
}
/**
* Can a tile be acquired from its owners and used for an improvement?
* Slightly weakens canClaimForImprovement to allow for purchase
* and/or stealing.
*
* @param tile The <code>Tile</code> to consider.
* @return True if the tile ownership can be claimed.
*/
public boolean canAcquireForImprovement(Tile tile) {
return canClaimForImprovement(tile)
|| getLandPrice(tile) >= 0;
}
/**
* Get the <code>Unit</code> value.
*

View File

@ -2466,7 +2466,7 @@ public class Unit extends FreeColGameObject implements Locatable, Location, Owna
return getState() == UnitState.FORTIFYING;
case IMPROVING:
if (location instanceof Tile
&& getOwner().canClaimForImprovement(location.getTile())) {
&& getOwner().canAcquireForImprovement(location.getTile())) {
return getMovesLeft() > 0;
}
return false;