Search in sources :

Example 11 with EquipmentModifier

use of pcgen.core.EquipmentModifier in project pcgen by PCGen.

the class CharacterFacadeImpl method hasBeenAdjusted.

private boolean hasBeenAdjusted(Equipment equipItemToAdjust) {
    Set<EquipmentModifier> allEqMods = new HashSet<>(equipItemToAdjust.getEqModifierList(true));
    allEqMods.addAll(equipItemToAdjust.getEqModifierList(false));
    for (EquipmentModifier eqMod : allEqMods) {
        if (!eqMod.isType(Constants.EQMOD_TYPE_BASEMATERIAL)) {
            return true;
        }
    }
    return false;
}
Also used : EquipmentModifier(pcgen.core.EquipmentModifier) HashSet(java.util.HashSet)

Example 12 with EquipmentModifier

use of pcgen.core.EquipmentModifier in project pcgen by PCGen.

the class CharacterFacadeImpl method isQualifiedFor.

@Override
public boolean isQualifiedFor(EquipmentFacade equipFacade, EquipModFacade eqModFacade) {
    if (!(equipFacade instanceof Equipment) || !(eqModFacade instanceof EquipmentModifier)) {
        return false;
    }
    Equipment equip = (Equipment) equipFacade;
    EquipmentModifier eqMod = (EquipmentModifier) eqModFacade;
    //TODO: Handle second head
    return equip.canAddModifier(theCharacter, eqMod, true);
}
Also used : EquipmentModifier(pcgen.core.EquipmentModifier) Equipment(pcgen.core.Equipment)

Example 13 with EquipmentModifier

use of pcgen.core.EquipmentModifier in project pcgen by PCGen.

the class BonusLst method unparse.

@Override
public String[] unparse(LoadContext context, CDOMObject obj) {
    if (obj instanceof EquipmentModifier) {
        // EquipmentModifier bonuses are handled by plugin.lsttokens.equipmentmodifier.BonusToken
        return null;
    }
    Changes<BonusObj> changes = context.getObjectContext().getListChanges(obj, ListKey.BONUS);
    if (changes == null || changes.isEmpty()) {
        // Empty indicates no token present
        return null;
    }
    // CONSIDER need to deal with removed...
    Collection<BonusObj> added = changes.getAdded();
    String tokenName = getTokenName();
    Set<String> bonusSet = new TreeSet<>();
    for (BonusObj bonus : added) {
        if (tokenName.equals(bonus.getTokenSource())) {
            String bonusString = bonus.getLSTformat();
            bonusSet.add(bonusString);
        }
    }
    if (bonusSet.isEmpty()) {
        // This is okay - just no BONUSes from this token
        return null;
    }
    return bonusSet.toArray(new String[bonusSet.size()]);
}
Also used : EquipmentModifier(pcgen.core.EquipmentModifier) BonusObj(pcgen.core.bonus.BonusObj) TreeSet(java.util.TreeSet)

Example 14 with EquipmentModifier

use of pcgen.core.EquipmentModifier in project pcgen by PCGen.

the class ChooseLst method parseNonEmptyToken.

@Override
protected ParseResult parseNonEmptyToken(LoadContext context, CDOMObject obj, String value) {
    if (obj instanceof Ungranted) {
        return new ParseResult.Fail("Cannot use " + getTokenName() + " on an Ungranted object type: " + obj.getClass().getSimpleName(), context);
    }
    if (obj instanceof NonInteractive) {
        return new ParseResult.Fail("Cannot use " + getTokenName() + " on an Non-Interactive object type: " + obj.getClass().getSimpleName(), context);
    }
    String key;
    String val;
    int pipeLoc = value.indexOf(Constants.PIPE);
    if (value.startsWith("FEAT=")) {
        key = "FEATEQ";
        val = value.substring(5);
    } else if (value.startsWith("LANGAUTO:")) {
        key = "LANGAUTO";
        val = value.substring(9);
    } else if (pipeLoc == -1) {
        key = value;
        val = null;
    } else {
        key = value.substring(0, pipeLoc);
        val = value.substring(pipeLoc + 1);
    }
    if (!((obj instanceof Ability) || (obj instanceof Domain) || (obj instanceof Race) || (obj instanceof PCTemplate) || (obj instanceof Skill) || (obj instanceof EquipmentModifier))) {
        //Allow TEMPBONUS related choose
        if (!"NUMBER".equals(key)) {
            return new ParseResult.Fail(getTokenName() + " is not supported for " + obj.getClass().getSimpleName(), context);
        }
    }
    if (key.startsWith("NUMCHOICES=")) {
        String maxCount = key.substring(11);
        if (maxCount == null || maxCount.isEmpty()) {
            return new ParseResult.Fail("NUMCHOICES in CHOOSE must be a formula: " + value, context);
        }
        Formula f = FormulaFactory.getFormulaFor(maxCount);
        if (!f.isValid()) {
            return new ParseResult.Fail("Number of Choices in " + getTokenName() + " was not valid: " + f.toString(), context);
        }
        context.getObjectContext().put(obj, FormulaKey.NUMCHOICES, f);
        pipeLoc = val.indexOf(Constants.PIPE);
        if (pipeLoc == -1) {
            key = val;
            val = null;
        } else {
            key = val.substring(0, pipeLoc);
            val = val.substring(pipeLoc + 1);
        }
    }
    return context.processSubToken(obj, getTokenName(), key, val);
}
Also used : Ability(pcgen.core.Ability) Formula(pcgen.base.formula.Formula) Skill(pcgen.core.Skill) EquipmentModifier(pcgen.core.EquipmentModifier) Race(pcgen.core.Race) NonInteractive(pcgen.cdom.base.NonInteractive) Domain(pcgen.core.Domain) PCTemplate(pcgen.core.PCTemplate) Ungranted(pcgen.cdom.base.Ungranted)

Example 15 with EquipmentModifier

use of pcgen.core.EquipmentModifier in project pcgen by PCGen.

the class ActiveEqModFacetTest method getSourceObject.

@Override
protected Equipment getSourceObject() {
    Equipment e = new Equipment();
    e.setName("e" + n++);
    EquipmentModifier mod = getObject();
    e.addToEqModifierList(mod, true);
    return e;
}
Also used : EquipmentModifier(pcgen.core.EquipmentModifier) Equipment(pcgen.core.Equipment)

Aggregations

EquipmentModifier (pcgen.core.EquipmentModifier)25 Equipment (pcgen.core.Equipment)8 EqModRef (pcgen.cdom.helper.EqModRef)5 StringTokenizer (java.util.StringTokenizer)4 ParseResult (pcgen.rules.persistence.token.ParseResult)4 BigDecimal (java.math.BigDecimal)3 Test (org.junit.Test)3 EquipmentHead (pcgen.cdom.inst.EquipmentHead)3 BonusObj (pcgen.core.bonus.BonusObj)3 EquipSet (pcgen.core.character.EquipSet)3 ArrayList (java.util.ArrayList)2 Formula (pcgen.base.formula.Formula)2 CharID (pcgen.cdom.enumeration.CharID)2 GameMode (pcgen.core.GameMode)2 PCTemplate (pcgen.core.PCTemplate)2 PlayerCharacter (pcgen.core.PlayerCharacter)2 Race (pcgen.core.Race)2 SizeAdjustment (pcgen.core.SizeAdjustment)2 LoadContext (pcgen.rules.context.LoadContext)2 HashSet (java.util.HashSet)1