Search in sources :

Example 26 with EquipmentHead

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

the class Equipment method clone.

/**
	 * Description of the Method
	 * 
	 * @return Description of the Return Value
	 */
@Override
public Equipment clone() {
    Equipment eq = null;
    try {
        eq = (Equipment) super.clone();
        eq.heads = new ArrayList<>();
        for (EquipmentHead head : heads) {
            if (head == null) {
                eq.heads.add(null);
            } else {
                EquipmentHead eh = new EquipmentHead(eq, head.getHeadIndex());
                eh.overlayCDOMObject(head);
                eq.heads.add(eh);
            }
        }
        //
        if (bonusMap != null) {
            eq.bonusMap = new HashMap<>(bonusMap);
        }
        eq.setMoveString(moveString());
        // eq.setTypeString(super.getType());
        // none of the types associated with modifiers
        eq.carried = carried;
        eq.equipped = equipped;
        eq.location = location;
        eq.numberEquipped = numberEquipped;
        eq.qty = qty;
        eq.outputIndex = outputIndex;
        eq.d_childTypes = new HashMap<>(d_childTypes);
        eq.d_containedEquipment = new ArrayList<>(d_containedEquipment);
        eq.assocSupt = assocSupt.clone();
        eq.getEquipmentHead(1).removeListFor(ListKey.EQMOD);
        eq.getEquipmentHead(2).removeListFor(ListKey.EQMOD);
        eq.getEquipmentHead(1).addAllToListFor(ListKey.EQMOD, cloneEqModList(eq, true));
        eq.getEquipmentHead(2).addAllToListFor(ListKey.EQMOD, cloneEqModList(eq, false));
    } catch (CloneNotSupportedException e) {
        ShowMessageDelegate.showMessageDialog(e.getMessage(), Constants.APPLICATION_NAME, MessageType.ERROR);
    }
    return eq;
}
Also used : EquipmentHead(pcgen.cdom.inst.EquipmentHead)

Example 27 with EquipmentHead

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

the class Equipment method calcPlusForHead.

/**
	 * Calculates the plus value fo the specified head
	 * 
	 * @param bPrimary Which head is required, the primary (true) or the secondary (false)
	 * @return The plus for the equipment head
	 */
public int calcPlusForHead(boolean bPrimary) {
    int iPlus = 0;
    int headnum = bPrimary ? 1 : 2;
    EquipmentHead head = getEquipmentHeadReference(headnum);
    if (head == null) {
        return iPlus;
    }
    for (EquipmentModifier eqMod : head.getSafeListFor(ListKey.EQMOD)) {
        int iCount = getSelectCorrectedAssociationCount(eqMod);
        if (iCount < 1) {
            iCount = 1;
        }
        iPlus += (iCount * eqMod.getSafe(IntegerKey.PLUS));
    }
    return iPlus;
}
Also used : EquipmentHead(pcgen.cdom.inst.EquipmentHead)

Example 28 with EquipmentHead

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

the class Equipment method calcPlusForCosting.

/**
	 * Calculates the plusForCosting attribute of the Equipment object
	 * 
	 * @return The plusForCosting value
	 */
public int calcPlusForCosting() {
    int iPlus = 0;
    for (EquipmentHead head : heads) {
        for (EquipmentModifier eqMod : head.getSafeListFor(ListKey.EQMOD)) {
            int iCount = getSelectCorrectedAssociationCount(eqMod);
            if (iCount < 1) {
                iCount = 1;
            }
            iPlus += (iCount * eqMod.getSafe(IntegerKey.PLUS));
        }
    }
    return iPlus;
}
Also used : EquipmentHead(pcgen.cdom.inst.EquipmentHead)

Example 29 with EquipmentHead

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

the class ObjectNameDisplayer method toString.

/**
	 * Returns an informative String identifying the VarScoped underlying this
	 * ObjectNameDisplayer
	 *
	 */
