Search in sources :

Example 41 with Equipment

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

the class ActiveEqModFacet method dataAdded.

/**
	 * Adds the EqMods associated with a piece of Equipment which is equipped by
	 * a Player Character.
	 * 
	 * Triggered when one of the Facets to which ActiveEqModFacet listens fires
	 * a DataFacetChangeEvent to indicate a piece of Equipment was equipped by a
	 * Player Character.
	 * 
	 * @param dfce
	 *            The DataFacetChangeEvent containing the information about the
	 *            change
	 * 
	 * @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
	 */
@Override
public void dataAdded(DataFacetChangeEvent<CharID, Equipment> dfce) {
    /*
		 * In theory, this doesn't need to check for additions/removals from the
		 * EqMod list, because such changes can't happen to equipment that is
		 * currently equipped by the PC (new equipment is a clone, not the
		 * original item)
		 */
    CharID id = dfce.getCharID();
    Equipment eq = dfce.getCDOMObject();
    for (EquipmentModifier eqMod : eq.getEqModifierList(true)) {
        add(id, eqMod, eq);
    }
    for (EquipmentModifier eqMod : eq.getEqModifierList(false)) {
        add(id, eqMod, eq);
    }
}
Also used : EquipmentModifier(pcgen.core.EquipmentModifier) Equipment(pcgen.core.Equipment) CharID(pcgen.cdom.enumeration.CharID)

Example 42 with Equipment

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

the class PreShieldProfTest method setUp.

/**
	 * @see pcgen.AbstractCharacterTestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    Equipment heavySteelShield = new Equipment();
    heavySteelShield.setName("Heavy Steel Shield");
    heavySteelShield.addToListFor(ListKey.TYPE, Type.getConstant("Shield"));
    heavySteelShield.addToListFor(ListKey.TYPE, Type.getConstant("Heavy"));
    Globals.getContext().getReferenceContext().importObject(heavySteelShield);
    Equipment heavyWoodenShield = new Equipment();
    heavyWoodenShield.setName("Heavy Wooden Shield");
    heavyWoodenShield.addToListFor(ListKey.TYPE, Type.getConstant("Shield"));
    heavyWoodenShield.addToListFor(ListKey.TYPE, Type.getConstant("Heavy"));
    Globals.getContext().getReferenceContext().importObject(heavyWoodenShield);
    Equipment lightWoodenShield = new Equipment();
    lightWoodenShield.setName("Light Steel Shield");
    lightWoodenShield.addToListFor(ListKey.TYPE, Type.getConstant("Shield"));
    lightWoodenShield.addToListFor(ListKey.TYPE, Type.getConstant("Light"));
    Globals.getContext().getReferenceContext().importObject(lightWoodenShield);
    Equipment fullPlateEq = new Equipment();
    fullPlateEq.setName("Full Plate");
    fullPlateEq.addToListFor(ListKey.TYPE, Type.getConstant("Shield"));
    fullPlateEq.addToListFor(ListKey.TYPE, Type.getConstant("Heavy"));
    Globals.getContext().getReferenceContext().importObject(fullPlateEq);
    ShieldProf fullPlate = new ShieldProf();
    fullPlate.setName("Full Plate");
    fullPlate.addToListFor(ListKey.TYPE, Type.getConstant("Heavy"));
    Globals.getContext().getReferenceContext().importObject(fullPlate);
    ShieldProf lightWood = new ShieldProf();
    lightWood.setName("Light Wooden Shield");
    lightWood.addToListFor(ListKey.TYPE, Type.getConstant("Light"));
    Globals.getContext().getReferenceContext().importObject(lightWood);
    ShieldProf heavyWood = new ShieldProf();
    heavyWood.setName("Heavy Wooden Shield");
    heavyWood.addToListFor(ListKey.TYPE, Type.getConstant("Heavy"));
    Globals.getContext().getReferenceContext().importObject(heavyWood);
    ShieldProf heavySteel = new ShieldProf();
    heavySteel.setName("Heavy Steel Shield");
    heavySteel.addToListFor(ListKey.TYPE, Type.getConstant("Heavy"));
    Globals.getContext().getReferenceContext().importObject(heavySteel);
}
Also used : ShieldProf(pcgen.core.ShieldProf) Equipment(pcgen.core.Equipment)

Example 43 with Equipment

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

the class PreEquipSecondaryTest method testNotEquipped.

/**
	 * Verify that negated PREEQUIPSECONDARY tests work.
	 */
