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


Java See类代码示例

本文整理汇总了Java中net.sf.freecol.common.networking.ChangeSet.See的典型用法代码示例。如果您正苦于以下问题:Java See类的具体用法?Java See怎么用?Java See使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


See类属于net.sf.freecol.common.networking.ChangeSet包,在下文中一共展示了See类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: csBuy

import net.sf.freecol.common.networking.ChangeSet.See; //导入依赖的package包/类
/**
 * Buy goods from a native settlement.
 *
 * @param unit The {@code Unit} that is buying.
 * @param goods The {@code Goods} to buy.
 * @param price The price to pay.
 * @param sis The {@code ServerIndianSettlement} to give to.
 * @param cs A {@code ChangeSet} to update.
 */
private void csBuy(Unit unit, Goods goods, int price,
                   ServerIndianSettlement sis, ChangeSet cs) {
    final Specification spec = getGame().getSpecification();
    final int alarmBonus = -Math.round(price * 0.001f
        * spec.getPercentage(GameOptions.ALARM_BONUS_BUY));
    final ServerPlayer owner = (ServerPlayer)unit.getOwner();
    csVisit(owner, sis, 0, cs);
    GoodsLocation.moveGoods(sis, goods.getType(), goods.getAmount(), unit);
    cs.add(See.perhaps(), unit);
    sis.getOwner().modifyGold(price);
    owner.modifyGold(-price);
    sis.csModifyAlarm(owner, alarmBonus, true, cs);
    sis.updateWantedGoods();
    final Tile tile = sis.getTile();
    tile.updateIndianSettlement(owner);
    cs.add(See.only(owner), tile);
    cs.addPartial(See.only(owner), owner,
                  "gold", String.valueOf(owner.getGold()));
    logger.finest(owner.getSuffix() + " " + unit + " buys " + goods
                  + " at " + sis.getName() + " for " + price);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:31,代码来源:InGameController.java

示例2: csSell

import net.sf.freecol.common.networking.ChangeSet.See; //导入依赖的package包/类
/**
 * Sell goods to a native settlement.
 *
 * @param unit The {@code Unit} that is selling.
 * @param goods The {@code Goods} to sell.
 * @param price The price to charge.
 * @param sis The {@code ServerIndianSettlement} to sell to.
 * @param cs A {@code ChangeSet} to update.
 */
private void csSell(Unit unit, Goods goods, int price,
                    ServerIndianSettlement sis, ChangeSet cs) {
    final Specification spec = getGame().getSpecification();
    final ServerPlayer owner = (ServerPlayer)unit.getOwner();
    final int alarmBonus = -Math.round(price * 0.001f
        * spec.getPercentage(GameOptions.ALARM_BONUS_SELL));
    csVisit(owner, sis, 0, cs);
    GoodsLocation.moveGoods(unit, goods.getType(), goods.getAmount(), sis);
    cs.add(See.perhaps(), unit);
    sis.getOwner().modifyGold(-price);
    owner.modifyGold(price);
    sis.csModifyAlarm(owner, alarmBonus, true, cs);
    sis.updateWantedGoods();
    final Tile tile = sis.getTile();
    tile.updateIndianSettlement(owner);
    cs.add(See.only(owner), tile);
    cs.addPartial(See.only(owner), owner,
                  "gold", String.valueOf(owner.getGold()));
    cs.addSale(owner, sis, goods.getType(),
               Math.round((float)price/goods.getAmount()));
    logger.finest(owner.getSuffix() + " " + unit + " sells " + goods
                  + " at " + sis.getName() + " for " + price);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:33,代码来源:InGameController.java

示例3: csEvictUsers

import net.sf.freecol.common.networking.ChangeSet.See; //导入依赖的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:wintertime,项目名称:FreeCol,代码行数:27,代码来源:ServerColony.java

示例4: askLearnSkill

import net.sf.freecol.common.networking.ChangeSet.See; //导入依赖的package包/类
/**
 * Ask about learning a skill at a native settlement.
 *
 * @param serverPlayer The {@code ServerPlayer} that is learning.
 * @param unit The {@code Unit} that is learning.
 * @param is The {@code IndianSettlement} to learn from.
 * @return A {@code ChangeSet} encapsulating this action.
 */
public ChangeSet askLearnSkill(ServerPlayer serverPlayer, Unit unit,
                               IndianSettlement is) {
    ChangeSet cs = new ChangeSet();

    csVisit(serverPlayer, is, 0, cs);
    Tile tile = is.getTile();
    tile.updateIndianSettlement(serverPlayer);
    cs.add(See.only(serverPlayer), tile);
    unit.setMovesLeft(0);
    cs.addPartial(See.only(serverPlayer), unit,
        "movesLeft", String.valueOf(unit.getMovesLeft()));

    // Do not update others, nothing to see yet.
    return cs;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:24,代码来源:InGameController.java

示例5: assignTeacher

import net.sf.freecol.common.networking.ChangeSet.See; //导入依赖的package包/类
/**
 * Assign a student to a teacher.
 *
 * @param serverPlayer The {@code ServerPlayer} that owns the unit.
 * @param student The student {@code Unit}.
 * @param teacher The teacher {@code Unit}.
 * @return A {@code ChangeSet} encapsulating this action.
 */
public ChangeSet assignTeacher(ServerPlayer serverPlayer, Unit student,
                               Unit teacher) {
    Unit oldStudent = teacher.getStudent();
    Unit oldTeacher = student.getTeacher();

    // Only update units that changed their teaching situation.
    ChangeSet cs = new ChangeSet();
    if (oldTeacher != null) {
        oldTeacher.setStudent(null);
        cs.add(See.only(serverPlayer), oldTeacher);
    }
    if (oldStudent != null) {
        oldStudent.setTeacher(null);
        cs.add(See.only(serverPlayer), oldStudent);
    }
    teacher.setStudent(student);
    teacher.changeWorkType(null);
    student.setTeacher(teacher);
    cs.add(See.only(serverPlayer), student, teacher);
    return cs;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:30,代码来源:InGameController.java

示例6: payArrears

import net.sf.freecol.common.networking.ChangeSet.See; //导入依赖的package包/类
/**
 * Pay arrears.
 *
 * @param serverPlayer The {@code ServerPlayer} that owns the unit.
 * @param type The {@code GoodsType} to pay the arrears for.
 * @return A {@code ChangeSet} encapsulating this action.
 */
public ChangeSet payArrears(ServerPlayer serverPlayer, GoodsType type) {
    int arrears = serverPlayer.getArrears(type);
    if (arrears <= 0) {
        return serverPlayer.clientError("No arrears for pay for: "
            + type.getId());
    } else if (!serverPlayer.checkGold(arrears)) {
        return serverPlayer.clientError("Not enough gold to pay arrears for: "
            + type.getId());
    }

    ChangeSet cs = new ChangeSet();
    Market market = serverPlayer.getMarket();
    serverPlayer.modifyGold(-arrears);
    market.setArrears(type, 0);
    cs.addPartial(See.only(serverPlayer), serverPlayer,
        "gold", String.valueOf(serverPlayer.getGold()));
    cs.add(See.only(serverPlayer), market.getMarketData(type));
    // Arrears payment is private.
    return cs;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:28,代码来源:InGameController.java

示例7: clearSpeciality

import net.sf.freecol.common.networking.ChangeSet.See; //导入依赖的package包/类
/**
 * Clear the specialty of a unit.
 *
 * FIXME: why not clear speciality in the open?  You can disband!
 * If we implement this remember to fix the visibility.
 *
 * @param serverPlayer The owner of the unit.
 * @param unit The {@code Unit} to clear the speciality of.
 * @return A {@code ChangeSet} encapsulating this action.
 */
public ChangeSet clearSpeciality(ServerPlayer serverPlayer, Unit unit) {
    UnitTypeChange uc = unit.getUnitChange(UnitChangeType.CLEAR_SKILL);
    if (uc == null) {
        return serverPlayer.clientError("Can not clear unit speciality: "
            + unit.getId());
    }

    // There can be some restrictions that may prevent the
    // clearing of the speciality.  AFAICT the only ATM is that a
    // teacher can not lose its speciality, but this will need to
    // be revisited if we invent a work location that requires a
    // particular unit type.
    if (unit.getStudent() != null) {
        return serverPlayer.clientError("Can not clear speciality of a teacher.");
    }

    // Valid, change type.
    unit.changeType(uc.to);//-vis: safe in colony

    // Update just the unit, others can not see it as this only happens
    // in-colony.
    return new ChangeSet().add(See.only(serverPlayer), unit);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:34,代码来源:InGameController.java

示例8: joinColony

import net.sf.freecol.common.networking.ChangeSet.See; //导入依赖的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

示例9: csModifyTension

import net.sf.freecol.common.networking.ChangeSet.See; //导入依赖的package包/类
/**
 * Modifies the hostility against the given player.
 *
 * +til: Handles tile modifications.
 *
 * @param player The {@code Player}.
 * @param add The amount to add to the current tension level.
 * @param origin A {@code Settlement} where the alarming event
 *     occurred.
 * @param cs A {@code ChangeSet} to update.
 */
public void csModifyTension(Player player, int add, Settlement origin,
                            ChangeSet cs) {
    Tension.Level oldLevel = getTension(player).getLevel();
    getTension(player).modify(add);
    if (oldLevel != getTension(player).getLevel()) {
        cs.add(See.only((ServerPlayer)player), this);
    }

    // Propagate tension change as settlement alarm to all
    // settlements except the one that originated it (if any).
    if (isIndian()) {
        for (IndianSettlement is : transform(getIndianSettlements(),
                i -> i != origin && i.hasContacted(player))) {
            ((ServerIndianSettlement)is).csModifyAlarm(player, add,
                                                       false, cs);//+til
        }
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:30,代码来源:ServerPlayer.java

示例10: setBuildQueue

import net.sf.freecol.common.networking.ChangeSet.See; //导入依赖的package包/类
/**
 * Set build queue.
 *
 * @param serverPlayer The {@code ServerPlayer} that owns the colony.
 * @param colony The {@code Colony} to set the queue of.
 * @param queue The new build queue.
 * @return A {@code ChangeSet} encapsulating this action.
 */
public ChangeSet setBuildQueue(ServerPlayer serverPlayer, Colony colony,
                               List<BuildableType> queue) {
    BuildableType current = colony.getCurrentlyBuilding();
    colony.setBuildQueue(queue);
    if (getGame().getSpecification()
        .getBoolean(GameOptions.CLEAR_HAMMERS_ON_CONSTRUCTION_SWITCH)
        && current != colony.getCurrentlyBuilding()) {
        for (AbstractGoods ag : transform(current.getRequiredGoods(),
                g -> !g.getType().isStorable())) {
            colony.removeGoods(ag.getType());
        }
    }
    colony.invalidateCache();

    // Only visible to player.
    ChangeSet cs = new ChangeSet();
    cs.add(See.only(serverPlayer), colony);
    return cs;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:28,代码来源:InGameController.java

示例11: setCurrentStop

import net.sf.freecol.common.networking.ChangeSet.See; //导入依赖的package包/类
/**
 * Set a unit stop.
 *
 * @param serverPlayer The {@code ServerPlayer} that owns the unit.
 * @param unit The {@code Unit} to set the destination for.
 * @param index The stop index.
 * @return A {@code ChangeSet} encapsulating this action.
 */
public ChangeSet setCurrentStop(ServerPlayer serverPlayer, Unit unit,
                                int index) {
    TradeRoute tr = unit.getTradeRoute();
    if (tr == null) {
        return serverPlayer.clientError("Unit has no trade route to set stop for.");
    } else if (index < 0 || index >= tr.getStopCount()) {
        return serverPlayer.clientError("Stop index out of range [0.."
            + tr.getStopCount() + "]: " + index);
    }

    unit.setCurrentStop(index);

    // Others can not see a stop change.
    return new ChangeSet().add(See.only(serverPlayer), unit);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:24,代码来源:InGameController.java

示例12: setNewLandName

import net.sf.freecol.common.networking.ChangeSet.See; //导入依赖的package包/类
/**
 * Set land name.
 *
 * @param serverPlayer The {@code ServerPlayer} who landed.
 * @param unit The {@code Unit} that has come ashore.
 * @param name The new land name.
 * @return A {@code ChangeSet} encapsulating this action.
 */
public ChangeSet setNewLandName(ServerPlayer serverPlayer, Unit unit,
                                String name) {
    ChangeSet cs = new ChangeSet();

    // Special case of a welcome from an adjacent native unit,
    // offering the land the landing unit is on if a peace treaty
    // is accepted.
    serverPlayer.setNewLandName(name);

    // Update the name and note the history.
    cs.addPartial(See.only(serverPlayer), serverPlayer,
        "newLandName", name);
    Turn turn = serverPlayer.getGame().getTurn();
    HistoryEvent h = new HistoryEvent(turn,
        HistoryEvent.HistoryEventType.DISCOVER_NEW_WORLD, serverPlayer)
            .addName("%name%", name);
    cs.addHistory(serverPlayer, h);
    return cs;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:28,代码来源:InGameController.java

示例13: updateTradeRoute

import net.sf.freecol.common.networking.ChangeSet.See; //导入依赖的package包/类
/**
 * Update a trade route for a player.
 *
 * @param serverPlayer The {@code ServerPlayer} to set trade
 *     routes for.
 * @param tradeRoute An uninterned {@code TradeRoute} to update.
 * @return A {@code ChangeSet} encapsulating this action.
 */
public ChangeSet updateTradeRoute(ServerPlayer serverPlayer,
                                  TradeRoute tradeRoute) {
    final Game game = getGame();
    String name;
    StringTemplate fail;
    TradeRoute tr;
    if (tradeRoute == null || tradeRoute.getId() == null
        || (name = tradeRoute.getName()) == null) {
        return serverPlayer.clientError("Bogus route");
    } else if ((fail = tradeRoute.verify()) != null) {
        return serverPlayer.clientError(Messages.message(fail));
    } else if ((tr = game.getFreeColGameObject(tradeRoute.getId(),
                TradeRoute.class)) == null) {
        return serverPlayer.clientError("Not an existing trade route: "
            + tradeRoute.getId());
    }
    tr.setId(tradeRoute.getId());
    tr.copyIn(tradeRoute);

    // Have to update the whole player alas.
    return new ChangeSet().add(See.only(serverPlayer), serverPlayer);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:31,代码来源:InGameController.java

示例14: csMercenaries

import net.sf.freecol.common.networking.ChangeSet.See; //导入依赖的package包/类
/**
 * Add an independent (non-monarch) mercenary offer to the player.
 *
 * @param price The price to charge for the mercenaries.
 * @param mercenaries A list of mercenary units.
 * @param action The monarch action that caused the offer.
 * @param random A pseudo-random number source.
 * @param cs A {@code ChangeSet} to update.
 */
public void csMercenaries(int price, List<AbstractUnit> mercenaries,
                          Monarch.MonarchAction action,
                          Random random, ChangeSet cs) {
    if (price <= 0 || mercenaries.isEmpty()) return;
    final int n = NameCache.getMercenaryLeaderIndex(random);
    cs.add(See.only(this),
           new MonarchActionMessage(action, StringTemplate
               .template(action.getTextKey())
               .addName("%leader%", NameCache.getMercenaryLeaderName(n))
               .addAmount("%gold%", price)
               .addStringTemplate("%mercenaries%",
                   AbstractUnit.getListLabel(", ", mercenaries)),
               "image.flavor.model.mercenaries." + n));
    new MonarchSession(this, action, mercenaries, price);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:25,代码来源:ServerPlayer.java

示例15: csNewTurn

import net.sf.freecol.common.networking.ChangeSet.See; //导入依赖的package包/类
/**
 * New turn for this colony tile.
 *
 * @param random A {@code Random} number source.
 * @param lb A {@code LogBuilder} to log to.
 * @param cs A {@code ChangeSet} to update.
 */
@Override
public void csNewTurn(Random random, LogBuilder lb, ChangeSet cs) {
    Colony colony = getColony();
    ServerPlayer owner = (ServerPlayer)colony.getOwner();

    Tile workTile = getWorkTile();
    if (!isColonyCenterTile() && !isEmpty() && canBeWorked()) {
        for (Unit unit : getUnitList()) {
            Resource resource = expendResource(workTile, unit.getWorkType(),
                                               unit.getType());
            if (resource != null) {
                lb.add(" ", getId(), " exhausted resource ",
                       resource.getType().getSuffix());
                cs.addMessage(owner,
                    new ModelMessage(ModelMessage.MessageType.WARNING,
                                     "model.colonyTile.resourceExhausted",
                                     colony)
                        .addNamed("%resource%", resource)
                        .addName("%colony%", colony.getName()));
                cs.add(See.perhaps(), workTile);
                break;
            }
        }
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:33,代码来源:ServerColonyTile.java


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