Search in sources :

Example 31 with Ability

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

the class AbstractGlobalTargetedSaveRestoreTest method testAddAbilityVirtualTarget.

@Test
public void testAddAbilityVirtualTarget() {
    TokenRegistration.register(plugin.bonustokens.SkillRank.class);
    T target = create(getObjectClass(), "Target");
    Ability abil = context.getReferenceContext().constructCDOMObject(Ability.class, "GrantedAbility");
    context.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, abil);
    new plugin.lsttokens.add.AbilityToken().parseToken(context, target, "FEAT|VIRTUAL|GrantedAbility");
    Skill granted = create(Skill.class, "GrantedSkill");
    create(Skill.class, "IgnoredSkill");
    new plugin.lsttokens.choose.SkillToken().parseToken(context, abil, "GrantedSkill|IgnoredSkill");
    new plugin.lsttokens.BonusLst().parseToken(context, abil, "SKILLRANK|%LIST|1");
    abil.put(ObjectKey.MULTIPLE_ALLOWED, true);
    Object o = prepare(target);
    finishLoad();
    assertEquals(0.0f, SkillRankControl.getTotalRank(pc, granted));
    applyObject(target);
    pc.setDirty(true);
    pc.calcActiveBonuses();
    assertEquals(1.0f, SkillRankControl.getTotalRank(pc, granted));
    runRoundRobin(getPreEqualityCleanup());
    assertEquals(1.0f, SkillRankControl.getTotalRank(pc, granted));
    assertEquals(1.0f, SkillRankControl.getTotalRank(reloadedPC, granted));
    remove(o);
    reloadedPC.setDirty(true);
//This fails (see CODE-2387)
//assertEquals(0.0f, SkillRankControl.getTotalRank(reloadedPC, granted));
}
Also used : Ability(pcgen.core.Ability) Skill(pcgen.core.Skill) SkillToken(plugin.lsttokens.choose.SkillToken) CDOMObject(pcgen.cdom.base.CDOMObject) Test(org.junit.Test)

Example 32 with Ability

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

the class AbilityIntegrationTest method testRoundRobinMixed.

@Test
public void testRoundRobinMixed() throws PersistenceLayerException {
    verifyCleanStart();
    Ability ab = primaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil1");
    primaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    ab = secondaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil1");
    secondaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    ab = primaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil2");
    primaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    ab = secondaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil2");
    secondaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    TestContext tc = new TestContext();
    commit(testCampaign, tc, "FEAT|VIRTUAL|.CLEAR.Abil2|Abil1");
    commit(modCampaign, tc, "FEAT|AUTOMATIC|.CLEAR.Abil1|Abil2");
    completeRoundRobin(tc);
}
Also used : Ability(pcgen.core.Ability) TestContext(plugin.lsttokens.editcontext.testsupport.TestContext) Test(org.junit.Test)

Example 33 with Ability

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

the class AbilityIntegrationTest method testRoundRobinClearOrder.

@Test
public void testRoundRobinClearOrder() throws PersistenceLayerException {
    verifyCleanStart();
    Ability ab = primaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil1");
    primaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    ab = secondaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil1");
    secondaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    ab = primaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil2");
    primaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    ab = secondaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil2");
    secondaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    TestContext tc = new TestContext();
    commit(testCampaign, tc, "FEAT|VIRTUAL|.CLEAR", "FEAT|VIRTUAL|Abil1|Abil2");
    commit(modCampaign, tc, "FEAT|VIRTUAL|.CLEAR");
    completeRoundRobin(tc);
}
Also used : Ability(pcgen.core.Ability) TestContext(plugin.lsttokens.editcontext.testsupport.TestContext) Test(org.junit.Test)

Example 34 with Ability

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

the class AbilityIntegrationTest method testRoundRobinNoReset.

@Test
public void testRoundRobinNoReset() throws PersistenceLayerException {
    verifyCleanStart();
    Ability ab = primaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil1");
    primaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    ab = secondaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil1");
    secondaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    ab = primaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil2");
    primaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    ab = secondaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil2");
    secondaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    TestContext tc = new TestContext();
    commit(testCampaign, tc, "FEAT|VIRTUAL|Abil1|Abil2");
    emptyCommit(modCampaign, tc);
    completeRoundRobin(tc);
}
Also used : Ability(pcgen.core.Ability) TestContext(plugin.lsttokens.editcontext.testsupport.TestContext) Test(org.junit.Test)

Example 35 with Ability

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

the class AbilityIntegrationTest method testRoundRobinSimple.

@Test
public void testRoundRobinSimple() throws PersistenceLayerException {
    verifyCleanStart();
    Ability ab = primaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil1");
    primaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    ab = secondaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil1");
    secondaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    ab = primaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil2");
    primaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    ab = secondaryContext.getReferenceContext().constructCDOMObject(Ability.class, "Abil2");
    secondaryContext.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, ab);
    TestContext tc = new TestContext();
    commit(testCampaign, tc, "FEAT|NORMAL|Abil1");
    commit(modCampaign, tc, "FEAT|VIRTUAL|TYPE=TestType");
    completeRoundRobin(tc);
}
Also used : Ability(pcgen.core.Ability) TestContext(plugin.lsttokens.editcontext.testsupport.TestContext) Test(org.junit.Test)

Aggregations

Ability (pcgen.core.Ability)279 CNAbility (pcgen.cdom.content.CNAbility)128 AbilityCategory (pcgen.core.AbilityCategory)60 PlayerCharacter (pcgen.core.PlayerCharacter)54 Test (org.junit.Test)46 ArrayList (java.util.ArrayList)43 CNAbilitySelection (pcgen.cdom.helper.CNAbilitySelection)25 ParseResult (pcgen.rules.persistence.token.ParseResult)21 HashMapToList (pcgen.base.util.HashMapToList)15 PCClass (pcgen.core.PCClass)15 Spell (pcgen.core.spell.Spell)15 StringTokenizer (java.util.StringTokenizer)14 TestContext (plugin.lsttokens.editcontext.testsupport.TestContext)13 LoadContext (pcgen.rules.context.LoadContext)12 SpecialAbility (pcgen.core.SpecialAbility)11 CharacterSpell (pcgen.core.character.CharacterSpell)11 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)11 List (java.util.List)10 CDOMObject (pcgen.cdom.base.CDOMObject)10 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)10