public void testNotEquipped() throws Exception {
    final PlayerCharacter character = getCharacter();
    final Equipment longsword = new Equipment();
    longsword.setName("Longsword");
    final Equipment dagger = new Equipment();
    dagger.setName("Dagger");
    character.addEquipment(longsword);
    longsword.setIsEquipped(true, character);
    longsword.setLocation(EquipmentLocation.EQUIPPED_SECONDARY);
    character.doAfavorForAunitTestThatIgnoresEquippingRules();
    final Prerequisite prereqDaggerNotSec = PreParserFactory.getInstance().parse("!PREEQUIPSECONDARY:1,Dagger");
    assertTrue("Dagger not equipped", PrereqHandler.passes(prereqDaggerNotSec, character, null));
    character.addEquipment(dagger);
    dagger.setIsEquipped(true, character);
    dagger.setLocation(EquipmentLocation.EQUIPPED_PRIMARY);
    assertTrue("Dagger not equipped", PrereqHandler.passes(prereqDaggerNotSec, character, null));
    final Prerequisite prereqLongswordNotSec = PreParserFactory.getInstance().parse("!PREEQUIPSECONDARY:1,Longsword");
    assertFalse("Longsword equipped", PrereqHandler.passes(prereqLongswordNotSec, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Equipment(pcgen.core.Equipment)

Example 44 with Equipment

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

the class PreEquipTest method testPassesPrerequisitePlayerCharacter.

/*
	 * Class under test for int passes(Prerequisite, PlayerCharacter)
	 */
public void testPassesPrerequisitePlayerCharacter() {
    final PlayerCharacter character = getCharacter();
    final Equipment longsword = new Equipment();
    longsword.setName("Longsword");
    character.addEquipment(longsword);
    longsword.setIsEquipped(true, character);
    character.doAfavorForAunitTestThatIgnoresEquippingRules();
    final Prerequisite prereq = new Prerequisite();
    prereq.setKind("equip");
    prereq.setKey("LONGSWORD");
    prereq.setOperand("1");
    prereq.setOperator(PrerequisiteOperator.EQ);
    final boolean passes = PrereqHandler.passes(prereq, character, null);
    assertTrue(passes);
    longsword.setName("Longsword (Masterwork)");
    assertFalse("Should be an exact match only", PrereqHandler.passes(prereq, character, null));
    prereq.setKey("LONGSWORD%");
    assertTrue("Should be allow wildcard match", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Equipment(pcgen.core.Equipment)

Example 45 with Equipment

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

the class PreEquipTwoWeaponTest method testPassesPrerequisitePlayerCharacter.

/*
	 * Class under test for int passes(Prerequisite, PlayerCharacter)
	 */
public void testPassesPrerequisitePlayerCharacter() {
    final PlayerCharacter character = getCharacter();
    final Equipment longsword = new Equipment();
    longsword.setName("Longsword");
    character.addEquipment(longsword);
    longsword.setIsEquipped(true, character);
    longsword.setLocation(EquipmentLocation.EQUIPPED_TWO_HANDS);
    character.doAfavorForAunitTestThatIgnoresEquippingRules();
    final Prerequisite prereq = new Prerequisite();
    prereq.setKind("equiptwoweapon");
    prereq.setKey("LONGSWORD");
    prereq.setOperand("1");
    prereq.setOperator(PrerequisiteOperator.EQ);
    final boolean passes = PrereqHandler.passes(prereq, character, null);
    assertTrue(passes);
    longsword.setName("Longsword (Large/Masterwork)");
    assertFalse("Should be an exact match only", PrereqHandler.passes(prereq, character, null));
    prereq.setKey("LONGSWORD (LARGE%");
    assertTrue("Should allow wildcard match", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Equipment(pcgen.core.Equipment)

Aggregations

Equipment (pcgen.core.Equipment)166 PlayerCharacter (pcgen.core.PlayerCharacter)41 ArrayList (java.util.ArrayList)28 StringTokenizer (java.util.StringTokenizer)25 EquipSet (pcgen.core.character.EquipSet)22 CDOMObject (pcgen.cdom.base.CDOMObject)20 LoadContext (pcgen.rules.context.LoadContext)15 SizeAdjustment (pcgen.core.SizeAdjustment)11 EquipmentHead (pcgen.cdom.inst.EquipmentHead)10 WeaponProf (pcgen.core.WeaponProf)10 CharID (pcgen.cdom.enumeration.CharID)9 WieldCategory (pcgen.core.character.WieldCategory)9 CDOMReference (pcgen.cdom.base.CDOMReference)8 ArmorProf (pcgen.core.ArmorProf)8 EquipmentModifier (pcgen.core.EquipmentModifier)8 Race (pcgen.core.Race)8 ShieldProf (pcgen.core.ShieldProf)8 BonusObj (pcgen.core.bonus.BonusObj)8 Test (org.junit.Test)7 ScopeInstance (pcgen.base.formula.base.ScopeInstance)7