Search in sources :

Example 6 with ExclusiveToken

use of plugin.lsttokens.skill.ExclusiveToken in project pcgen by PCGen.

the class AbstractGlobalTargetedSaveRestoreTest method testGlobalCCSkill.

@Test
public void testGlobalCCSkill() {
    PCClass myclass = create(PCClass.class, "SomeClass");
    new HdToken().parseToken(context, myclass, "8");
    Skill granted = create(Skill.class, "Granted");
    new ExclusiveToken().parseToken(context, granted, "Yes");
    T target = create(getObjectClass(), "Target");
    create(Skill.class, "MySkill");
    new CcskillLst().parseToken(context, target, "Granted");
    Object o = prepare(target);
    finishLoad();
    pc.incrementClassLevel(1, myclass);
    pc.setHP(pc.getActiveClassLevel(myclass, 0), 3);
    assertEquals(SkillCost.EXCLUSIVE, pc.getSkillCostForClass(granted, myclass));
    applyObject(target);
    assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(granted, myclass));
    final Runnable cleanup = getPreEqualityCleanup();
    Runnable fullcleanup = new Runnable() {

        public void run() {
            if (cleanup != null) {
                cleanup.run();
            }
            //TODO need this to create the spell support :/
            PCClass cl = context.getReferenceContext().silentlyGetConstructedCDOMObject(PCClass.class, "SomeClass");
            reloadedPC.getSpellSupport(cl);
        }
    };
    runRoundRobin(fullcleanup);
    assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(granted, myclass));
    assertEquals(SkillCost.CROSS_CLASS, reloadedPC.getSkillCostForClass(granted, myclass));
    remove(o);
    reloadedPC.setDirty(true);
    assertEquals(SkillCost.EXCLUSIVE, reloadedPC.getSkillCostForClass(granted, myclass));
}
Also used : Skill(pcgen.core.Skill) HdToken(plugin.lsttokens.pcclass.HdToken) CDOMObject(pcgen.cdom.base.CDOMObject) PCClass(pcgen.core.PCClass) ExclusiveToken(plugin.lsttokens.skill.ExclusiveToken) CcskillLst(plugin.lsttokens.CcskillLst) Test(org.junit.Test)

Example 7 with ExclusiveToken

use of plugin.lsttokens.skill.ExclusiveToken in project pcgen by PCGen.

the class AbstractGlobalTargetedSaveRestoreTest method testGlobalCCSkillList.

public void testGlobalCCSkillList() {
    PCClass myclass = create(PCClass.class, "SomeClass");
    new HdToken().parseToken(context, myclass, "8");
    Skill granted = create(Skill.class, "Granted");
    new ExclusiveToken().parseToken(context, granted, "Yes");
    T target = create(getObjectClass(), "Target");
    create(Skill.class, "MySkill");
    new CcskillLst().parseToken(context, target, "LIST");
    new SkillToken().parseToken(context, target, "Granted|MySkill");
    additionalChooseSet(target);
    Object o = prepare(target);
    finishLoad();
    pc.incrementClassLevel(1, myclass);
    pc.setHP(pc.getActiveClassLevel(myclass, 0), 3);
    assertEquals(SkillCost.EXCLUSIVE, pc.getSkillCostForClass(granted, myclass));
    applyObject(target);
    assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(granted, myclass));
    final Runnable cleanup = getPreEqualityCleanup();
    Runnable fullcleanup = new Runnable() {

        public void run() {
            if (cleanup != null) {
                cleanup.run();
            }
            //TODO need this to create the spell support :/
            PCClass cl = context.getReferenceContext().silentlyGetConstructedCDOMObject(PCClass.class, "SomeClass");
            reloadedPC.getSpellSupport(cl);
        }
    };
    runRoundRobin(fullcleanup);
    assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(granted, myclass));
    assertEquals(SkillCost.CROSS_CLASS, reloadedPC.getSkillCostForClass(granted, myclass));
    remove(o);
    reloadedPC.setDirty(true);
    if (isSymmetric()) {
        assertEquals(SkillCost.EXCLUSIVE, reloadedPC.getSkillCostForClass(granted, myclass));
    }
}
Also used : Skill(pcgen.core.Skill) HdToken(plugin.lsttokens.pcclass.HdToken) CDOMObject(pcgen.cdom.base.CDOMObject) PCClass(pcgen.core.PCClass) ExclusiveToken(plugin.lsttokens.skill.ExclusiveToken) SkillToken(plugin.lsttokens.choose.SkillToken) CcskillLst(plugin.lsttokens.CcskillLst)

Example 8 with ExclusiveToken

use of plugin.lsttokens.skill.ExclusiveToken in project pcgen by PCGen.

the class AbstractGlobalTargetedSaveRestoreTest method testGlobalCSkill.

