Search in sources :

Example 61 with CNAbility

use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.

the class AbstractCNASEnforcingFacetTest method testDifferentSelection.

@Test
public void testDifferentSelection() {
    Object source1 = new Object();
    assertTrue(getFacet().isEmpty(id));
    assertEquals(0, getFacet().getCount(id));
    CNAbility n1 = CNAbilityFactory.getCNAbility(feat, Nature.NORMAL, multyes);
    CNAbility n2 = CNAbilityFactory.getCNAbility(feat, Nature.NORMAL, multyes);
    CNAbilitySelection cnas1 = new CNAbilitySelection(n1, "English");
    CNAbilitySelection cnas2 = new CNAbilitySelection(n2, "German");
    assertTrue(getFacet().add(id, cnas1, source1));
    assertFalse(getFacet().isEmpty(id));
    assertEquals(1, getFacet().getCount(id));
    assertTrue(getFacet().add(id, cnas2, source1));
    assertEquals(2, getFacet().getCount(id));
    assertTrue(getFacet().remove(id, cnas2, source1));
    assertEquals(1, getFacet().getCount(id));
    assertFalse(getFacet().isEmpty(id));
    assertTrue(getFacet().remove(id, cnas1, source1));
    assertEquals(0, getFacet().getCount(id));
    assertTrue(getFacet().isEmpty(id));
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection) Test(org.junit.Test)

Example 62 with CNAbility

use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.

the class AbstractCNASEnforcingFacetTest method testDifferentSelectionAndNature.

@Test
public void testDifferentSelectionAndNature() {
    Object source1 = new Object();
    assertTrue(getFacet().isEmpty(id));
    assertEquals(0, getFacet().getCount(id));
    CNAbility normal = CNAbilityFactory.getCNAbility(feat, Nature.NORMAL, multyes);
    CNAbility virtual = CNAbilityFactory.getCNAbility(feat, Nature.VIRTUAL, multyes);
    CNAbilitySelection cnas1 = new CNAbilitySelection(normal, "English");
    CNAbilitySelection cnas2 = new CNAbilitySelection(virtual, "German");
    assertTrue(getFacet().add(id, cnas1, source1));
    assertFalse(getFacet().isEmpty(id));
    assertEquals(1, getFacet().getCount(id));
    assertTrue(getFacet().add(id, cnas2, source1));
    assertEquals(2, getFacet().getCount(id));
    assertTrue(getFacet().remove(id, cnas2, source1));
    assertEquals(1, getFacet().getCount(id));
    assertFalse(getFacet().isEmpty(id));
    assertTrue(getFacet().remove(id, cnas1, source1));
    assertEquals(0, getFacet().getCount(id));
    assertTrue(getFacet().isEmpty(id));
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection) Test(org.junit.Test)

Example 63 with CNAbility

use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.

the class CNAbilitySelectionUtilitiesTest method testDifferentAbility.

@Test
public void testDifferentAbility() {
    CNAbility nomultCNA = CNAbilityFactory.getCNAbility(feat, Nature.NORMAL, nomult);
    CNAbility othernomultCNA = CNAbilityFactory.getCNAbility(feat, Nature.NORMAL, othernomult);
    CNAbilitySelection cnas1 = new CNAbilitySelection(nomultCNA);
    CNAbilitySelection cnas2 = new CNAbilitySelection(othernomultCNA);
    assertTrue(CNAbilitySelectionUtilities.canCoExist(cnas1, cnas2));
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Test(org.junit.Test)

Example 64 with CNAbility

use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.

the class CNAbilitySelectionUtilitiesTest method testDifferentCategory.

@Test
public void testDifferentCategory() {
    CNAbility nomultCNA = CNAbilityFactory.getCNAbility(feat, Nature.NORMAL, nomult);
    Ability trickster = new Ability();
    trickster.setName("NoMult");
    trickster.setCDOMCategory(specialty);
    CNAbility othernomultCNA = CNAbilityFactory.getCNAbility(specialty, Nature.NORMAL, trickster);
    CNAbilitySelection cnas1 = new CNAbilitySelection(nomultCNA);
    CNAbilitySelection cnas2 = new CNAbilitySelection(othernomultCNA);
    assertTrue(CNAbilitySelectionUtilities.canCoExist(cnas1, cnas2));
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) Test(org.junit.Test)

Example 65 with CNAbility

use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.

the class AbstractCNASEnforcingFacetTest method testDifferentNature.

@Test
public void testDifferentNature() {
    Object source1 = new Object();
    assertTrue(getFacet().isEmpty(id));
    assertEquals(0, getFacet().getCount(id));
    CNAbility normal = CNAbilityFactory.getCNAbility(feat, Nature.NORMAL, nomult);
    CNAbility virtual = CNAbilityFactory.getCNAbility(feat, Nature.VIRTUAL, nomult);
    CNAbilitySelection cnas1 = new CNAbilitySelection(normal);
    CNAbilitySelection cnas2 = new CNAbilitySelection(virtual);
    assertFalse(CNAbilitySelectionUtilities.canCoExist(cnas1, cnas2));
    assertTrue(getFacet().add(id, cnas1, source1));
    assertFalse(getFacet().isEmpty(id));
    assertEquals(1, getFacet().getCount(id));
    assertFalse(getFacet().add(id, cnas2, source1));
    assertEquals(1, getFacet().getCount(id));
    //LIFO
    assertFalse(getFacet().remove(id, cnas2, source1));
    assertEquals(1, getFacet().getCount(id));
    assertFalse(getFacet().isEmpty(id));
    assertTrue(getFacet().remove(id, cnas1, source1));
    assertEquals(0, getFacet().getCount(id));
    assertTrue(getFacet().isEmpty(id));
    assertTrue(getFacet().add(id, cnas1, source1));
    assertFalse(getFacet().isEmpty(id));
    assertEquals(1, getFacet().getCount(id));
    assertFalse(getFacet().add(id, cnas2, source1));
    assertEquals(1, getFacet().getCount(id));
    //FIFO
    assertTrue(getFacet().remove(id, cnas1, source1));
    assertEquals(1, getFacet().getCount(id));
    assertFalse(getFacet().isEmpty(id));
    assertTrue(getFacet().remove(id, cnas2, source1));
    assertEquals(0, getFacet().getCount(id));
    assertTrue(getFacet().isEmpty(id));
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection) Test(org.junit.Test)

Aggregations

CNAbility (pcgen.cdom.content.CNAbility)131 Ability (pcgen.core.Ability)77 ArrayList (java.util.ArrayList)37 CNAbilitySelection (pcgen.cdom.helper.CNAbilitySelection)28 AbilityCategory (pcgen.core.AbilityCategory)26 Test (org.junit.Test)21 HashMapToList (pcgen.base.util.HashMapToList)16 List (java.util.List)15 PlayerCharacter (pcgen.core.PlayerCharacter)9 Language (pcgen.core.Language)7 HashSet (java.util.HashSet)5 Nature (pcgen.cdom.enumeration.Nature)5 SpecialAbility (pcgen.core.SpecialAbility)5 BonusObj (pcgen.core.bonus.BonusObj)5 BigDecimal (java.math.BigDecimal)4 CDOMObject (pcgen.cdom.base.CDOMObject)4 LoadContext (pcgen.rules.context.LoadContext)4 StringTokenizer (java.util.StringTokenizer)3 GenericMapToList (pcgen.base.util.GenericMapToList)3 PCClass (pcgen.core.PCClass)3