Search in sources :

Example 81 with Skill

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

the class LocalAddedSkillCostFacetTest method testRemoveUselessClass.

@Test
public void testRemoveUselessClass() {
    Skill t1 = getObject();
    assertFalse(getFacet().contains(id, class1, SkillCost.CLASS, t1));
    getFacet().add(id, class1, SkillCost.CLASS, t1, source1);
    getFacet().add(id, class2, SkillCost.CLASS, t1, source1);
    assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
    assertFalse(getFacet().contains(id, class1, SkillCost.CROSS_CLASS, t1));
    assertTrue(getFacet().contains(id, class2, SkillCost.CLASS, t1));
    //No cross pollution
    getFacet().remove(id, class3, SkillCost.CLASS, t1, source1);
    assertTrue(getFacet().contains(id, class2, SkillCost.CLASS, t1));
    getFacet().remove(id, class2, SkillCost.CLASS, t1, source1);
    assertFalse(getFacet().contains(id, class2, SkillCost.CLASS, t1));
    assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
    getFacet().remove(id, class1, SkillCost.CLASS, t1, source1);
    assertFalse(getFacet().contains(id, class1, SkillCost.CLASS, t1));
}
Also used : Skill(pcgen.core.Skill) Test(org.junit.Test)

Example 82 with Skill

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

the class LocalAddedSkillCostFacetTest method testAddTwoClasses.

@Test
public void testAddTwoClasses() {
    Skill t1 = getObject();
    Skill t2 = getObject();
    assertFalse(getFacet().contains(id, class1, SkillCost.CLASS, t1));
    getFacet().add(id, class1, SkillCost.CLASS, t1, source1);
    assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
    assertFalse(getFacet().contains(id, class1, SkillCost.CLASS, t2));
    assertFalse(getFacet().contains(id, class1, SkillCost.CROSS_CLASS, t1));
    assertFalse(getFacet().contains(id, class2, SkillCost.CLASS, t1));
    assertFalse(getFacet().contains(id, class2, SkillCost.CLASS, t2));
    //No cross pollution
    assertFalse(getFacet().contains(altid, class1, SkillCost.CLASS, t1));
    getFacet().add(id, class2, SkillCost.CLASS, t2, source1);
    assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
    assertFalse(getFacet().contains(id, class1, SkillCost.CLASS, t2));
    assertFalse(getFacet().contains(id, class1, SkillCost.CROSS_CLASS, t1));
    assertTrue(getFacet().contains(id, class2, SkillCost.CLASS, t2));
    assertFalse(getFacet().contains(id, class2, SkillCost.CLASS, t1));
    //No cross pollution
    assertFalse(getFacet().contains(altid, class1, SkillCost.CLASS, t1));
    assertFalse(getFacet().contains(altid, class2, SkillCost.CLASS, t2));
}
Also used : Skill(pcgen.core.Skill) Test(org.junit.Test)

Example 83 with Skill

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

the class LocalAddedSkillCostFacetTest method testRemoveUselessSkill.

@Test
public void testRemoveUselessSkill() {
    Skill t1 = getObject();
    getFacet().add(id, class1, SkillCost.CLASS, t1, source1);
    //Just don't throw an exception
    getFacet().remove(id, class1, SkillCost.CLASS, getAltObject(), source1);
}
Also used : Skill(pcgen.core.Skill) Test(org.junit.Test)

Example 84 with Skill

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

the class LocalAddedSkillCostFacetTest method testAddMultGet.

@Test
public void testAddMultGet() {
    Skill t1 = getObject();
    assertFalse(getFacet().contains(id, class1, SkillCost.CLASS, t1));
    getFacet().add(id, class1, SkillCost.CLASS, t1, source1);
    assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
    assertFalse(getFacet().contains(id, class1, SkillCost.CROSS_CLASS, t1));
    //No cross pollution
    assertFalse(getFacet().contains(altid, class1, SkillCost.CLASS, t1));
    Skill t2 = getAltObject();
    //Second add doesn't change anything
    getFacet().add(id, class1, SkillCost.CROSS_CLASS, t2, source1);
    assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
    assertTrue(getFacet().contains(id, class1, SkillCost.CROSS_CLASS, t2));
    assertFalse(getFacet().contains(id, class1, SkillCost.CLASS, t2));
    //No cross pollution
    assertFalse(getFacet().contains(altid, class1, SkillCost.CROSS_CLASS, t2));
}
Also used : Skill(pcgen.core.Skill) Test(org.junit.Test)

