Search in sources :

Example 1 with Load

use of pcgen.util.enumeration.Load in project pcgen by PCGen.

the class PlayerCharacter method processOldAcCheck.

/**
	 * Calculate the ACCHECK bonus from equipped items. Extracted from
	 * modToFromEquipment.
	 *
	 * TODO Penalty for load could/should be GameMode specific?
	 *
	 * @return PC's ACCHECK bonus from equipment
	 * @deprecated due to PCACCHECK code control
	 */
@Deprecated
public int processOldAcCheck() {
    Load load = getHouseRuledLoadType();
    int bonus = 0;
    int penaltyForLoad = (load == Load.MEDIUM) ? -3 : (load == Load.HEAVY) ? -6 : 0;
    final IdentityList<Equipment> vEqList = new IdentityList<>(tempBonusItemList);
    for (Equipment eq : getEquippedEquipmentSet()) {
        // Do not count virtual items created by temporary bonuses
        if (!vEqList.contains(eq)) {
            bonus += EqToken.getAcCheckTokenInt(this, eq);
        }
    }
    bonus = Math.min(bonus, penaltyForLoad);
    bonus += (int) getTotalBonusTo("MISC", "ACCHECK");
    return bonus;
}
Also used : Load(pcgen.util.enumeration.Load) IdentityList(pcgen.base.util.IdentityList)

Example 2 with Load

use of pcgen.util.enumeration.Load in project pcgen by PCGen.

the class PlayerCharacter method processOldMaxDex.

/**
	 * Calculate the MAXDEX bonus taking account of equipped items. Extracted
	 * from modToFromEquipment.
	 *
	 * @return MAXDEX bonus
	 * @deprecated due to PCMAXDEX code control
	 */
@Deprecated
public int processOldMaxDex() {
    final int statBonus = (int) getStatBonusTo("MISC", "MAXDEX");
    final Load load = getHouseRuledLoadType();
    int bonus = (load == Load.MEDIUM) ? 3 : (load == Load.HEAVY) ? 1 : (load == Load.OVERLOAD) ? 0 : statBonus;
    // If this is still true after all the equipment has been
    // examined, then we should use the Maximum - Maximum Dex modifier.
    boolean useMax = (load == Load.LIGHT);
    for (Equipment eq : getEquippedEquipmentSet()) {
        final int potentialMax = EqToken.getMaxDexTokenInt(this, eq);
        if (potentialMax != Constants.MAX_MAXDEX) {
            if (useMax || bonus > potentialMax) {
                bonus = potentialMax;
            }
            useMax = false;
        }
    }
    if (useMax) {
        bonus = Constants.MAX_MAXDEX;
    }
    bonus += ((int) getTotalBonusTo("MISC", "MAXDEX") - statBonus);
    if (bonus < 0) {
        bonus = 0;
    } else if (bonus > Constants.MAX_MAXDEX) {
        bonus = Constants.MAX_MAXDEX;
    }
    return bonus;
}
Also used : Load(pcgen.util.enumeration.Load)

Example 3 with Load

use of pcgen.util.enumeration.Load in project pcgen by PCGen.

the class BaseMovementToken method getToken.

/**
	 * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler)
	 */
@Override
public String getToken(String tokenSource, CharacterDisplay display, ExportHandler eh) {
    String retString = "";
    if ((display.getRace() != null) && !display.getRace().equals(Globals.s_EMPTYRACE)) {
        StringTokenizer aTok = new StringTokenizer(tokenSource, ".", false);
        //clear BASEMOVEMENT Token
        aTok.nextToken();
        String moveType = "WALK";
        Load load = Load.LIGHT;
        boolean flag = true;
        //Move Type
        if (aTok.hasMoreElements()) {
            moveType = aTok.nextToken();
            try {
                int movNum = Integer.parseInt(moveType);
                if (movNum < display.getNumberOfMovements()) {
                    moveType = display.getMovementValues().get(movNum).getName();
                }
            } catch (NumberFormatException e) {
            // Delibrately ignore exception, means movetype is not an index
            }
        }
        //Encumberance Level
        if (aTok.hasMoreElements()) {
            String loadName = aTok.nextToken();
            for (Load aLoad : Load.values()) {
                if (loadName.equals(aLoad.toString())) {
                    load = aLoad;
                }
            }
        }
        //Display Movement Measurement type?
        if (aTok.hasMoreElements()) {
            flag = "TRUE".equalsIgnoreCase(aTok.nextToken());
        }
        retString = getBaseMovementToken(display, moveType, load, flag);
    }
    return retString;
}
Also used : StringTokenizer(java.util.StringTokenizer) Load(pcgen.util.enumeration.Load)

