use of pcgen.core.prereq.Prerequisite in project pcgen by PCGen.
the class PreDeityDomainWriter method specialCase.
@Override
public boolean specialCase(Writer writer, Prerequisite prereq) throws IOException {
PrerequisiteOperator po = getConsolidateMethod(kindHandled(), prereq, false);
if (po == null) {
return false;
}
if (!po.equals(prereq.getOperator())) {
writer.write('!');
}
writer.write("PRE" + kindHandled().toUpperCase() + ':' + (prereq.isOverrideQualify() ? "Q:" : ""));
writer.write(po.equals(PrerequisiteOperator.GTEQ) ? prereq.getOperand() : "1");
for (Prerequisite p : prereq.getPrerequisites()) {
writer.write(',');
writer.write(p.getKey());
}
return true;
}
use of pcgen.core.prereq.Prerequisite in project pcgen by PCGen.
the class PreLevelWriter method specialCase.
/**
* @see pcgen.persistence.lst.output.prereq.AbstractPrerequisiteWriter#specialCase(java.io.Writer writer, pcgen.core.prereq.Prerequisite prereq)
*/
@Override
public boolean specialCase(Writer writer, Prerequisite prereq) throws IOException {
//
if (prereq.getKind() == null) {
//
// ...with exactly 2 entries...
//
List<Prerequisite> prereqList = prereq.getPrerequisites();
if (prereqList.size() == 2) {
//
// ...both of which are PREHD. The first must specify >= and the second <=
//
final Prerequisite elementGTEQ = prereqList.get(0);
final Prerequisite elementLTEQ = prereqList.get(1);
if ("level".equalsIgnoreCase(elementGTEQ.getKind()) && elementGTEQ.getOperator().equals(PrerequisiteOperator.GTEQ) && "level".equalsIgnoreCase(elementLTEQ.getKind()) && elementLTEQ.getOperator().equals(PrerequisiteOperator.LTEQ)) {
if (prereq.getOperator().equals(PrerequisiteOperator.LT)) {
writer.write('!');
}
writer.write("PRELEVEL:" + (prereq.isOverrideQualify() ? "Q:" : ""));
writer.write("MIN=");
writer.write(elementGTEQ.getOperand());
writer.write(",MAX=");
writer.write(elementLTEQ.getOperand());
return true;
}
}
}
return false;
}
use of pcgen.core.prereq.Prerequisite in project pcgen by PCGen.
the class PrereqHandlerTest method testFeatPasses.
/**
* Tests PREFEAT
* @throws PersistenceLayerException
*/
public void testFeatPasses() throws PersistenceLayerException {
final PreParserFactory factory = PreParserFactory.getInstance();
final Prerequisite prereq = factory.parse("!PREFEAT:1,Uncanny Dodge");
final PlayerCharacter pc = getCharacter();
final Race human = new Race();
human.setName("Human");
pc.setRace(human);
assertTrue("No feat should return true", PrereqHandler.passes(prereq, pc, null));
final Ability ud = new Ability();
ud.setName("Uncanny Dodge");
ud.setCDOMCategory(AbilityCategory.FEAT);
ud.put(StringKey.KEY_NAME, "Uncanny Dodge");
addAbility(AbilityCategory.FEAT, ud);
assertFalse("Feat should return false", PrereqHandler.passes(prereq, pc, null));
}
use of pcgen.core.prereq.Prerequisite in project pcgen by PCGen.
the class PreTypeParserTest method testNewStyle.
/**
* @throws Exception
*/
@Test
public void testNewStyle() throws Exception {
PreTypeParser producer = new PreTypeParser();
Prerequisite prereq = producer.parse("TYPE", "1,Mithral,Adamantine,Darkwood", false, false);
System.out.println(prereq.toString());
assertEquals("<prereq operator=\"GTEQ\" operand=\"1\" >\n" + "<prereq kind=\"type\" key=\"Mithral\" operator=\"EQ\" operand=\"1\" >\n" + "</prereq>\n" + "<prereq kind=\"type\" key=\"Adamantine\" operator=\"EQ\" operand=\"1\" >\n" + "</prereq>\n" + "<prereq kind=\"type\" key=\"Darkwood\" operator=\"EQ\" operand=\"1\" >\n" + "</prereq>\n" + "</prereq>\n", prereq.toString());
}
use of pcgen.core.prereq.Prerequisite in project pcgen by PCGen.
the class PreVariableParserTest method testNotEqual.
/**
* @throws Exception
*/
@Test
public void testNotEqual() throws Exception {
PreVariableParser parser = new PreVariableParser();
Prerequisite prereq = parser.parse("VARNEQ", "Enraged,1", false, false);
assertEquals("<prereq kind=\"var\" key=\"Enraged\" operator=\"NEQ\" operand=\"1\" >\n</prereq>\n", prereq.toString());
}
Aggregations