use of pcgen.persistence.PersistenceLayerException in project pcgen by PCGen.
the class AddFeatToken method parseNonEmptyToken.
@Override
protected ParseResult parseNonEmptyToken(LoadContext context, CDOMObject obj, String value) {
ParsingSeparator sep = new ParsingSeparator(value, '|');
sep.addGroupingPair('[', ']');
sep.addGroupingPair('(', ')');
String addType = sep.next();
if (!"FEAT".equals(addType)) {
return new ParseResult.Fail("Incompatible with ADD:FEAT:" + value);
}
String activeValue = sep.next();
Formula count;
if (!sep.hasNext()) {
count = FormulaFactory.ONE;
} else {
count = FormulaFactory.getFormulaFor(activeValue);
if (!count.isValid()) {
return new ParseResult.Fail("Count in " + getTokenName() + " was not valid: " + count.toString(), context);
}
if (count.isStatic() && count.resolveStatic().doubleValue() <= 0) {
return new ParseResult.Fail("Count in ADD:FEAT must be > 0", context);
}
activeValue = sep.next();
}
if (sep.hasNext()) {
return new ParseResult.Fail("ADD:FEAT had too many pipe separated items: " + value, context);
}
try {
if (!context.processToken(obj, "ADD", "ABILITY|" + count.toString() + "|FEAT|NORMAL|" + activeValue)) {
Logging.replayParsedMessages();
return new ParseResult.Fail("Delegation Error from ADD:FEAT");
}
} catch (PersistenceLayerException e) {
return new ParseResult.Fail("Delegation Error from ADD:FEAT: " + e.getLocalizedMessage());
}
return ParseResult.SUCCESS;
}
use of pcgen.persistence.PersistenceLayerException in project pcgen by PCGen.
the class AddVFeatToken method parseNonEmptyToken.
@Override
protected ParseResult parseNonEmptyToken(LoadContext context, CDOMObject obj, String value) {
ParsingSeparator sep = new ParsingSeparator(value, '|');
sep.addGroupingPair('[', ']');
sep.addGroupingPair('(', ')');
String addType = sep.next();
if (!"VFEAT".equals(addType)) {
return new ParseResult.Fail("Incompatible with ADD:VFEAT: " + value);
}
String activeValue = sep.next();
Formula count;
if (!sep.hasNext()) {
count = FormulaFactory.ONE;
} else {
count = FormulaFactory.getFormulaFor(activeValue);
if (!count.isValid()) {
return new ParseResult.Fail("Count in " + getTokenName() + " was not valid: " + count.toString(), context);
}
if (count.isStatic() && count.resolveStatic().doubleValue() <= 0) {
return new ParseResult.Fail("Count in ADD:VFEAT must be > 0", context);
}
activeValue = sep.next();
}
if (sep.hasNext()) {
return new ParseResult.Fail("ADD:VFEAT had too many pipe separated items: " + value, context);
}
try {
if (!context.processToken(obj, "ADD", "ABILITY|" + count.toString() + "|FEAT|VIRTUAL|" + activeValue)) {
Logging.replayParsedMessages();
return new ParseResult.Fail("Delegation Error from ADD:VFEAT");
}
} catch (PersistenceLayerException e) {
return new ParseResult.Fail("Delegation Error from ADD:VFEAT: " + e.getLocalizedMessage());
}
return ParseResult.SUCCESS;
}
use of pcgen.persistence.PersistenceLayerException in project pcgen by PCGen.
the class PreEquipSecondaryWriter method write.
/**
* @see pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface#write(java.io.Writer, pcgen.core.prereq.Prerequisite)
*/
@Override
public void write(Writer writer, Prerequisite prereq) throws PersistenceLayerException {
checkValidOperator(prereq, operatorsHandled());
try {
if (prereq.getOperator().equals(PrerequisiteOperator.LT)) {
writer.write('!');
}
writer.write("PREEQUIPSECONDARY:" + (prereq.isOverrideQualify() ? "Q:" : ""));
writer.write(prereq.getOperand());
writer.write(',');
writer.write(prereq.getKey());
} catch (IOException e) {
throw new PersistenceLayerException(e.getMessage());
}
}
use of pcgen.persistence.PersistenceLayerException in project pcgen by PCGen.
the class PreCityWriter method write.
/**
* @see pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface#write(java.io.Writer, pcgen.core.prereq.Prerequisite)
*/
@Override
public void write(Writer writer, Prerequisite prereq) throws PersistenceLayerException {
checkValidOperator(prereq, operatorsHandled());
try {
if (prereq.getOperator().equals(PrerequisiteOperator.NEQ)) {
writer.write('!');
}
writer.write("PRECITY:" + (prereq.isOverrideQualify() ? "Q:" : ""));
writer.write(prereq.getKey());
} catch (IOException e) {
throw new PersistenceLayerException(e.getMessage());
}
}
use of pcgen.persistence.PersistenceLayerException in project pcgen by PCGen.
the class PreClassWriter method write.
/**
* @see pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface#write(java.io.Writer, pcgen.core.prereq.Prerequisite)
*/
@Override
public void write(Writer writer, Prerequisite prereq) throws PersistenceLayerException {
checkValidOperator(prereq, operatorsHandled());
try {
if (prereq.getOperator() == PrerequisiteOperator.LT) {
writer.write('!');
}
writer.write("PRECLASS:" + (prereq.isOverrideQualify() ? "Q:" : "") + "1,");
writer.write(prereq.getKey());
writer.write('=');
writer.write(prereq.getOperand());
} catch (IOException e) {
throw new PersistenceLayerException(e.getMessage());
}
}
Aggregations