Example 85 with Skill

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

the class PreVarTest method test2857848c.

public void test2857848c() {
    final PCClass warrior = new PCClass();
    warrior.setName("Warrior");
    LoadContext context = Globals.getContext();
    context.unconditionallyProcess(warrior, "DEFINE", "MyVar|0");
    context.unconditionallyProcess(warrior, "BONUS", "VAR|MyVar|2");
    final PCClass notawarrior = new PCClass();
    notawarrior.setName("NotAWarrior");
    context.unconditionallyProcess(notawarrior, "PREVARGTEQ", "MyVar,1");
    Skill concentration = context.getReferenceContext().constructCDOMObject(Skill.class, "Concentration");
    context.unconditionallyProcess(notawarrior, "CSKILL", "Concentration");
    context.unconditionallyProcess(notawarrior, "BONUS", "SKILL|Concentration|5");
    assertTrue(context.getReferenceContext().resolveReferences(null));
    PCClassLoader loader = new PCClassLoader();
    try {
        SourceEntry se = new CampaignSourceEntry(new Campaign(), new URI("file://test"));
        loader.completeObject(context, se, warrior);
        loader.completeObject(context, se, notawarrior);
        PlayerCharacter character = this.getCharacter();
        assertFalse(notawarrior.qualifies(character, notawarrior));
        //Fails
        character.incrementClassLevel(1, notawarrior);
        assertEquals(0, SkillModifier.modifier(concentration, character).intValue());
        character.incrementClassLevel(1, warrior);
        assertEquals(0, SkillModifier.modifier(concentration, character).intValue());
        assertTrue(notawarrior.qualifies(character, notawarrior));
        character.incrementClassLevel(1, notawarrior);
        assertEquals(5, SkillModifier.modifier(concentration, character).intValue());
    } catch (URISyntaxException | PersistenceLayerException e) {
        fail(e.getMessage());
    }
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) PersistenceLayerException(pcgen.persistence.PersistenceLayerException) Skill(pcgen.core.Skill) Campaign(pcgen.core.Campaign) PlayerCharacter(pcgen.core.PlayerCharacter) LoadContext(pcgen.rules.context.LoadContext) PCClassLoader(pcgen.persistence.lst.PCClassLoader) SourceEntry(pcgen.persistence.lst.SourceEntry) CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) URISyntaxException(java.net.URISyntaxException) PCClass(pcgen.core.PCClass) URI(java.net.URI)

Aggregations

Skill (pcgen.core.Skill)165 Test (org.junit.Test)60 PCClass (pcgen.core.PCClass)55 ArrayList (java.util.ArrayList)29 CDOMReference (pcgen.cdom.base.CDOMReference)24 CharID (pcgen.cdom.enumeration.CharID)23 SkillCost (pcgen.cdom.enumeration.SkillCost)16 CDOMObject (pcgen.cdom.base.CDOMObject)15 PlayerCharacter (pcgen.core.PlayerCharacter)14 ChoiceSet (pcgen.cdom.base.ChoiceSet)13 ConcretePersistentTransitionChoice (pcgen.cdom.base.ConcretePersistentTransitionChoice)13 ReferenceChoiceSet (pcgen.cdom.choiceset.ReferenceChoiceSet)13 ClassSkillChoiceActor (pcgen.cdom.helper.ClassSkillChoiceActor)13 StringTokenizer (java.util.StringTokenizer)10 ObjectMatchingReference (pcgen.cdom.reference.ObjectMatchingReference)10 Ability (pcgen.core.Ability)10 LoadContext (pcgen.rules.context.LoadContext)9 ClassSkillList (pcgen.cdom.list.ClassSkillList)8 HashSet (java.util.HashSet)7 CNAbility (pcgen.cdom.content.CNAbility)7