本文整理汇总了Java中net.sf.freecol.common.model.Tile.getIndianSettlement方法的典型用法代码示例。如果您正苦于以下问题:Java Tile.getIndianSettlement方法的具体用法?Java Tile.getIndianSettlement怎么用?Java Tile.getIndianSettlement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.freecol.common.model.Tile
的用法示例。
在下文中一共展示了Tile.getIndianSettlement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: moveScoutIndianSettlement
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* Move a scout into an Indian settlement to speak with the chief,
* or demand a tribute following a move of
* MoveType.ENTER_INDIAN_SETTLEMENT_WITH_SCOUT.
* The scout does not physically get into the village, it will
* just stay where it is.
*
* @param unit The {@code Unit} that is scouting.
* @param direction The direction in which the Indian settlement lies.
* @return True if automatic movement of the unit can proceed (never).
*/
private boolean moveScoutIndianSettlement(Unit unit, Direction direction) {
if (!askClearGotoOrders(unit)
|| !askServer().scoutSettlement(unit, direction)) return false;
// Offer the choices.
final Tile unitTile = unit.getTile();
final Tile tile = unitTile.getNeighbourOrNull(direction);
final Player player = unit.getOwner();
final IndianSettlement is = tile.getIndianSettlement();
final int count = player.getNationSummary(is.getOwner())
.getNumberOfSettlements();
ScoutIndianSettlementAction act
= getGUI().getScoutIndianSettlementChoice(is, (count <= 0)
? Messages.message("many") : Integer.toString(count));
if (act == null) return false; // Cancelled
switch (act) {
case SCOUT_SETTLEMENT_ATTACK:
if (getGUI().confirmPreCombat(unit, tile)) {
askServer().attack(unit, direction);
}
break;
case SCOUT_SETTLEMENT_SPEAK:
// Prevent turn ending to allow speaking results to complete
moveMode = moveMode.minimize(MoveMode.EXECUTE_GOTO_ORDERS);
askServer().scoutSpeakToChief(unit, is);
break;
case SCOUT_SETTLEMENT_TRIBUTE:
return moveTribute(unit, 1, direction);
default:
logger.warning("showScoutIndianSettlementDialog fail: " + act);
break;
}
return false;
}
示例2: changeState
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* Change a units state.
*
* @param serverPlayer The {@code ServerPlayer} that owns the unit.
* @param unit The {@code Unit} to change the state of.
* @param state The new {@code UnitState}.
* @return A {@code ChangeSet} encapsulating this action.
*/
public ChangeSet changeState(ServerPlayer serverPlayer, Unit unit,
UnitState state) {
ChangeSet cs = new ChangeSet();
Tile tile = unit.getTile();
boolean tileDirty = tile != null && tile.getIndianSettlement() != null;
if (state == UnitState.FORTIFYING && tile != null) {
ServerColony colony = (tile.getOwningSettlement() instanceof Colony)
? (ServerColony) tile.getOwningSettlement()
: null;
Player owner = (colony == null) ? null : colony.getOwner();
if (owner != null
&& owner != unit.getOwner()
&& serverPlayer.getStance(owner) != Stance.ALLIANCE
&& serverPlayer.getStance(owner) != Stance.PEACE) {
if (colony.isTileInUse(tile)) {
colony.csEvictUsers(unit, cs);
}
if (serverPlayer.getStance(owner) == Stance.WAR) {
tile.changeOwnership(null, null); // Clear owner if at war
tileDirty = true;
}
}
}
unit.setState(state);
if (tileDirty) {
cs.add(See.perhaps(), tile);
} else {
cs.add(See.perhaps(), (FreeColGameObject)unit.getLocation());
}
// Others might be able to see the unit.
getGame().sendToOthers(serverPlayer, cs);
return cs;
}
示例3: testHorsesLost
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
public void testHorsesLost() {
Game game = ServerTestHelper.startServerGame(getTestMap(true));
Map map = game.getMap();
AIMain aiMain = ServerTestHelper.getServer().getAIMain();
// Create players, settlement and unit
ServerPlayer inca = (ServerPlayer)game.getPlayerByNationId("model.nation.inca");
ServerPlayer dutch = (ServerPlayer)game.getPlayerByNationId("model.nation.dutch");
dutch.exploreMap(true);
Tile settlementTile = map.getTile(2, 1);
FreeColTestCase.IndianSettlementBuilder builder
= new FreeColTestCase.IndianSettlementBuilder(game);
builder.player(inca).settlementTile(settlementTile).build();
IndianSettlement is = settlementTile.getIndianSettlement();
Player.makeContact(inca, dutch);
Tile unitTile = map.getTile(2, 2);
Unit scout = new ServerUnit(game, unitTile, dutch,
scoutType, scoutRole);
assertEquals(scoutRole, scout.getRole());
AIUnit aiUnit = aiMain.getAIUnit(scout);
aiUnit.setMission(null);
assertNotNull("The scout should be an AI unit", aiUnit);
assertEquals("Scout should have the scout role", scoutRole,
scout.getRole());
assertTrue("Scout should be able to speak to chief",
scout.hasAbility(Ability.SPEAK_WITH_CHIEF));
assertEquals("The Inca settlement should be a scouting target", null,
ScoutingMission.invalidReason(aiUnit, is));
assertEquals("The Inca settlement should be found as scouting target",
is, ScoutingMission.findTarget(aiUnit, 10, false));
assertEquals("Scouting mission should be assignable to scout", null,
ScoutingMission.invalidReason(aiUnit));
ScoutingMission mission
= new ScoutingMission(aiMain, aiUnit, is);
assertEquals("Scout should have been assigned the Scouting mission",
mission, aiUnit.getMission());
assertEquals(null, mission.invalidReason());
assertTrue("Scouting mission should be valid",
mission.isValid());
assertEquals("Scouting mission target should be the Inca settlement",
is, mission.getTarget());
// Invalidate the mission by losing the horses.
scout.changeRole(spec().getDefaultRole(), 0);
assertFalse("Scout should not have the scout role",
scout.hasAbility(Ability.SPEAK_WITH_CHIEF));
assertNotNull("Scouting mission should be invalid",
aiUnit.getMission().invalidReason());
assertNotNull("Scouting mission should be impossible for this unit",
ScoutingMission.invalidReason(aiUnit));
// Restore the horses.
scout.changeRole(scoutRole, 1);
assertTrue("Scouting mission should be valid again",
aiUnit.getMission().isValid());
// Complete the mission, should be invalid.
is.setScouted(dutch);
assertFalse("Scouting mission should be invalid lacking target",
aiUnit.getMission().isValid());
// Add an LCR. Mission could become valid again.
Tile lcrTile = map.getTile(2, 3);
lcrTile.addLostCityRumour(new LostCityRumour(game, lcrTile));
assertEquals("Scouting mission should be possible for this unit", null,
ScoutingMission.invalidReason(aiUnit));
assertEquals("The LCR tile should be a scouting target",
lcrTile, ScoutingMission.findTarget(aiUnit, 10, false));
}