Search in sources :

Example 26 with Race

use of pcgen.core.Race 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 27 with Race

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

the class RaceTypeFacetTest method testGetFromRace.

@Test
public void testGetFromRace() {
    Race r = new Race();
    r.put(ObjectKey.RACETYPE, TEST_RACE_TYPE);
    rfacet.set(id, r);
    assertSame(TEST_RACE_TYPE, facet.getRaceType(id));
    rfacet.remove(id);
    assertNull(facet.getRaceType(id));
}
Also used : Race(pcgen.core.Race) Test(org.junit.Test)

Example 28 with Race

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

the class RacialSubTypesFacetTest method testGetFromTemplateOverridesRaceandCMod.

@Test
public void testGetFromTemplateOverridesRaceandCMod() {
    Race r = new Race();
    r.addToListFor(ListKey.RACESUBTYPE, TEST_RACE_TYPE);
    rfacet.set(id, r);
    assertList(facet.getRacialSubTypes(id), TEST_RACE_TYPE);
    PCTemplate t = new PCTemplate();
    t.setName("PCT");
    t.addToListFor(ListKey.RACESUBTYPE, RACE_TYPE_TOO);
    tfacet.add(id, t, this);
    assertList(facet.getRacialSubTypes(id), TEST_RACE_TYPE, RACE_TYPE_TOO);
    PCTemplate t2 = new PCTemplate();
    t2.setName("Other");
    t2.addToListFor(ListKey.RACESUBTYPE, LAST_RACE_TYPE);
    tfacet.add(id, t2, this);
    assertList(facet.getRacialSubTypes(id), TEST_RACE_TYPE, RACE_TYPE_TOO, LAST_RACE_TYPE);
    tfacet.remove(id, t2, this);
    assertList(facet.getRacialSubTypes(id), TEST_RACE_TYPE, RACE_TYPE_TOO);
    tfacet.remove(id, t, this);
    assertList(facet.getRacialSubTypes(id), TEST_RACE_TYPE);
}
Also used : Race(pcgen.core.Race) PCTemplate(pcgen.core.PCTemplate) Test(org.junit.Test)

Example 29 with Race

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

the class LegsFacetTest method testWithNothingInRaceDefault2.

@Test
public void testWithNothingInRaceDefault2() {
    rfacet.set(id, new Race());
    assertEquals(2, facet.getLegs(id));
}
Also used : Race(pcgen.core.Race) Test(org.junit.Test)

Example 30 with Race

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

the class LegsFacetTest method testGetFromTemplate.

@Test
public void testGetFromTemplate() {
    rfacet.set(id, new Race());
    PCTemplate t = new PCTemplate();
    t.put(IntegerKey.LEGS, 5);
    tfacet.add(id, t, this);
    assertEquals(5, facet.getLegs(id));
    tfacet.remove(id, t, this);
    assertEquals(2, facet.getLegs(id));
}
Also used : Race(pcgen.core.Race) PCTemplate(pcgen.core.PCTemplate) Test(org.junit.Test)

Aggregations

Race (pcgen.core.Race)167 Test (org.junit.Test)78 PCTemplate (pcgen.core.PCTemplate)66 PlayerCharacter (pcgen.core.PlayerCharacter)28 CDOMObject (pcgen.cdom.base.CDOMObject)16 LoadContext (pcgen.rules.context.LoadContext)16 PCClass (pcgen.core.PCClass)15 ArrayList (java.util.ArrayList)10 SizeAdjustment (pcgen.core.SizeAdjustment)10 ParseResult (pcgen.rules.persistence.token.ParseResult)10 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)10 PCStat (pcgen.core.PCStat)9 FixedSizeFormula (pcgen.cdom.formula.FixedSizeFormula)8 Equipment (pcgen.core.Equipment)8 BonusObj (pcgen.core.bonus.BonusObj)7 Formula (pcgen.base.formula.Formula)6 WieldCategory (pcgen.core.character.WieldCategory)6 GameMode (pcgen.core.GameMode)5 Skill (pcgen.core.Skill)5 CompanionList (pcgen.cdom.list.CompanionList)4