Search in sources :

Example 21 with EquipmentHead

use of pcgen.cdom.inst.EquipmentHead in project pcgen by PCGen.

the class CritrangeToken method unparse.

@Override
public String[] unparse(LoadContext context, Equipment eq) {
    EquipmentHead head = eq.getEquipmentHeadReference(1);
    if (head == null) {
        return null;
    }
    Integer mult = context.getObjectContext().getInteger(head, IntegerKey.CRIT_RANGE);
    if (mult == null) {
        return null;
    }
    if (mult < 0) {
        context.addWriteMessage(getTokenName() + " cannot be negative: " + mult);
        return null;
    }
    return new String[] { mult.toString() };
}
Also used : EquipmentHead(pcgen.cdom.inst.EquipmentHead)

Example 22 with EquipmentHead

use of pcgen.cdom.inst.EquipmentHead in project pcgen by PCGen.

the class AltcritmultToken method unparse.

@Override
public String[] unparse(LoadContext context, Equipment eq) {
    EquipmentHead head = eq.getEquipmentHeadReference(2);
    if (head == null) {
        return null;
    }
    Integer mult = context.getObjectContext().getInteger(head, IntegerKey.CRIT_MULT);
    if (mult == null) {
        return null;
    }
    int multInt = mult.intValue();
    String retString;
    if (multInt == -1) {
        retString = "-";
    } else if (multInt <= 0) {
        context.addWriteMessage(getTokenName() + " cannot be <= 0");
        return null;
    } else {
        retString = "x" + multInt;
    }
    return new String[] { retString };
}
Also used : EquipmentHead(pcgen.cdom.inst.EquipmentHead)

Example 23 with EquipmentHead

use of pcgen.cdom.inst.EquipmentHead in project pcgen by PCGen.

the class AltdamageToken method unparse.

@Override
public String[] unparse(LoadContext context, Equipment eq) {
    EquipmentHead head = eq.getEquipmentHeadReference(2);
    if (head == null) {
        return null;
    }
    String damage = context.getObjectContext().getString(head, StringKey.DAMAGE);
    if (damage == null) {
        return null;
    }
    return new String[] { damage };
}
Also used : EquipmentHead(pcgen.cdom.inst.EquipmentHead)

Example 24 with EquipmentHead

use of pcgen.cdom.inst.EquipmentHead in project pcgen by PCGen.

the class PlayerCharacter method getExpandedWeapons.

/**
	 * Retrieve the expanded list of weapons Expanded weapons include: double
	 * weapons and melee+ranged weapons Output order is assumed Merge of like
	 * equipment depends on the passed in int
	 *
	 * @param merge The type of merge to perform
	 *
	 * @return the sorted list of weapons.
	 */
