Search in sources :

Example 1 with ExportHandler

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 "";
    }
}
Also used : StringWriter(java.io.StringWriter) ExportHandler(pcgen.io.ExportHandler) IOException(java.io.IOException) File(java.io.File) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter)

Example 2 with ExportHandler

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);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) ExportHandler(pcgen.io.ExportHandler) File(java.io.File) Test(org.junit.Test)

Example 3 with ExportHandler

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));
}
Also used : TextToken(plugin.exporttokens.TextToken) PlayerCharacter(pcgen.core.PlayerCharacter) ExportHandler(pcgen.io.ExportHandler)

Example 4 with ExportHandler

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");
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) ExportHandler(pcgen.io.ExportHandler)

Example 5 with ExportHandler

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));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) ExportHandler(pcgen.io.ExportHandler)

Aggregations

ExportHandler (pcgen.io.ExportHandler)31 PlayerCharacter (pcgen.core.PlayerCharacter)24 File (java.io.File)7 BufferedWriter (java.io.BufferedWriter)6 StringWriter (java.io.StringWriter)4 IOException (java.io.IOException)3 TextToken (plugin.exporttokens.TextToken)3 OutputStreamWriter (java.io.OutputStreamWriter)2 Test (org.junit.Test)2 FileOutputStream (java.io.FileOutputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 CharacterFacade (pcgen.facade.core.CharacterFacade)1 ExportException (pcgen.io.ExportException)1 PCGFile (pcgen.io.PCGFile)1