Search in sources :

Example 6 with PrerequisiteOperator

use of pcgen.core.prereq.PrerequisiteOperator in project pcgen by PCGen.

the class PreSpellSchoolSubWriter method specialCase.

@Override
public boolean specialCase(Writer writer, Prerequisite prereq) throws IOException {
    PrerequisiteOperator po = getConsolidateMethod(kindHandled(), prereq, true);
    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());
        writer.write('=');
        writer.write(p.getOperand());
    }
    return true;
}
Also used : PrerequisiteOperator(pcgen.core.prereq.PrerequisiteOperator) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 7 with PrerequisiteOperator

use of pcgen.core.prereq.PrerequisiteOperator in project pcgen by PCGen.

the class PreSpellTypeWriter 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 {
    PrerequisiteOperator po = getConsolidateMethod(kindHandled(), prereq, true);
    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());
        writer.write('=');
        writer.write(p.getOperand());
    }
    return true;
}
Also used : PrerequisiteOperator(pcgen.core.prereq.PrerequisiteOperator) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 8 with PrerequisiteOperator

use of pcgen.core.prereq.PrerequisiteOperator in project pcgen by PCGen.

the class PreSpellSchoolWriter method specialCase.

@Override
public boolean specialCase(Writer writer, Prerequisite prereq) throws IOException {
    PrerequisiteOperator po = getConsolidateMethod(kindHandled(), prereq, true);
    if (po == null) {
        return false;
    }
    if (po != prereq.getOperator()) {
        writer.write('!');
    }
    writer.write("PRE" + kindHandled().toUpperCase() + ':' + (prereq.isOverrideQualify() ? "Q:" : ""));
    writer.write(po == PrerequisiteOperator.GTEQ ? prereq.getOperand() : "1");
    for (Prerequisite p : prereq.getPrerequisites()) {
        writer.write(',');
        writer.write(p.getKey());
        writer.write('=');
        writer.write(p.getOperand());
    }
    return true;
}
Also used : PrerequisiteOperator(pcgen.core.prereq.PrerequisiteOperator) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 9 with PrerequisiteOperator

use of pcgen.core.prereq.PrerequisiteOperator in project pcgen by PCGen.

the class PreTypeWriter method specialCase.

@Override
public boolean specialCase(Writer writer, Prerequisite prereq) throws IOException {
    // If this is NOT a PREMULT... fail
    if (prereq.getKind() != null) {
        return false;
    }
    PrerequisiteOperator oper = null;
    for (Prerequisite p : prereq.getPrerequisites()) {
        //
        if (!"1".equals(p.getOperand())) {
            return false;
        }
        //
        if (!kindHandled().equalsIgnoreCase(p.getKind())) {
            return false;
        }
        //
        if (oper == null) {
            oper = p.getOperator();
        } else {
            if (!oper.equals(p.getOperator())) {
                return false;
            }
        }
    }
    String count = prereq.getOperand();
    if (PrerequisiteOperator.NEQ.equals(oper)) {
        try {
            int i = Integer.parseInt(count);
            if (prereq.getPrerequisiteCount() != i) {
                return false;
            }
        } catch (NumberFormatException e) {
            return false;
        }
    } else if (!PrerequisiteOperator.EQ.equals(oper)) {
        return false;
    }
    if (!PrerequisiteOperator.GTEQ.equals(prereq.getOperator()) ^ !PrerequisiteOperator.EQ.equals(oper)) {
        writer.write('!');
    }
    writer.write("PRE" + kindHandled().toUpperCase() + ':' + (prereq.isOverrideQualify() ? "Q:" : ""));
    writer.write(oper.equals(PrerequisiteOperator.EQ) ? prereq.getOperand() : "1");
    for (Prerequisite p : prereq.getPrerequisites()) {
        writer.write(',');
        writer.write(p.getKey());
    }
    return true;
}
Also used : PrerequisiteOperator(pcgen.core.prereq.PrerequisiteOperator) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 10 with PrerequisiteOperator

use of pcgen.core.prereq.PrerequisiteOperator in project pcgen by PCGen.

the class PreShieldProfWriter 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;
}
Also used : PrerequisiteOperator(pcgen.core.prereq.PrerequisiteOperator) Prerequisite(pcgen.core.prereq.Prerequisite)

Aggregations

PrerequisiteOperator (pcgen.core.prereq.PrerequisiteOperator)52 Prerequisite (pcgen.core.prereq.Prerequisite)50 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)2 IOException (java.io.IOException)1