use of pcgen.io.ExportHandler in project pcgen by PCGen.
the class VAbilityTokenTest method testName.
/**
* Tests the name subtoken of VABILITY.
*/
public void testName() {
VAbilityToken tok = new VAbilityToken();
ExportHandler eh = new ExportHandler(null);
PlayerCharacter character = getCharacter();
assertEquals("Perform (Dance)", tok.getToken("VABILITY.FEAT.0.NAME", character, eh));
assertEquals("Skill Focus", tok.getToken("VABILITY.FEAT.1.NAME", character, eh));
}
use of pcgen.io.ExportHandler in project pcgen by PCGen.
the class VariableProcessor method getExportVariable.
/**
* Returns a float value representing a variable used by the
* export process, for example, any token that is used in an outputsheet.
*
* @param valString The name of the token to process. i.e. "LOCK.CON"
* @return The evaluated value of valString as a String.
*/
public String getExportVariable(String valString) {
final StringWriter sWriter = new StringWriter();
final BufferedWriter aWriter = new BufferedWriter(sWriter);
final ExportHandler aExport = new ExportHandler(new File(""));
aExport.replaceTokenSkipMath(pc, valString, aWriter);
sWriter.flush();
try {
aWriter.flush();
} catch (IOException e) {
Logging.errorPrint("Couldn't flush the StringWriter used in PlayerCharacter.getVariableValue.", e);
}
final String bString = sWriter.toString();
String result;
try {
// Float values
result = String.valueOf(Float.parseFloat(bString));
} catch (NumberFormatException e) {
// String values
result = bString;
}
return result;
}
use of pcgen.io.ExportHandler in project pcgen by PCGen.
the class PCHasVarFunctionTest 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(""));
PCHasVarFunction pchv = new PCHasVarFunction(pc, eh);
Boolean result = (Boolean) pchv.exec(Collections.singletonList("FooV"));
assertFalse("Should not have var", result);
addAbility(AbilityCategory.FEAT, fooFeat);
pc.calcActiveBonuses();
assertTrue("Should have var FooV", pc.hasVariable("FooV"));
result = (Boolean) pchv.exec(Collections.singletonList("FooV"));
assertTrue("PCHasVar could not see FooV", result);
}
use of pcgen.io.ExportHandler in project pcgen by PCGen.
the class TextTokenTest method testNumSuffix.
/**
* Test the output for negative numbers with fractions.
*/
public void testNumSuffix() {
TextToken tok = new TextToken();
ExportHandler eh = new ExportHandler(null);
PlayerCharacter character = getCharacter();
character.setPCAttribute(NumericPCAttribute.AGE, 1);
assertEquals("Suffix 1", "st", tok.getToken("TEXT.NUMSUFFIX.AGE", getCharacter(), eh));
character.setPCAttribute(NumericPCAttribute.AGE, 2);
assertEquals("Suffix 2", "nd", tok.getToken("TEXT.NUMSUFFIX.AGE", getCharacter(), eh));
character.setPCAttribute(NumericPCAttribute.AGE, 3);
assertEquals("Suffix 3", "rd", tok.getToken("TEXT.NUMSUFFIX.AGE", getCharacter(), eh));
character.setPCAttribute(NumericPCAttribute.AGE, 4);
assertEquals("Suffix 4", "th", tok.getToken("TEXT.NUMSUFFIX.AGE", getCharacter(), eh));
character.setPCAttribute(NumericPCAttribute.AGE, 11);
assertEquals("Suffix 11", "th", tok.getToken("TEXT.NUMSUFFIX.AGE", getCharacter(), eh));
character.setPCAttribute(NumericPCAttribute.AGE, 12);
assertEquals("Suffix 12", "th", tok.getToken("TEXT.NUMSUFFIX.AGE", getCharacter(), eh));
character.setPCAttribute(NumericPCAttribute.AGE, 13);
assertEquals("Suffix 13", "th", tok.getToken("TEXT.NUMSUFFIX.AGE", getCharacter(), eh));
character.setPCAttribute(NumericPCAttribute.AGE, 14);
assertEquals("Suffix 14", "th", tok.getToken("TEXT.NUMSUFFIX.AGE", getCharacter(), eh));
character.setPCAttribute(NumericPCAttribute.AGE, 21);
assertEquals("Suffix 21", "st", tok.getToken("TEXT.NUMSUFFIX.AGE", getCharacter(), eh));
character.setPCAttribute(NumericPCAttribute.AGE, 22);
assertEquals("Suffix 22", "nd", tok.getToken("TEXT.NUMSUFFIX.AGE", getCharacter(), eh));
character.setPCAttribute(NumericPCAttribute.AGE, 23);
assertEquals("Suffix 23", "rd", tok.getToken("TEXT.NUMSUFFIX.AGE", getCharacter(), eh));
character.setPCAttribute(NumericPCAttribute.AGE, 24);
assertEquals("Suffix 24", "th", tok.getToken("TEXT.NUMSUFFIX.AGE", getCharacter(), eh));
character.setPCAttribute(NumericPCAttribute.AGE, 133);
assertEquals("Suffix 133", "rd", tok.getToken("TEXT.NUMSUFFIX.AGE", getCharacter(), eh));
}
use of pcgen.io.ExportHandler in project pcgen by PCGen.
the class TextTokenTest method testNumSuffixDirect.
/**
* Test the output for negative numbers with fractions.
*/
public void testNumSuffixDirect() {
TextToken tok = new TextToken();
ExportHandler eh = new ExportHandler(null);
assertEquals("Suffix 1", "st", tok.getToken("TEXT.NUMSUFFIX.1", getCharacter(), eh));
assertEquals("Suffix 2", "nd", tok.getToken("TEXT.NUMSUFFIX.2", getCharacter(), eh));
assertEquals("Suffix 3", "rd", tok.getToken("TEXT.NUMSUFFIX.3", getCharacter(), eh));
assertEquals("Suffix 4", "th", tok.getToken("TEXT.NUMSUFFIX.4", getCharacter(), eh));
assertEquals("Suffix 12", "th", tok.getToken("TEXT.NUMSUFFIX.12", getCharacter(), eh));
assertEquals("Suffix 133", "rd", tok.getToken("TEXT.NUMSUFFIX.133", getCharacter(), eh));
assertEquals("Suffix 133", "rd", tok.getToken("TEXT.NUMSUFFIX.133.0", getCharacter(), eh));
}
Aggregations