@Override
public String toString() {
    Class<? extends VarScoped> objClass = obj.getClass();
    String suffix = null;
    VarScoped object = obj;
    if (EquipmentHead.class.equals(objClass)) {
        EquipmentHead head = (EquipmentHead) obj;
        int index = head.getHeadIndex();
        objClass = Equipment.class;
        object = (Equipment) head.getOwner();
        suffix = "Part: " + index;
    }
    StringBuilder sb = new StringBuilder();
    sb.append(objClass.getSimpleName()).append(" ");
    sb.append(object.getKeyName());
    if (suffix != null) {
        sb.append(" (").append(suffix).append(")");
    }
    return sb.toString();
}
Also used : EquipmentHead(pcgen.cdom.inst.EquipmentHead) VarScoped(pcgen.base.formula.base.VarScoped)

Example 30 with EquipmentHead

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

the class WeaponhToken method getWeaponEquipment.

/**
	 * Create a fake Unarmed Strike equipment so we don't need it in the .lst files anymore
	 *
	 * @param display The character used to generate the size.
	 * @return The Unarmed Strike equipment.
	 */
public static Equipment getWeaponEquipment(CharacterDisplay display) {
    // Creating a fake Unarmed Strike equipment so we
    // don't need it in the .lst files anymore
    WeaponProf wp = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(WeaponProf.class, "Unarmed Strike");
    if (wp == null) {
        wp = new WeaponProf();
        wp.setName(LanguageBundle.getString("Equipment.UnarmedStrike"));
        wp.put(StringKey.KEY_NAME, "Unarmed Strike");
        wp.addToListFor(ListKey.TYPE, Type.SIMPLE);
        Globals.getContext().getReferenceContext().importObject(wp);
    }
    Equipment eq = new Equipment();
    eq.setName(LanguageBundle.getString("Equipment.UnarmedStrike"));
    eq.put(StringKey.KEY_NAME, "KEY_Unarmed Strike");
    eq.put(ObjectKey.WEAPON_PROF, new CDOMDirectSingleRef<>(wp));
    eq.put(StringKey.OUTPUT_NAME, LanguageBundle.getString("Equipment.UnarmedStrike"));
    eq.addType(Type.WEAPON);
    eq.addType(Type.MELEE);
    eq.addType(Type.SIMPLE);
    eq.addType(Type.UNARMED);
    eq.addType(Type.SUBDUAL);
    eq.addType(Type.STANDARD);
    eq.addType(Type.MONK);
    eq.addType(Type.BLUDGEONING);
    WieldCategory lightWC = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(WieldCategory.class, "Light");
    if (lightWC == null) {
    // Error?
    } else {
        eq.put(ObjectKey.WIELD, lightWC);
    }
    eq.put(ObjectKey.COST, BigDecimal.ZERO);
    eq.put(ObjectKey.CURRENT_COST, BigDecimal.ZERO);
    eq.put(ObjectKey.WEIGHT, BigDecimal.ZERO);
    EquipmentHead head = eq.getEquipmentHead(1);
    head.put(StringKey.DAMAGE, "1d1");
    head.put(IntegerKey.CRIT_MULT, 2);
    head.put(IntegerKey.CRIT_RANGE, 1);
    eq.put(ObjectKey.MOD_CONTROL, EqModControl.NO);
    SizeAdjustment sa = display.getSizeAdjustment();
    CDOMDirectSingleRef<SizeAdjustment> ref = CDOMDirectSingleRef.getRef(sa);
    eq.put(ObjectKey.SIZE, ref);
    eq.put(ObjectKey.BASESIZE, ref);
    return eq;
}
Also used : EquipmentHead(pcgen.cdom.inst.EquipmentHead) Equipment(pcgen.core.Equipment) WeaponProf(pcgen.core.WeaponProf) WieldCategory(pcgen.core.character.WieldCategory) SizeAdjustment(pcgen.core.SizeAdjustment)

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