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());
}
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;
}
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);
}
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;
}
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;
}
Aggregations