use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class PreArmorProfTest method testWithFeatThatGrantsBonus.
/**
* Test Preweaponprof with a feat that has a bonus tag
* This test was written to help find the source of bug 1699779.
*
* @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", "ARMORPROF|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|PREPROFWITHARMOR: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.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class AbstractIntegrationTestCase method classSetUp.
@BeforeClass
public static final void classSetUp() throws URISyntaxException {
OutputDB.reset();
testCampaign = new CampaignSourceEntry(new Campaign(), new URI("file:/Test%20Case"));
modCampaign = new CampaignSourceEntry(new Campaign(), new URI("file:/Test%20Case%20Modifier"));
classSetUpFired = true;
}
use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class CampaignFeatToken method unparse.
@Override
public String[] unparse(LoadContext context, Campaign campaign) {
Changes<CampaignSourceEntry> cseChanges = context.getObjectContext().getListChanges(campaign, ListKey.FILE_FEAT);
Collection<CampaignSourceEntry> added = cseChanges.getAdded();
if (added == null) {
//empty indicates no token
return null;
}
Set<String> set = new TreeSet<>();
for (CampaignSourceEntry cse : added) {
set.add(cse.getLSTformat());
}
return set.toArray(new String[set.size()]);
}
use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class PreCampaignTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
sourceCamp = buildCampaign("Source");
camp1 = buildCampaign("Camp1");
camp2KeyParent = buildCampaign("Camp2");
camp3 = buildCampaign("Camp3");
CampaignSourceEntry cse = new CampaignSourceEntry(camp3, camp3.getSourceURI());
camp2KeyParent.addToListFor(ListKey.FILE_PCC, cse);
camp4Wild = buildCampaign("Camp4");
camp4Wild.addToListFor(ListKey.BOOK_TYPE, "Wild");
camp6TypeParent = buildCampaign("Camp5");
cse = new CampaignSourceEntry(camp4Wild, camp4Wild.getSourceURI());
camp6TypeParent.addToListFor(ListKey.FILE_PCC, cse);
}
use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class LSTConverter method startItem.
private void startItem(final Campaign campaign) {
for (final Loader loader : loaders) {
List<CampaignSourceEntry> files = loader.getFiles(campaign);
for (final CampaignSourceEntry cse : files) {
final URI uri = cse.getURI();
setChanged();
notifyObservers(uri);
if (!"file".equalsIgnoreCase(uri.getScheme())) {
Logging.log(Logging.WARNING, "Skipping campaign " + uri + " from " + campaign.getSourceURI() + " as it is not a local file.");
continue;
}
File in = new File(uri);
// Use canonical name to stop reruns for the same file referred to using ..
URI canonicalUri;
try {
canonicalUri = in.getCanonicalFile().toURI();
} catch (IOException e1) {
Logging.log(Logging.WARNING, "Skipping campaign " + uri + " from " + campaign.getSourceURI() + " as it could not be made canonical. " + e1.getMessage());
continue;
}
if (written.contains(canonicalUri)) {
continue;
}
written.add(canonicalUri);
File base = findSubRoot(rootDir, in);
if (base == null) {
Logging.log(Logging.WARNING, "Skipping campaign " + uri + " from " + campaign.getSourceURI() + " as it is not in the selected source directory.");
continue;
}
String relative = in.toString().substring(base.toString().length() + 1);
if (!in.exists()) {
Logging.log(Logging.WARNING, "Skipping campaign " + uri + " from " + campaign.getSourceURI() + " as it does not exist. Campaign is " + cse.getCampaign().getSourceURI());
continue;
}
File outFile = new File(outDir, File.separator + relative);
if (outFile.exists()) {
Logging.log(Logging.WARNING, "Won't overwrite: " + outFile);
continue;
}
ensureParents(outFile.getParentFile());
try {
changeLogWriter.append("\nProcessing " + in + "\n");
String result = load(uri, loader);
if (result != null) {
Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "UTF-8"));
out.write(result);
out.close();
}
} catch (PersistenceLayerException | IOException | InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
Aggregations