Search in sources :

Example 71 with Campaign

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

the class PreVarTest method test2856622.

public void test2856622() {
    LoadContext context = Globals.getContext();
    final PCClass warrior = new PCClass();
    warrior.setName("Warrior");
    PCClassLevel level1 = warrior.getOriginalClassLevel(1);
    context.unconditionallyProcess(level1, "SAB", "Test Works|PREVARGTEQ:CL,3");
    assertTrue(context.getReferenceContext().resolveReferences(null));
    PlayerCharacter character = this.getCharacter();
    character.incrementClassLevel(1, warrior);
    PCClassLoader loader = new PCClassLoader();
    try {
        SourceEntry se = new CampaignSourceEntry(new Campaign(), new URI("file://test"));
        loader.completeObject(context, se, warrior);
        List<SpecialAbility> sabList = level1.getListFor(ListKey.SAB);
        assertNotNull(sabList);
        assertEquals(1, sabList.size());
        SpecialAbility sab = sabList.get(0);
        assertFalse(sab.qualifies(character, warrior));
        character.incrementClassLevel(1, warrior);
        assertFalse(sab.qualifies(character, warrior));
        character.incrementClassLevel(1, warrior);
        assertTrue(sab.qualifies(character, warrior));
    } catch (URISyntaxException | PersistenceLayerException e) {
        fail(e.getMessage());
    }
}
Also used : SpecialAbility(pcgen.core.SpecialAbility) URISyntaxException(java.net.URISyntaxException) PCClass(pcgen.core.PCClass) URI(java.net.URI) PCClassLevel(pcgen.cdom.inst.PCClassLevel) CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) PersistenceLayerException(pcgen.persistence.PersistenceLayerException) PlayerCharacter(pcgen.core.PlayerCharacter) Campaign(pcgen.core.Campaign) LoadContext(pcgen.rules.context.LoadContext) PCClassLoader(pcgen.persistence.lst.PCClassLoader) SourceEntry(pcgen.persistence.lst.SourceEntry) CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry)

Example 72 with Campaign

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

the class VisionTokenTest method setUp.

/*
	 * @see TestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    final GenericLoader<PCTemplate> loader = new GenericLoader<>(PCTemplate.class);
    final LoadContext context = Globals.getContext();
    CampaignSourceEntry source;
    try {
        source = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
    } catch (URISyntaxException e) {
        throw new UnreachableError(e);
    }
    loader.parseLine(context, null, "Darkvision		VISION:Darkvision (60')", source);
    darkvisionT = context.getReferenceContext().silentlyGetConstructedCDOMObject(PCTemplate.class, "Darkvision");
    loader.parseLine(context, null, "Low-light		VISION:Low-light", source);
    lowlightT = context.getReferenceContext().silentlyGetConstructedCDOMObject(PCTemplate.class, "Low-light");
    loader.parseLine(context, null, "Astral		VISION:Astral (130')", source);
    astralT = context.getReferenceContext().silentlyGetConstructedCDOMObject(PCTemplate.class, "Astral");
    assertTrue(context.getReferenceContext().resolveReferences(null));
    metricUS = new UnitSet();
    metricUS.setName("Metric");
    metricUS.setDistanceUnit("m");
    metricUS.setDistanceFactor(new BigDecimal(0.3));
    metricUS.setDistanceDisplayPattern(new DecimalFormat("#.##"));
    SettingsHandler.getGame().getModeContext().getReferenceContext().importObject(metricUS);
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) DecimalFormat(java.text.DecimalFormat) GenericLoader(pcgen.persistence.lst.GenericLoader) LoadContext(pcgen.rules.context.LoadContext) UnitSet(pcgen.core.UnitSet) URISyntaxException(java.net.URISyntaxException) UnreachableError(pcgen.base.lang.UnreachableError) PCTemplate(pcgen.core.PCTemplate) URI(java.net.URI) BigDecimal(java.math.BigDecimal)

Example 73 with Campaign

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

the class PCBooleanFunctionTest method additionalSetUp.

@Override
protected void additionalSetUp() throws Exception {
    CampaignSourceEntry cse = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
    final FeatLoader featLoader = new FeatLoader();
    fooFeat = new Ability();
    final String fooFeatStr = "Foo	TYPE:General	DEFINE:FooV|0";
    featLoader.parseLine(Globals.getContext(), fooFeat, fooFeatStr, cse);
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Ability(pcgen.core.Ability) Campaign(pcgen.core.Campaign) FeatLoader(pcgen.persistence.lst.FeatLoader) URI(java.net.URI)

Example 74 with Campaign

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

the class PCHasVarFunctionTest method additionalSetUp.

@Override
protected void additionalSetUp() throws Exception {
    CampaignSourceEntry cse = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
    final FeatLoader featLoader = new FeatLoader();
    fooFeat = new Ability();
    final String fooFeatStr = "Foo	TYPE:General	DEFINE:FooV|0";
    featLoader.parseLine(Globals.getContext(), fooFeat, fooFeatStr, cse);
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Ability(pcgen.core.Ability) Campaign(pcgen.core.Campaign) FeatLoader(pcgen.persistence.lst.FeatLoader) URI(java.net.URI)

Example 75 with Campaign

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

the class DisplayNameTokenTest method classSetUp.

@BeforeClass
public static void classSetUp() throws URISyntaxException {
    testCampaign = new CampaignSourceEntry(new Campaign(), new URI("file:/Test%20Case"));
    classSetUpFired = true;
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) URI(java.net.URI) BeforeClass(org.junit.BeforeClass)

Aggregations

Campaign (pcgen.core.Campaign)84 URI (java.net.URI)49 CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)44 URISyntaxException (java.net.URISyntaxException)17 BeforeClass (org.junit.BeforeClass)16 LoadContext (pcgen.rules.context.LoadContext)16 ArrayList (java.util.ArrayList)14 PlayerCharacter (pcgen.core.PlayerCharacter)11 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)11 File (java.io.File)10 PCClass (pcgen.core.PCClass)10 PCClassLoader (pcgen.persistence.lst.PCClassLoader)10 UnreachableError (pcgen.base.lang.UnreachableError)9 Ability (pcgen.core.Ability)9 GameMode (pcgen.core.GameMode)7 SourceEntry (pcgen.persistence.lst.SourceEntry)7 Test (org.junit.Test)6 HashSet (java.util.HashSet)5 CampaignFacade (pcgen.facade.core.CampaignFacade)5 PCGFile (pcgen.io.PCGFile)5