Example 4 with Load

use of pcgen.util.enumeration.Load in project pcgen by PCGen.

the class Equipment method moveString.

/**
	 * Process and return a movement string
	 * 
	 * @return the Movement string
	 */
public String moveString() {
    if (!moveString.isEmpty()) {
        final Load eqLoad;
        if (isHeavy()) {
            eqLoad = Load.HEAVY;
        } else if (isMedium()) {
            eqLoad = Load.MEDIUM;
        } else if (isLight()) {
            eqLoad = Load.LIGHT;
        } else {
            eqLoad = Load.OVERLOAD;
        }
        //
        // This will generate a list for base moves 30,20
        // or 60,50,40 depending on how many tokens are
        // in the original tag
        //
        final StringTokenizer aTok = new StringTokenizer(moveString, ",");
        int baseMove = -1;
        int tokenCount = aTok.countTokens();
        switch(tokenCount) {
            case 2:
                baseMove = 30;
                break;
            case 3:
                baseMove = 60;
                break;
            default:
                tokenCount = -1;
                break;
        }
        if (tokenCount > 0) {
            final StringBuilder retString = new StringBuilder(moveString.length());
            for (int i = 0; i < tokenCount; ++i) {
                if (i != 0) {
                    retString.append(',');
                }
                retString.append(Globals.calcEncumberedMove(eqLoad, baseMove));
                baseMove -= 10;
            }
            return retString.toString();
        }
    }
    return moveString;
}
Also used : Load(pcgen.util.enumeration.Load) StringTokenizer(java.util.StringTokenizer)

Example 5 with Load

use of pcgen.util.enumeration.Load in project pcgen by PCGen.

the class EquipInfoTab method setLoadLabel.

/**
	 */
public void setLoadLabel(String text) {
    // bold / highlight text based on encumbrance value
    Font font = loadLabel.getFont();
    Color color = UIPropertyContext.getQualifiedColor();
    Load encumbrance = Load.getLoadType(text);
    switch(encumbrance) {
        case MEDIUM:
            font = FontManipulation.bold(font);
            color = UIPropertyContext.getAutomaticColor();
            break;
        case HEAVY:
            font = FontManipulation.bold_italic(font);
            color = UIPropertyContext.getVirtualColor();
            break;
        case OVERLOAD:
            font = FontManipulation.bold_italic(font);
            color = UIPropertyContext.getNotQualifiedColor();
            break;
        default:
            font = FontManipulation.plain(font);
    }
    loadLabel.setText(text);
    loadLabel.setFont(font);
    loadLabel.setForeground(color);
}
Also used : Load(pcgen.util.enumeration.Load) Color(java.awt.Color) Font(java.awt.Font)

Aggregations

Load (pcgen.util.enumeration.Load)12 CDOMObject (pcgen.cdom.base.CDOMObject)4 StringTokenizer (java.util.StringTokenizer)3 PCTemplate (pcgen.core.PCTemplate)2 Race (pcgen.core.Race)2 Color (java.awt.Color)1 Font (java.awt.Font)1 IdentityList (pcgen.base.util.IdentityList)1 Ungranted (pcgen.cdom.base.Ungranted)1 ParseResult (pcgen.rules.persistence.token.ParseResult)1