Search in sources :

Example 21 with Campaign

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

the class PreShieldProfTest method testWithFeatThatGrantsBonus.

/**
	 * Test PREPROFWITHSHIELD with a feat that has a bonus tag
	 * 
	 * @throws Exception the exception
	 */
public void testWithFeatThatGrantsBonus() throws Exception {
    final PlayerCharacter character = getCharacter();
    final FeatLoader featLoader = new FeatLoader();
    CampaignSourceEntry cse;
    try {
        cse = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
    } catch (URISyntaxException e) {
        throw new UnreachableError(e);
    }
    int baseHp = character.hitPoints();
    Ability bar = new Ability();
    final String barStr = "Bar	TYPE:General	DESC:See Text	BONUS:HP|CURRENTMAX|50";
    featLoader.parseLine(Globals.getContext(), bar, barStr, cse);
    addAbility(AbilityCategory.FEAT, bar);
    assertEquals("Character should have 50 bonus hp added.", baseHp + 50, character.hitPoints());
    final Ability martialProf = TestHelper.makeAbility("Shield Proficiency (Single)", "FEAT", "General");
    Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "SHIELDPROF|Full Plate");
    assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
    Ability foo = new Ability();
    final String fooStr = "Foo	TYPE:General	DESC:See Text	BONUS:HP|CURRENTMAX|50|PREPROFWITHSHIELD:1,Full Plate";
    featLoader.parseLine(Globals.getContext(), foo, fooStr, cse);
    addAbility(AbilityCategory.FEAT, foo);
    assertEquals("Character has the Full Plate proficiency so the bonus should be added", baseHp + 50 + 50, character.hitPoints());
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) Campaign(pcgen.core.Campaign) FeatLoader(pcgen.persistence.lst.FeatLoader) URISyntaxException(java.net.URISyntaxException) UnreachableError(pcgen.base.lang.UnreachableError) URI(java.net.URI)

Example 22 with Campaign

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

the class PreCampaignTest method buildCampaign.

private Campaign buildCampaign(String key) {
    Campaign camp = new Campaign();
    camp.setKeyName(key);
    camp.setName(key);
    try {
        camp.setSourceURI(new URI("file:/" + key));
    } catch (URISyntaxException e) {
        Logging.errorPrint("PreCampaignTest.buildCampaign failed", e);
        throw new RuntimeException(e);
    }
    Globals.addCampaign(camp);
    return camp;
}
Also used : Campaign(pcgen.core.Campaign) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 23 with Campaign

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

the class ModifyOtherLst method parseTokenWithSeparator.

//MODIFYOTHER:EQUIPMENT|GROUP=Martial|EqCritRange|ADD|1
@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, CDOMObject obj, String value) {
    if (obj instanceof Campaign) {
        return new ParseResult.Fail(getTokenName() + " may not be used in Campaign Files.  " + "Please use the Global Modifier file", context);
    }
    ParsingSeparator sep = new ParsingSeparator(value, '|');
    sep.addGroupingPair('[', ']');
    sep.addGroupingPair('(', ')');
    String scopeName = sep.next();
    /*
		 * Note lvs is implicitly defined as "not global" since the global scope
		 * is "" and thus would have failed the tests imposed by
		 * AbstractTokenWithSeparator
		 */
    final LegalScope lvs = context.getVariableContext().getScope(scopeName);
    if (lvs == null) {
        return new ParseResult.Fail(getTokenName() + " found illegal variable scope: " + scopeName + " as first argument: " + value, context);
    }
    if (!sep.hasNext()) {
        return new ParseResult.Fail(getTokenName() + " needed 2nd argument: " + value, context);
    }
    LoadContext subContext = context.dropIntoContext(lvs.getName());
    return continueParsing(subContext, obj, value, sep);
}
Also used : Campaign(pcgen.core.Campaign) ParsingSeparator(pcgen.base.text.ParsingSeparator) LegalScope(pcgen.base.formula.base.LegalScope) LoadContext(pcgen.rules.context.LoadContext)

Example 24 with Campaign

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

the class RequiredTokenTest 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)

Example 25 with Campaign

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

the class ValueTokenTest 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