public List<Equipment> getExpandedWeapons(final int merge) {
    final List<Equipment> weapList = sortEquipmentList(getEquipmentOfType("Weapon", 3), merge);
    //
    for (int idx = 0; idx < weapList.size(); ++idx) {
        final Equipment equip = weapList.get(idx);
        if (equip.isDouble() && (equip.getLocation() == EquipmentLocation.EQUIPPED_TWO_HANDS)) {
            Equipment eqm = equip.clone();
            eqm.removeType(Type.DOUBLE);
            eqm.addType(Type.HEAD1);
            // Add "Head 1 only" to the name of the weapon
            eqm.setWholeItemName(eqm.getName());
            eqm.setName(EquipmentUtilities.appendToName(eqm.getName(), "Head 1 only"));
            if (!eqm.getOutputName().contains("Head 1 only")) {
                eqm.put(StringKey.OUTPUT_NAME, EquipmentUtilities.appendToName(eqm.getOutputName(), "Head 1 only"));
            }
            setProf(equip, eqm);
            weapList.add(idx + 1, eqm);
            eqm = equip.clone();
            final String altType = eqm.getType(false);
            if (!altType.isEmpty()) {
                eqm.removeListFor(ListKey.TYPE);
                for (String s : altType.split("\\.")) {
                    eqm.addType(Type.getConstant(s));
                }
            }
            eqm.removeType(Type.DOUBLE);
            eqm.addType(Type.HEAD2);
            EquipmentHead head = eqm.getEquipmentHead(1);
            String altDamage = eqm.getAltDamage(this);
            if (!altDamage.isEmpty()) {
                head.put(StringKey.DAMAGE, altDamage);
            }
            head.put(IntegerKey.CRIT_MULT, eqm.getAltCritMultiplier());
            head.put(IntegerKey.CRIT_RANGE, eqm.getRawCritRange(false));
            head.removeListFor(ListKey.EQMOD);
            head.addAllToListFor(ListKey.EQMOD, eqm.getEqModifierList(false));
            // Add "Head 2 only" to the name of the weapon
            eqm.setWholeItemName(eqm.getName());
            eqm.setName(EquipmentUtilities.appendToName(eqm.getName(), "Head 2 only"));
            if (!eqm.getOutputName().contains("Head 2 only")) {
                eqm.put(StringKey.OUTPUT_NAME, EquipmentUtilities.appendToName(eqm.getOutputName(), "Head 2 only"));
            }
            setProf(equip, eqm);
            weapList.add(idx + 2, eqm);
        } else //
        if (equip.isMelee() && equip.isRanged()) {
            //
            // Strip off the Ranged portion, set range to 0
            //
            Equipment eqm = equip.clone();
            eqm.addType(Type.BOTH);
            eqm.removeType(Type.RANGED);
            eqm.removeType(Type.THROWN);
            eqm.put(IntegerKey.RANGE, 0);
            setProf(equip, eqm);
            weapList.set(idx, eqm);
            boolean replacedPrimary = primaryWeaponFacet.replace(id, equip, eqm);
            boolean replacedSecondary = secondaryWeaponFacet.replace(id, equip, eqm);
            //
            // Add thrown portion, strip Melee
            //
            Equipment eqr = equip.clone();
            eqr.addType(Type.RANGED);
            eqr.addType(Type.THROWN);
            eqr.addType(Type.BOTH);
            eqr.removeType(Type.MELEE);
            // Add "Thrown" to the name of the weapon
            eqr.setName(EquipmentUtilities.appendToName(eqr.getName(), "Thrown"));
            if (!eqr.getOutputName().contains("Thrown")) {
                eqr.put(StringKey.OUTPUT_NAME, EquipmentUtilities.appendToName(eqr.getOutputName(), "Thrown"));
            }
            setProf(equip, eqr);
            weapList.add(++idx, eqr);
            if (replacedPrimary) {
                primaryWeaponFacet.addAfter(id, eqm, eqr);
            } else if (replacedSecondary) {
                secondaryWeaponFacet.addAfter(id, eqm, eqr);
            }
        }
    }
    return weapList;
}
Also used : EquipmentHead(pcgen.cdom.inst.EquipmentHead)

Example 25 with EquipmentHead

use of pcgen.cdom.inst.EquipmentHead in project pcgen by PCGen.

the class Equipment method removeEqModifier.

/**
	 * Description of the Method
	 * 
	 * @param eqMod
	 *            Description of the Parameter
	 * @param bPrimary
	 *            Description of the Parameter
	 * @param pc
	 *            The PC carrying the item
	 */
public void removeEqModifier(final EquipmentModifier eqMod, final boolean bPrimary, PlayerCharacter pc) {
    final EquipmentModifier aMod = getEqModifierKeyed(eqMod.getKeyName(), bPrimary);
    if (aMod == null) {
        return;
    }
    // Remove the modifier if all associated choices are deleted
    if (!hasAssociations(aMod) || !EquipmentChoiceDriver.getChoice(0, this, aMod, false, pc)) {
        EquipmentHead head = getEquipmentHead(bPrimary ? 1 : 2);
        head.removeFromListFor(ListKey.EQMOD, aMod);
        head.removeVarModifiers(pc.getCharID(), aMod);
        if (bPrimary) {
            usePrimaryCache = false;
        } else {
            useSecondaryCache = false;
        }
        restoreEqModsAfterRemove(pc, eqMod, bPrimary, head);
        setDirty(true);
    }
}
Also used : EquipmentHead(pcgen.cdom.inst.EquipmentHead)

Aggregations

EquipmentHead (pcgen.cdom.inst.EquipmentHead)43 Equipment (pcgen.core.Equipment)10 BigDecimal (java.math.BigDecimal)6 ParseResult (pcgen.rules.persistence.token.ParseResult)6 CDOMObject (pcgen.cdom.base.CDOMObject)5 EqModRef (pcgen.cdom.helper.EqModRef)5 StringTokenizer (java.util.StringTokenizer)4 ScopeInstance (pcgen.base.formula.base.ScopeInstance)4 CharID (pcgen.cdom.enumeration.CharID)4 Type (pcgen.cdom.enumeration.Type)4 ArrayList (java.util.ArrayList)3 VarScoped (pcgen.base.formula.base.VarScoped)3 VarModifier (pcgen.cdom.content.VarModifier)3 EquipmentModifier (pcgen.core.EquipmentModifier)3 TreeSet (java.util.TreeSet)2 Formula (pcgen.base.formula.Formula)2 RemoteModifier (pcgen.cdom.content.RemoteModifier)2 WeaponProf (pcgen.core.WeaponProf)2 BonusObj (pcgen.core.bonus.BonusObj)2 AbstractObjectContext (pcgen.rules.context.AbstractObjectContext)2