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


Java Force类代码示例

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


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

示例1: readChild

import net.sf.freecol.common.model.Force; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void readChild(FreeColXMLReader xr) throws XMLStreamException {
    final String tag = xr.getLocalName();

    if (EXPEDITIONARY_FORCE_TAG.equals(tag)) {
        this.expeditionaryForce.readFromXML(xr);

    } else if (INTERVENTION_FORCE_TAG.equals(tag)) {
        this.interventionForce.readFromXML(xr);

    // @compat 0.11.5
    // Mercenary force is never updated, and lives in the spec now, so
    // just read and discard it.
    } else if (MERCENARY_FORCE_TAG.equals(tag)) {
        new Force(getSpecification()).readFromXML(xr);
    // end @compat 0.11.5

    } else {
        super.readChild(xr);
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:25,代码来源:Monarch.java

示例2: createREFPlayer

import net.sf.freecol.common.model.Force; //导入依赖的package包/类
/**
 * Create the Royal Expeditionary Force player corresponding to
 * a given player that is about to rebel.
 *
 * Public for the test suite.
 *
 * FIXME: this should eventually generate changes for the REF player.
 *
 * @param serverPlayer The {@code ServerPlayer} about to rebel.
 * @return The REF player.
 */
public ServerPlayer createREFPlayer(ServerPlayer serverPlayer) {
    final Nation refNation = serverPlayer.getNation().getREFNation();
    final Monarch monarch = serverPlayer.getMonarch();
    final ServerPlayer refPlayer = getFreeColServer().makeAIPlayer(refNation);
    final Europe europe = refPlayer.getEurope();
    final Predicate<Tile> exploredPred = t ->
        ((!t.isLand() || t.isCoastland() || t.getOwner() == serverPlayer)
            && t.isExploredBy(serverPlayer));
    // Inherit rebel player knowledge of the seas, coasts, claimed
    // land but not full detailed scouting knowledge.
    Set<Tile> explore = new HashSet<>();
    getGame().getMap().forEachTile(exploredPred, t -> explore.add(t));
    refPlayer.exploreTiles(explore);

    // Trigger initial placement routine
    refPlayer.setEntryTile(null);
    // Will change, setup only
    Player.makeContact(serverPlayer, refPlayer);

    // Instantiate the REF in Europe
    Force exf = monarch.getExpeditionaryForce();
    if (!exf.prepareToBoard()) {
        logger.warning("Unable to ensure space for the REF land units.");
        // For now, do not fail completely
    }
    List<Unit> landUnits = refPlayer.createUnits(exf.getLandUnitsList(),
                                                 europe);//-vis: safe!map
    List<Unit> navalUnits = refPlayer.createUnits(exf.getNavalUnitsList(),
                                                  europe);//-vis: safe!map
    List<Unit> leftOver = refPlayer.loadShips(landUnits, navalUnits,
                                              random);//-vis: safe!map
    if (!leftOver.isEmpty()) {
        // Should not happen, make this return null one day
        logger.warning("Failed to board REF units: "
            + join(" ", transform(leftOver, alwaysTrue(),
                                  FreeColObject::getId)));
    }
    return refPlayer;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:51,代码来源:InGameController.java

示例3: getExpeditionaryForce

import net.sf.freecol.common.model.Force; //导入依赖的package包/类
/**
 * Get the force describing the REF.
 *
 * @return The REF {@code Force}.
 */
public Force getExpeditionaryForce() {
    if (this.expeditionaryForce == null) {
        final Specification spec = getSpecification();
        this.expeditionaryForce = new Force(spec,
            spec.getUnitList(GameOptions.REF_FORCE), null);
    }
    return this.expeditionaryForce;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:14,代码来源:Monarch.java

示例4: getInterventionForce

import net.sf.freecol.common.model.Force; //导入依赖的package包/类
/**
 * Get the force describing the Intervention Force.
 *
 * @return The intervention {@code Force}.
 */
public Force getInterventionForce() {
    if (this.interventionForce == null) {
        final Specification spec = getSpecification();
        this.interventionForce = new Force(spec,
            spec.getUnitList(GameOptions.INTERVENTION_FORCE), null);
    }
    return this.interventionForce;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:14,代码来源:Monarch.java

示例5: chooseForREF

import net.sf.freecol.common.model.Force; //导入依赖的package包/类
/**
 * Gets units to be added to the Royal Expeditionary Force.
 *
 * @param random The {@code Random} number source to use.
 * @return An addition to the Royal Expeditionary Force.
 */
public AbstractUnit chooseForREF(Random random) {
    initializeCaches();

    final Specification spec = getSpecification();
    // Preserve some extra naval capacity so that not all the REF
    // navy is completely loaded
    // FIXME: magic number 2.5 * Manowar-capacity = 15
    Force ref = getExpeditionaryForce();
    boolean needNaval = ref.getCapacity()
        < ref.getSpaceRequired() + 15;
    List<UnitType> types = (needNaval) ? navalREFUnitTypes
        : landREFUnitTypes;
    if (types.isEmpty()) return null;
    UnitType unitType = getRandomMember(logger, "Choose REF unit",
                                        types, random);
    Role role = (needNaval
        || !unitType.hasAbility(Ability.CAN_BE_EQUIPPED))
        ? spec.getDefaultRole()
        : (randomInt(logger, "Choose land role", random, 3) == 0)
        ? refMountedRole
        : refArmedRole;
    int number = (needNaval) ? 1
        : randomInt(logger, "Choose land#", random, 3) + 1;
    AbstractUnit result = new AbstractUnit(unitType, role.getId(), number);
    logger.info("Add to " + player.getDebugName()
        + " REF: capacity=" + ref.getCapacity()
        + " spaceRequired=" + ref.getSpaceRequired()
        + " => " + result);
    return result;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:37,代码来源:Monarch.java

示例6: updateInterventionForce

import net.sf.freecol.common.model.Force; //导入依赖的package包/类
/**
 * Update the intervention force, adding land units depending on
 * turns passed, and naval units sufficient to transport all land
 * units.
 */
public void updateInterventionForce() {
    Specification spec = getSpecification();
    int interventionTurns = spec.getInteger(GameOptions.INTERVENTION_TURNS);
    if (interventionTurns > 0) {
        Force ivf = getInterventionForce();
        int updates = getGame().getTurn().getNumber() / interventionTurns;
        for (AbstractUnit unit : ivf.getLandUnitsList()) {
            // add units depending on current turn
            int value = unit.getNumber() + updates;
            unit.setNumber(value);
        }
        ivf.updateSpaceAndCapacity();

        while (ivf.getCapacity() < ivf.getSpaceRequired()) {
            boolean progress = false;
            // Under capacity?  Add ships until all units can be
            // transported at once.
            for (AbstractUnit ship : transform(ivf.getNavalUnitsList(),
                    u -> u.getType(spec).canCarryUnits()
                        && u.getType(spec).getSpace() > 0)) {
                ship.setNumber(ship.getNumber() + 1);
                progress = true;
            }
            if (!progress) break;
            ivf.updateSpaceAndCapacity();
        }
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:34,代码来源:Monarch.java

示例7: readChildren

import net.sf.freecol.common.model.Force; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void readChildren(FreeColXMLReader xr) throws XMLStreamException {
    final Specification spec = getSpecification();
    // Provide dummy forces to read into.
    if (this.expeditionaryForce == null) this.expeditionaryForce = new Force(spec);
    if (this.interventionForce == null) this.interventionForce = new Force(spec);

    super.readChildren(xr);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:13,代码来源:Monarch.java

示例8: getMercenaryForce

import net.sf.freecol.common.model.Force; //导入依赖的package包/类
/**
 * Gets the force describing the Mercenary Force.
 *
 * This is never updated, and directly derived from the spec.
 *
 * @return The mercenary {@code Force}.
 */
public Force getMercenaryForce() {
    final Specification spec = getSpecification();
    return new Force(spec,
        spec.getUnitList(GameOptions.MERCENARY_FORCE), null);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:13,代码来源:Monarch.java

示例9: getWarSupportForce

import net.sf.freecol.common.model.Force; //导入依赖的package包/类
/**
 * Get the war support force.
 *
 * This is never updated, and directly derived from the spec.
 *
 * @return The war support {@code Force}.
 */
public Force getWarSupportForce() {
    final Specification spec = getSpecification();
    return new Force(spec,
        spec.getUnitList(GameOptions.WAR_SUPPORT_FORCE), null);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:13,代码来源:Monarch.java


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