當前位置: 首頁>>代碼示例>>Java>>正文


Java Role.getRequiredGoodsList方法代碼示例

本文整理匯總了Java中net.sf.freecol.common.model.Role.getRequiredGoodsList方法的典型用法代碼示例。如果您正苦於以下問題:Java Role.getRequiredGoodsList方法的具體用法?Java Role.getRequiredGoodsList怎麽用?Java Role.getRequiredGoodsList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.sf.freecol.common.model.Role的用法示例。


在下文中一共展示了Role.getRequiredGoodsList方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: csLoseAutoEquip

import net.sf.freecol.common.model.Role; //導入方法依賴的package包/類
/**
 * Unit auto equips but loses equipment.
 *
 * @param attacker The {@code Unit} that attacked.
 * @param defender The {@code Unit} that defended and loses equipment.
 * @param cs A {@code ChangeSet} to update.
 */
private void csLoseAutoEquip(Unit attacker, Unit defender, ChangeSet cs) {
    ServerPlayer defenderPlayer = (ServerPlayer) defender.getOwner();
    StringTemplate defenderNation = defenderPlayer.getNationLabel();
    Settlement settlement = defender.getSettlement();
    Role role = defender.getAutomaticRole();
    StringTemplate defenderLabel = Messages.getUnitLabel(null,
        defender.getType().getId(), 1, defenderPlayer.getNation().getId(),
        role.getId(), null);
    ServerPlayer attackerPlayer = (ServerPlayer) attacker.getOwner();
    StringTemplate attackerNation = attacker.getApparentOwnerName();

    // Autoequipment is not actually with the unit, it is stored
    // in the settlement of the unit.  Remove it from there.
    for (AbstractGoods ag : role.getRequiredGoodsList()) {
        settlement.removeGoods(ag);
    }

    // No special message, attacker can not distinguish auto-armed
    // from actual-armed.
    cs.addMessage(attackerPlayer,
        new ModelMessage(ModelMessage.MessageType.COMBAT_RESULT,
                         "combat.unitDemotedToUnarmed.enemy", attacker)
            .addStringTemplate("%location%",
                 settlement.getLocationLabelFor(attackerPlayer))
            .addStringTemplate("%unit%", attacker.getLabel())
            .addStringTemplate("%oldName%", defenderLabel)
            .addStringTemplate("%enemyNation%", defenderNation)
            .addStringTemplate("%enemyUnit%", defender.getLabel()));
    cs.addMessage(defenderPlayer,
        new ModelMessage(ModelMessage.MessageType.COMBAT_RESULT,
                         "combat.unitLoseAutoEquip", defender)
            .addStringTemplate("%location%",
                settlement.getLocationLabelFor(defenderPlayer))
            .addStringTemplate("%unit%", defender.getLabel())
            .addStringTemplate("%enemyNation%", attackerNation)
            .addStringTemplate("%enemyUnit%", attacker.getLabel()));
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:45,代碼來源:ServerPlayer.java


注:本文中的net.sf.freecol.common.model.Role.getRequiredGoodsList方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。