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


Java Tile.cacheUnseen方法代码示例

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


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

示例1: joinColony

import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
 * Join a colony.
 *
 * @param serverPlayer The {@code ServerPlayer} that owns the unit.
 * @param unit The {@code Unit} that is joining.
 * @param colony The {@code Colony} to join.
 * @return A {@code ChangeSet} encapsulating this action.
 */
public ChangeSet joinColony(ServerPlayer serverPlayer, Unit unit,
                            Colony colony) {
    final Specification spec = getGame().getSpecification();
    ChangeSet cs = new ChangeSet();
    Set<Tile> ownedTiles = colony.getOwnedTiles();
    Tile tile = colony.getTile();

    // Join.
    tile.cacheUnseen();//+til
    unit.setLocation(colony);//-vis: safe/colony,-til
    unit.setMovesLeft(0);
    colony.equipForRole(unit, spec.getDefaultRole(), 0);

    // Update with colony tile, and tiles now owned.
    cs.add(See.only(serverPlayer), tile);
    for (Tile t : transform(tile.getSurroundingTiles(1, colony.getRadius()),
            t2 -> (t2.getOwningSettlement() == colony
                && !ownedTiles.contains(t2)))) {
        cs.add(See.perhaps(), t);
    }

    // Others might see a tile ownership change.
    getGame().sendToOthers(serverPlayer, cs);
    return cs;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:34,代码来源:InGameController.java

示例2: expendResource

import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
 * This method is called only when a new turn is beginning.  It
 * will reduce the quantity of the bonus {@code Resource}
 * that is on the given tile, if any and if applicable.
 *
 * @param tile The {@code Tile} to check for a resource.
 * @param goodsType The {@code GoodsType} the goods type to expend.
 * @param unitType The {@code UnitType} doing the production.
 * @return The {@code Resource} if it is exhausted by this
 *     call (so it can be used in a message), otherwise null.
 */
private Resource expendResource(Tile tile, GoodsType goodsType,
                                UnitType unitType) {
    if (!tile.hasResource()) return null;

    Resource resource = tile.getResource();
    if (resource.isUnlimited()) return null;

    if (resource.useQuantity(goodsType, unitType,
                             tile.getPotentialProduction(goodsType, unitType)) == 0) {
        tile.cacheUnseen();//+til
        tile.removeResource();//-til
        return resource;
    }
    return null;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:27,代码来源:ServerColonyTile.java

示例3: csEvictUsers

import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
 * Evict the users from a tile used by this colony, due to military
 * action from another unit.
 *
 * @param enemyUnit The {@code Unit} that has moved in.
 * @param cs A {@code ChangeSet} to update.
 */
public void csEvictUsers(Unit enemyUnit, ChangeSet cs) {
    ServerPlayer serverPlayer = (ServerPlayer)getOwner();
    Tile tile = enemyUnit.getTile();
    ServerColonyTile ct = (ServerColonyTile)getColonyTile(tile);
    if (ct == null) return;
    Tile colonyTile = ct.getColony().getTile();
    Tile copied = colonyTile.getTileToCache();
    if (!ejectUnits(ct, ct.getUnitList())) return;//-til
    colonyTile.cacheUnseen(copied);//+til
    cs.addMessage(serverPlayer,
        new ModelMessage(MessageType.WARNING,
                         "model.colony.workersEvicted",
                         this, this)
            .addName("%colony%", getName())
            .addStringTemplate("%location%", tile.getLocationLabel())
            .addStringTemplate("%enemyUnit%", enemyUnit.getLabel()));
    cs.add(See.only(serverPlayer), ct);
    cs.add(See.perhaps(), getTile()); // Colony size might have changed
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:27,代码来源:ServerColony.java

示例4: declineMounds

import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
 * Decline to investigate strange mounds.
 *
 * @param serverPlayer The {@code ServerPlayer} that owns the unit.
 * @param tile The {@code Tile} where the mounds are.
 * @return A {@code ChangeSet} encapsulating this action.
 */
public ChangeSet declineMounds(ServerPlayer serverPlayer, Tile tile) {
    tile.cacheUnseen();//+til
    tile.removeLostCityRumour();//-til

    // Others might see rumour disappear
    ChangeSet cs = new ChangeSet();
    cs.add(See.perhaps(), tile);
    getGame().sendToOthers(serverPlayer, cs);
    return cs;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:18,代码来源:InGameController.java

示例5: nativeFirstContact

import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
 * Handle first contact between European and native player.
 *
 * Note that we check for a diplomacy session, but only bother in
 * the case of tile!=null as that is the only possibility for some
 * benefit.
 *
 * @param serverPlayer The {@code ServerPlayer} making contact.
 * @param other The native {@code ServerPlayer} to contact.
 * @param tile A {@code Tile} on offer at first landing.
 * @param result Whether the initial peace treaty was accepted.
 * @return A {@code ChangeSet} encapsulating this action.
 */
public ChangeSet nativeFirstContact(ServerPlayer serverPlayer,
                                    ServerPlayer other, Tile tile,
                                    boolean result) {
    ChangeSet cs = new ChangeSet();
    DiplomacySession session = null;
    if (tile != null) {
        Unit u = tile.getFirstUnit();
        Settlement s = tile.getOwningSettlement();
        if (u != null && s != null) {
            session = DiplomacySession.findContactSession(u, s);
        }
    }
    if (result) {
        if (tile != null) {
            if (session == null) {
                return serverPlayer.clientError("No diplomacy for: "
                    + tile.getId());
            }
            tile.cacheUnseen();//+til
            tile.changeOwnership(serverPlayer, null);//-til
            cs.add(See.perhaps(), tile);
        }
    } else {
        // Consider not accepting the treaty to be an insult and
        // ban missions.
        other.csModifyTension(serverPlayer,
            Tension.TENSION_ADD_MAJOR, cs);//+til
        other.addMissionBan(serverPlayer);
    }
    if (session != null) session.complete(result, cs);
    getGame().sendToOthers(serverPlayer, cs);
    return cs;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:47,代码来源:InGameController.java

示例6: putOutsideColony

import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
 * Put outside colony.
 *
 * @param serverPlayer The {@code ServerPlayer} that owns the unit.
 * @param unit The {@code Unit} to be put out.
 * @return A {@code ChangeSet} encapsulating this action.
 */
public ChangeSet putOutsideColony(ServerPlayer serverPlayer, Unit unit) {
    Tile tile = unit.getTile();
    Colony colony = unit.getColony();
    if (unit.isInColony()) tile.cacheUnseen();//+til
    unit.setLocation(tile);//-vis: safe/colony,-til if in colony

    // Full tile update for the player, the rest get their limited
    // view of the colony so that population changes.
    ChangeSet cs = new ChangeSet();
    cs.add(See.only(serverPlayer), tile);
    cs.add(See.perhaps().except(serverPlayer), colony);
    return cs;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:21,代码来源:InGameController.java

示例7: csChangeMissionary

import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
 * Changes the missionary for this settlement and updates other players.
 *
 * +vis: Handles the visibility implications.
 * +til: Handles the tile appearance change.
 *
 * @param missionary The new missionary for this settlement.
 * @param cs A {@code ChangeSet} to update.
 */
public void csChangeMissionary(Unit missionary, ChangeSet cs) {
    final Unit old = getMissionary();
    if (missionary == old) return;

    final Tile tile = getTile();
    final ServerPlayer newOwner = (missionary == null) ? null
        : (ServerPlayer)missionary.getOwner();
    tile.cacheUnseen(newOwner);//+til

    if (old != null) {
        final ServerPlayer oldOwner = (ServerPlayer)old.getOwner(); 
        setMissionary(null);//-vis(oldOwner),-til
        tile.updateIndianSettlement(oldOwner);
        ((ServerUnit)old).csRemove(See.only(oldOwner),
            null, cs);//-vis(oldOwner)
        cs.add(See.only(oldOwner), tile);
        oldOwner.invalidateCanSeeTiles();//+vis(oldOwner)
    }

    if (missionary != null) {
        setMissionary(missionary);//-vis(newOwner)
        // Take the missionary off the map, and give it a fake
        // location at the settlement, bypassing the normal
        // validity checks.
        missionary.setLocation(null);//-vis(newOwner)
        missionary.setLocationNoUpdate(this);//-vis(newOwner),-til
        missionary.setMovesLeft(0);
        cs.add(See.only(newOwner), missionary);
        setConvertProgress(0);
        csChangeAlarm(newOwner, ALARM_NEW_MISSIONARY, true, cs);//-til
        tile.updateIndianSettlement(newOwner);

        cs.add(See.only(newOwner),
               newOwner.collectNewTiles(getMissionaryVisibleTiles()));
        cs.add(See.perhaps().always(newOwner), tile);
        newOwner.invalidateCanSeeTiles();//+vis(newOwner)
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:48,代码来源:ServerIndianSettlement.java

示例8: csClaimLand

import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
 * Claim land.
 *
 * @param tile The {@code Tile} to claim.
 * @param settlement The {@code Settlement} to claim for.
 * @param price The price to pay for the land, which must agree
 *     with the owner valuation, unless negative which denotes stealing.
 * @param cs A {@code ChangeSet} to update.
 */
public void csClaimLand(Tile tile, Settlement settlement, int price,
                        ChangeSet cs) {
    ServerPlayer owner = (ServerPlayer)tile.getOwner();
    Settlement ownerSettlement = tile.getOwningSettlement();
    tile.cacheUnseen();//+til
    tile.changeOwnership(this, settlement);//-vis(?),-til

    // Update the tile and any now-angrier owners, and the player
    // gold if a price was paid.
    cs.add(See.perhaps(), tile);
    if (price > 0) {
        modifyGold(-price);
        owner.modifyGold(price);
        cs.addPartial(See.only(this), this,
            "gold", String.valueOf(this.getGold()));
    } else if (price < 0 && owner.isIndian()) {
        ServerIndianSettlement sis = (ServerIndianSettlement)ownerSettlement;
        if (sis == null) {
            owner.csModifyTension(this, Tension.TENSION_ADD_LAND_TAKEN,
                                  cs);
        } else {
            sis.csModifyAlarm(this, Tension.TENSION_ADD_LAND_TAKEN,
                              true, cs);
        }
    }
    logger.finest(this.getName() + " claimed " + tile
        + " from " + ((owner == null) ? "no-one" : owner.getName())
        + ", price: " + ((price == 0) ? "free" : (price < 0) ? "stolen"
            : price));
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:40,代码来源:ServerPlayer.java

示例9: csEquipForRole

import net.sf.freecol.common.model.Tile; //导入方法依赖的package包/类
/**
 * Equip a unit for a specific role.
 *
 * @param unit The {@code Unit} to equip.
 * @param role The {@code Role} to equip for.
 * @param roleCount The role count.
 * @param random A pseudo-random number source.
 * @param cs A {@code ChangeSet} to update.
 * @return True if the equipping succeeds.
 */
public boolean csEquipForRole(Unit unit, Role role, int roleCount,
                              Random random, ChangeSet cs) {
    boolean ret = equipForRole(unit, role, roleCount);

    if (ret) {
        if (unit.isOnCarrier()) unit.setMovesLeft(0);
        Tile tile = getTile();
        tile.cacheUnseen();//+til
        unit.setLocation(tile);
        cs.add(See.perhaps(), tile);
    }
    return ret;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:24,代码来源:ServerColony.java


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