当前位置: 首页>>代码示例>>Java>>正文


Java Tile.getGame方法代码示例

本文整理汇总了Java中net.sf.freecol.common.model.Tile.getGame方法的典型用法代码示例。如果您正苦于以下问题:Java Tile.getGame方法的具体用法?Java Tile.getGame怎么用?Java Tile.getGame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.freecol.common.model.Tile的用法示例。


在下文中一共展示了Tile.getGame方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transform

import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
@Override
public void transform(Tile t) {
    if (!t.isLand()
        || t.hasSettlement()
        || nativeNation == null) return;
    UnitType skill = first(((IndianNationType)nativeNation.getType())
        .getSkills()).getObject();
    Player nativePlayer = getGame().getPlayerByNation(nativeNation);
    if (nativePlayer == null) return;
    String name = nativePlayer.getSettlementName(null);
    ServerIndianSettlement sis
        = new ServerIndianSettlement(t.getGame(),
            nativePlayer, name, t, false, skill, null);
    nativePlayer.addSettlement(sis);
    sis.placeSettlement(true);
    sis.addUnits(null);
    logger.info("Add settlement " + sis.getName() + " to tile " + t);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:19,代码来源:MapEditorTransformPanel.java

示例2: createResource

import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
 * Create a random resource on a tile.
 *
 * @param tile The {@code Tile} to create the resource on.
 * @return The created resource, or null if it is not possible.
 */
private Resource createResource(Tile tile) {
    if (tile == null) return null;
    ResourceType resourceType = RandomChoice.getWeightedRandom(null, null,
        tile.getType().getResourceTypes(), random);
    if (resourceType == null) return null;
    int minValue = resourceType.getMinValue();
    int maxValue = resourceType.getMaxValue();
    int quantity = (minValue == maxValue) ? maxValue
        : (minValue + randomInt(logger, "Rsiz", random, 
                                maxValue - minValue + 1));
    return new Resource(tile.getGame(), tile, resourceType, quantity);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:19,代码来源:TerrainGenerator.java

示例3: makeLostCityRumours

import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
 * Make lost city rumours on the given map.
 *
 * The number of rumours depends on the map size.
 *
 * @param map The {@code Map} to use.
 * @param importMap An optional {@code Map} to import from.
 * @param lb A {@code LogBuilder} to log to.
 */
private void makeLostCityRumours(Map map, Map importMap, LogBuilder lb) {
    final Game game = map.getGame();
    final boolean importRumours = game.getMapGeneratorOptions()
        .getBoolean(MapGeneratorOptions.IMPORT_RUMOURS);
    if (importMap != null && importRumours) {
        // Rumours were read from the import game, no need to do more
        return;
    }

    final int rumourNumber = game.getMapGeneratorOptions()
        .getRange(MapGeneratorOptions.RUMOUR_NUMBER);
    int number = getApproximateLandCount(game) / rumourNumber;
    int counter = 0;

    // FIXME: Remove temporary fix:
    if (importMap != null) {
        number = map.getWidth() * map.getHeight() * 25 / (100 * 35);
    }

    for (int i = 0; i < number; i++) {
        for (int tries = 0; tries < 100; tries++) {
            Tile t = map.getRandomLandTile(random);
            if (t.isPolar()) continue; // No polar lost cities
            if (t.isLand() && !t.hasLostCityRumour()
                && !t.hasSettlement() && t.getUnitCount() == 0) {
                LostCityRumour r = new LostCityRumour(t.getGame(), t);
                if (r.chooseType(null, random)
                    == LostCityRumour.RumourType.MOUNDS
                    && t.getOwningSettlement() != null) {
                    r.setType(LostCityRumour.RumourType.MOUNDS);
                }
                t.addLostCityRumour(r);
                counter++;
                break;
            }
        }
    }
    lb.add("Created ", counter,
        " lost city rumours of maximum ", number, ".\n");
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:50,代码来源:SimpleMapGenerator.java

示例4: 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));
            }
        }
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:65,代码来源:TerrainGenerator.java


注:本文中的net.sf.freecol.common.model.Tile.getGame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。