@Test
public void testGlobalCSkill() {
    PCClass monclass = create(PCClass.class, "MonClass");
    new HdToken().parseToken(context, monclass, "8");
    new TypeLst().parseToken(context, monclass, "Monster");
    Skill granted = create(Skill.class, "Granted");
    new ExclusiveToken().parseToken(context, granted, "Yes");
    T target = create(getObjectClass(), "Target");
    Skill skill = create(Skill.class, "MySkill");
    new ExclusiveToken().parseToken(context, skill, "Yes");
    new CskillLst().parseToken(context, target, "Granted");
    Object o = prepare(target);
    finishLoad();
    pc.incrementClassLevel(1, monclass);
    pc.setHP(pc.getActiveClassLevel(monclass, 0), 3);
    assertEquals(SkillCost.EXCLUSIVE, pc.getSkillCostForClass(granted, monclass));
    applyObject(target);
    assertEquals(SkillCost.CLASS, pc.getSkillCostForClass(granted, monclass));
    final Runnable cleanup = getPreEqualityCleanup();
    Runnable fullcleanup = new Runnable() {

        public void run() {
            if (cleanup != null) {
                cleanup.run();
            }
            //TODO need this to create the spell support :/
            PCClass cl = context.getReferenceContext().silentlyGetConstructedCDOMObject(PCClass.class, "MonClass");
            reloadedPC.getSpellSupport(cl);
        }
    };
    runRoundRobin(fullcleanup);
    assertEquals(SkillCost.CLASS, pc.getSkillCostForClass(granted, monclass));
    assertEquals(SkillCost.CLASS, reloadedPC.getSkillCostForClass(granted, monclass));
    remove(o);
    reloadedPC.setDirty(true);
    assertEquals(SkillCost.EXCLUSIVE, reloadedPC.getSkillCostForClass(granted, monclass));
}
Also used : Skill(pcgen.core.Skill) CskillLst(plugin.lsttokens.CskillLst) HdToken(plugin.lsttokens.pcclass.HdToken) CDOMObject(pcgen.cdom.base.CDOMObject) PCClass(pcgen.core.PCClass) TypeLst(plugin.lsttokens.TypeLst) ExclusiveToken(plugin.lsttokens.skill.ExclusiveToken) Test(org.junit.Test)

Example 9 with ExclusiveToken

use of plugin.lsttokens.skill.ExclusiveToken in project pcgen by PCGen.

the class PCClassLevelCCSkillTest method testDirect.

@Test
public void testDirect() throws PersistenceLayerException {
    PCClassLevel pcl = dragon.getOriginalClassLevel(1);
    ParseResult result = token.parseToken(context, pcl, "MySkill");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    new ExclusiveToken().parseToken(context, sk, "Yes");
    finishLoad();
    assertEquals(SkillCost.EXCLUSIVE, pc.getSkillCostForClass(sk, dragon));
    classFacet.addClass(id, dragon);
    classFacet.setLevel(id, dragon, 1);
    assertTrue(lscFacet.contains(id, dragon, SkillCost.CROSS_CLASS, sk));
    pc.setDirty(true);
    assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(sk, dragon));
    classFacet.setLevel(id, dragon, 0);
    assertFalse(lscFacet.contains(id, dragon, SkillCost.CROSS_CLASS, sk));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) ExclusiveToken(plugin.lsttokens.skill.ExclusiveToken) PCClassLevel(pcgen.cdom.inst.PCClassLevel) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 10 with ExclusiveToken

use of plugin.lsttokens.skill.ExclusiveToken in project pcgen by PCGen.

the class RaceMonCCSkillTest method testDirect.

@Test
public void testDirect() throws PersistenceLayerException {
    Race source = create(Race.class, "Source");
    ParseResult result = token.parseToken(context, source, "MySkill");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    new ExclusiveToken().parseToken(context, sk, "Yes");
    finishLoad();
    assertEquals(SkillCost.EXCLUSIVE, pc.getSkillCostForClass(sk, dragon));
    raceFacet.directSet(id, source, getAssoc());
    ClassSkillList dragonCSL = context.getReferenceContext().silentlyGetConstructedCDOMObject(ClassSkillList.class, "Dragon");
    assertEquals(SkillCost.EXCLUSIVE, pc.getSkillCostForClass(sk, dragon));
    pc.incrementClassLevel(1, dragon);
    assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(sk, dragon));
    assertTrue(lscFacet.contains(id, dragonCSL, SkillCost.CROSS_CLASS, sk));
    raceFacet.remove(id);
    assertFalse(lscFacet.contains(id, dragonCSL, SkillCost.CROSS_CLASS, sk));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) Race(pcgen.core.Race) ExclusiveToken(plugin.lsttokens.skill.ExclusiveToken) ClassSkillList(pcgen.cdom.list.ClassSkillList) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Aggregations

ExclusiveToken (plugin.lsttokens.skill.ExclusiveToken)12 Test (org.junit.Test)11 PCClass (pcgen.core.PCClass)8 Skill (pcgen.core.Skill)7 ParseResult (pcgen.rules.persistence.token.ParseResult)5 SkillToken (plugin.lsttokens.choose.SkillToken)5 HdToken (plugin.lsttokens.pcclass.HdToken)5 CDOMObject (pcgen.cdom.base.CDOMObject)4 Domain (pcgen.core.Domain)4 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)4 AbstractGlobalTargetedSaveRestoreTest (pcgen.io.testsupport.AbstractGlobalTargetedSaveRestoreTest)3 TypeLst (plugin.lsttokens.TypeLst)3 ClassSource (pcgen.cdom.helper.ClassSource)2 Race (pcgen.core.Race)2 CcskillLst (plugin.lsttokens.CcskillLst)2 CskillLst (plugin.lsttokens.CskillLst)2 PCClassLevel (pcgen.cdom.inst.PCClassLevel)1 ClassSkillList (pcgen.cdom.list.ClassSkillList)1 PCTemplate (pcgen.core.PCTemplate)1 CcskillToken (plugin.lsttokens.domain.CcskillToken)1