use of pcgen.io.ExportHandler in project pcgen by PCGen.
the class VAbilityTokenTest method testAssociated.
/**
* Tests the associated subtoken of VABILITY.
*/
public void testAssociated() {
VAbilityToken tok = new VAbilityToken();
ExportHandler eh = new ExportHandler(null);
PlayerCharacter character = getCharacter();
assertEquals("", tok.getToken("VABILITY.FEAT.0.ASSOCIATED", character, eh));
assertEquals("Bluff,Listen", tok.getToken("VABILITY.FEAT.1.ASSOCIATED", character, eh));
assertEquals("Bluff", tok.getToken("VABILITY.FEAT.1.ASSOCIATED.0", character, eh));
assertEquals("Listen", tok.getToken("VABILITY.FEAT.1.ASSOCIATED.1", character, eh));
}
use of pcgen.io.ExportHandler in project pcgen by PCGen.
the class VAbilityTokenTest method testSingleAspect.
/**
* Tests the ASPECT subtoken of VABILITY with an aspect specified.
*/
public void testSingleAspect() {
VAbilityToken tok = new VAbilityToken();
ExportHandler eh = new ExportHandler(null);
PlayerCharacter character = getCharacter();
assertEquals("Shape: Icosahedron", tok.getToken("VABILITY.FEAT.0.ASPECT.2", character, eh));
assertEquals("20", tok.getToken("VABILITY.FEAT.0.ASPECT.Sides", character, eh));
assertEquals("Green", tok.getToken("VABILITY.FEAT.0.ASPECT.Colour", character, eh));
assertEquals("2000", tok.getToken("VABILITY.FEAT.0.ASPECT.Age In Years", character, eh));
}
use of pcgen.io.ExportHandler in project pcgen by PCGen.
the class VAbilityTokenTest method testAssociatedCount.
/**
* Tests the ASSOCIATEDCOUNT subtoken of VABILITY.
*/
public void testAssociatedCount() {
VAbilityToken tok = new VAbilityToken();
ExportHandler eh = new ExportHandler(null);
PlayerCharacter character = getCharacter();
assertEquals("0", tok.getToken("VABILITY.FEAT.0.ASSOCIATEDCOUNT", character, eh));
assertEquals("2", tok.getToken("VABILITY.FEAT.1.ASSOCIATEDCOUNT", character, eh));
}
use of pcgen.io.ExportHandler in project pcgen by PCGen.
the class BatchExporter method exportParty.
/**
* Write a party sheet for the characters in the party to the outputStream. The party sheet will
* be selected based on the selected game mode and pcgen preferences.
*
* @param party the party to be output
* @param outputStream the stream to output the party sheet to.
* @throws IOException
* @throws ExportException
*/
private static void exportParty(PartyFacade party, OutputStream outputStream) throws IOException, ExportException {
try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"))) {
for (final CharacterFacade character : party) {
File templateFile = getXMLTemplate(character);
character.export(new ExportHandler(templateFile), bw);
}
}
}
use of pcgen.io.ExportHandler in project pcgen by PCGen.
the class BatchExporter method exportCharacterToNonPDF.
/**
* Write a non PDF (e.g. html, text) character sheet for the character to
* the output file. The character sheet will be built according to the
* template file. If the output file exists it will be overwritten.
*
* @param character The already loaded character to be output.
* @param outFile The file to which the character sheet is to be written.
* @param templateFile The file that has the export template definition.
* @return true if the export was successful, false if it failed in some way.
*/
public static boolean exportCharacterToNonPDF(CharacterFacade character, File outFile, File templateFile) {
try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "UTF-8"))) {
character.export(new ExportHandler(templateFile), bw);
character.setDefaultOutputSheet(false, templateFile);
return true;
} catch (final UnsupportedEncodingException e) {
Logging.errorPrint("Unable to create output file " + outFile.getAbsolutePath(), e);
return false;
} catch (final IOException e) {
Logging.errorPrint("Unable to create output file " + outFile.getAbsolutePath(), e);
return false;
} catch (final ExportException e) {
// Error will already be reported to the log
return false;
}
}
Aggregations