Search in sources :

Example 56 with Equipment

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

the class PreEquipBothTest method testType.

/**
	 * Test equipment type tests
	 * @throws Exception
	 */
public void testType() throws Exception {
    final PlayerCharacter character = getCharacter();
    final Equipment longsword = new Equipment();
    longsword.setName("Longsword");
    character.addEquipment(longsword);
    longsword.setIsEquipped(true, character);
    longsword.setLocation(EquipmentLocation.EQUIPPED_BOTH);
    character.doAfavorForAunitTestThatIgnoresEquippingRules();
    Prerequisite prereq = new Prerequisite();
    prereq.setKind("equipboth");
    prereq.setKey("TYPE=Weapon");
    prereq.setOperand("1");
    prereq.setOperator(PrerequisiteOperator.EQ);
    assertFalse("Equipment has no type", PrereqHandler.passes(prereq, character, null));
    longsword.addType(Type.WEAPON);
    assertTrue("Equipment is weapon", PrereqHandler.passes(prereq, character, null));
    prereq.setKey("TYPE.Armor");
    assertFalse("Equipment is not armor", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Equipment(pcgen.core.Equipment)

Example 57 with Equipment

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

the class PreEquipBothTest method testWield.

/**
	 * Test wield category tests
	 * @throws Exception
	 */
public void testWield() throws Exception {
    final PlayerCharacter character = getCharacter();
    final Race race = new Race();
    race.setName("Test Race");
    CDOMDirectSingleRef<SizeAdjustment> mediumRef = CDOMDirectSingleRef.getRef(medium);
    CDOMDirectSingleRef<SizeAdjustment> largeRef = CDOMDirectSingleRef.getRef(large);
    race.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
    character.setRace(race);
    LoadContext context = Globals.getContext();
    final Equipment longsword = new Equipment();
    longsword.setName("Longsword");
    character.addEquipment(longsword);
    longsword.setIsEquipped(true, character);
    longsword.setLocation(EquipmentLocation.EQUIPPED_BOTH);
    character.doAfavorForAunitTestThatIgnoresEquippingRules();
    Prerequisite prereq = new Prerequisite();
    prereq.setKind("equipboth");
    prereq.setKey("WIELDCATEGORY=OneHanded");
    prereq.setOperand("1");
    prereq.setOperator(PrerequisiteOperator.EQ);
    // Test 3.0 Style
    longsword.put(ObjectKey.SIZE, mediumRef);
    longsword.put(ObjectKey.BASESIZE, mediumRef);
    assertTrue("Weapon is M therefore OneHanded", PrereqHandler.passes(prereq, character, null));
    longsword.put(ObjectKey.SIZE, largeRef);
    longsword.put(ObjectKey.BASESIZE, largeRef);
    assertFalse("Weapon is L therefore TwoHanded", PrereqHandler.passes(prereq, character, null));
    // Test 3.5 style
    longsword.put(ObjectKey.SIZE, mediumRef);
    longsword.put(ObjectKey.BASESIZE, mediumRef);
    longsword.put(ObjectKey.WIELD, context.getReferenceContext().silentlyGetConstructedCDOMObject(WieldCategory.class, "TwoHanded"));
    assertFalse("Weapon is TwoHanded", PrereqHandler.passes(prereq, character, null));
    longsword.put(ObjectKey.WIELD, context.getReferenceContext().silentlyGetConstructedCDOMObject(WieldCategory.class, "OneHanded"));
    assertTrue("Weapon is OneHanded", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Equipment(pcgen.core.Equipment) Race(pcgen.core.Race) LoadContext(pcgen.rules.context.LoadContext) WieldCategory(pcgen.core.character.WieldCategory) SizeAdjustment(pcgen.core.SizeAdjustment) FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula)

Example 58 with Equipment

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

the class PreEquipPrimaryTest method testType.

/**
	 * Test equipment type tests
	 * @throws Exception
	 */
public void testType() throws Exception {
    final PlayerCharacter character = getCharacter();
    final Equipment longsword = new Equipment();
    longsword.setName("Longsword");
    character.addEquipment(longsword);
    longsword.setIsEquipped(true, character);
    longsword.setLocation(EquipmentLocation.EQUIPPED_PRIMARY);
    character.doAfavorForAunitTestThatIgnoresEquippingRules();
    Prerequisite prereq = new Prerequisite();
    prereq.setKind("equipprimary");
    prereq.setKey("TYPE=Slashing");
    prereq.setOperand("1");
    prereq.setOperator(PrerequisiteOperator.EQ);
    assertFalse("Equipment has no type", PrereqHandler.passes(prereq, character, null));
    longsword.addType(Type.getConstant("SLASHING"));
    assertTrue("Equipment is slashing", PrereqHandler.passes(prereq, character, null));
    prereq.setKey("TYPE.Armor");
    assertFalse("Equipment is not armor", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) Equipment(pcgen.core.Equipment)

Example 59 with Equipment

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

the class SourcedEquipmentFacetTest method getObject.

@Override
protected Equipment getObject() {
    Equipment wp = new Equipment();
    wp.setName("WP" + n++);
    return wp;
}
Also used : Equipment(pcgen.core.Equipment)

Example 60 with Equipment

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

the class UserEquipmentFacetTest method getObject.

@Override
protected Equipment getObject() {
    Equipment wp = new Equipment();
    wp.setName("WP" + n++);
    return wp;
}
Also used : 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