use of pcgen.io.ExportHandler in project pcgen by PCGen.
the class PlayerCharacterOutput method getExportToken.
String getExportToken(String token) {
try {
StringWriter retWriter = new StringWriter();
BufferedWriter bufWriter = new BufferedWriter(retWriter);
ExportHandler export = new ExportHandler(new File(""));
export.replaceTokenSkipMath(pc, token, bufWriter);
retWriter.flush();
try {
bufWriter.flush();
} catch (IOException e) {
// TODO - Handle Exception
}
return retWriter.toString();
} catch (Exception e) {
System.out.println("Failure fetching token: " + token);
return "";
}
}
use of pcgen.io.ExportHandler in project pcgen by PCGen.
the class PCBooleanFunctionTest method testExec.
/**
* Test method for {@link pcgen.io.freemarker.PCBooleanFunction#exec(java.util.List)}.
* @throws Exception
*/
@Test
public void testExec() throws Exception {
PlayerCharacter pc = getCharacter();
ExportHandler eh = new ExportHandler(new File(""));
PCBooleanFunction pcbf = new PCBooleanFunction(pc, eh);
Boolean result = (Boolean) pcbf.exec(Collections.singletonList("VAR.VARDEFINED:FooV"));
assertFalse("Should not have var", result);
addAbility(AbilityCategory.FEAT, fooFeat);
pc.calcActiveBonuses();
assertTrue("Should have var FooV", pc.hasVariable("FooV"));
result = (Boolean) pcbf.exec(Collections.singletonList("VAR.VARDEFINED:FooV"));
assertTrue("PCBoolean could not see FooV", result);
}
use of pcgen.io.ExportHandler in project pcgen by PCGen.
the class TextTokenTest method testTextFormatting.
/**
* Test the output for positive numbers with fractions.
*/
public void testTextFormatting() {
TextToken tok = new TextToken();
ExportHandler eh = new ExportHandler(null);
PlayerCharacter character = getCharacter();
assertEquals("TEXT.LOWER.NAME", "the vitamins are in my fresh brussels sprouts", tok.getToken("TEXT.LOWER.NAME", character, eh));
assertEquals("TEXT.UPPER.NAME", "THE VITAMINS ARE IN MY FRESH BRUSSELS SPROUTS", tok.getToken("TEXT.UPPER.NAME", character, eh));
assertEquals("TEXT.SENTENCE.NAME", "The vitamins are in my fresh brussels sprouts", tok.getToken("TEXT.SENTENCE.NAME", character, eh));
assertEquals("TEXT.SENTENCE.NAME", "The vitamins are in my fresh brussels sprouts", tok.getToken("TEXT.SENTENCE.NAME", character, eh));
character.setPCAttribute(PCAttribute.NAME, "The Vitamins are in my Fresh Brussels Sprouts");
assertEquals("TEXT.SENTENCE.INTERESTS", "One potatoe. Two potatoe. More", tok.getToken("TEXT.SENTENCE.INTERESTS", character, eh));
assertEquals("TEXT.TITLE.NAME", "The Vitamins Are In My Fresh Brussels Sprouts", tok.getToken("TEXT.TITLE.NAME", getCharacter(), eh));
assertEquals("TEXT.TITLE.NAME", "One Potatoe. Two Potatoe. More", tok.getToken("TEXT.TITLE.INTERESTS", character, eh));
}
use of pcgen.io.ExportHandler in project pcgen by PCGen.
the class AbilityListTokenTest method testCategory.
/**
* Test the output for negative numbers with fractions.
*/
public void testCategory() {
AbilityListToken tok = new AbilityListToken();
ExportHandler eh = new ExportHandler(null);
PlayerCharacter character = getCharacter();
is(tok.getToken("ABILITYLIST.BARDIC", character, eh), strEq("Perform (Dance)"), "ABILITYLIST.BARDIC");
}
use of pcgen.io.ExportHandler in project pcgen by PCGen.
the class AbilityTokenTest method testAssociatedCount.
/**
* Tests the ASSOCIATEDCOUNT subtoken of ABILITY.
*/
public void testAssociatedCount() {
AbilityToken tok = new AbilityToken();
ExportHandler eh = new ExportHandler(null);
PlayerCharacter character = getCharacter();
assertEquals("0", tok.getToken("ABILITY.FEAT.0.ASSOCIATEDCOUNT", character, eh));
assertEquals("2", tok.getToken("ABILITY.FEAT.1.ASSOCIATEDCOUNT", character, eh));
}
Aggregations