本文整理汇总了Java中net.sf.freecol.common.model.Tile.hasRiver方法的典型用法代码示例。如果您正苦于以下问题:Java Tile.hasRiver方法的具体用法?Java Tile.hasRiver怎么用?Java Tile.hasRiver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.freecol.common.model.Tile
的用法示例。
在下文中一共展示了Tile.hasRiver方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transform
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
@Override
public void transform(Tile tile) {
TileImprovementType riverType =
tile.getSpecification().getTileImprovementType("model.improvement.river");
if (riverType.isTileTypeAllowed(tile.getType())) {
if (!tile.hasRiver()) {
StringBuilder sb = new StringBuilder(64);
for (Direction direction : Direction.longSides) {
Tile t = tile.getNeighbourOrNull(direction);
TileImprovement otherRiver = (t == null) ? null
: t.getRiver();
if (t == null || (t.isLand() && otherRiver == null)) {
sb.append('0');
} else {
sb.append(magnitude);
}
}
tile.addRiver(magnitude, sb.toString());
} else {
tile.removeRiver();
}
}
}
示例2: perhapsAddBonus
import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
* Adds a terrain bonus with a probability determined by the
* {@code MapGeneratorOptions}.
*
* @param t The {@code Tile} to add bonuses to.
* @param generateBonus Generate the bonus or not.
*/
private void perhapsAddBonus(Tile t, boolean generateBonus) {
final Game game = t.getGame();
final OptionGroup mapOptions = game.getMapGeneratorOptions();
final Specification spec = game.getSpecification();
TileImprovementType fishBonusLandType
= spec.getTileImprovementType("model.improvement.fishBonusLand");
TileImprovementType fishBonusRiverType
= spec.getTileImprovementType("model.improvement.fishBonusRiver");
final int bonusNumber
= mapOptions.getRange(MapGeneratorOptions.BONUS_NUMBER);
if (t.isLand()) {
if (generateBonus
&& randomInt(logger, "Land Resource", random, 100) < bonusNumber) {
// Create random Bonus Resource
t.addResource(createResource(t));
}
} else {
int adjacentLand = 0;
boolean adjacentRiver = false;
for (Direction direction : Direction.values()) {
Tile otherTile = t.getNeighbourOrNull(direction);
if (otherTile != null && otherTile.isLand()) {
adjacentLand++;
if (otherTile.hasRiver()) {
adjacentRiver = true;
}
}
}
// In Col1, ocean tiles with less than 3 land neighbours
// produce 2 fish, all others produce 4 fish
if (adjacentLand > 2) {
t.add(new TileImprovement(game, t, fishBonusLandType, null));
}
// In Col1, the ocean tile in front of a river mouth would
// get an additional +1 bonus
// FIXME: This probably has some false positives, means
// river tiles that are NOT a river mouth next to this tile!
if (!t.hasRiver() && adjacentRiver) {
t.add(new TileImprovement(game, t, fishBonusRiverType, null));
}
if (t.getType().isHighSeasConnected()) {
if (generateBonus && adjacentLand > 1
&& randomInt(logger, "Sea resource", random,
10 - adjacentLand) == 0) {
t.addResource(createResource(t));
}
} else {
if (randomInt(logger, "Water resource", random, 100) < bonusNumber) {
// Create random Bonus Resource
t.addResource(createResource(t));
}
}
}
}