Search in sources :

Example 36 with Prerequisite

use of pcgen.core.prereq.Prerequisite 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 37 with Prerequisite

use of pcgen.core.prereq.Prerequisite 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)

Example 38 with Prerequisite

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

the class PreSkillMultWriter 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());
        if (p.getSubKey() != null) {
            writer.write(" (");
            writer.write(p.getSubKey());
            writer.write(")");
        }
        writer.write('=');
        writer.write(p.getOperand());
    }
    return true;
}
Also used : PrerequisiteOperator(pcgen.core.prereq.PrerequisiteOperator) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 39 with Prerequisite

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

the class PreSpellCastWriter 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 == PrerequisiteOperator.GTEQ && !"1".equals(prereq.getOperand())) {
        return false;
    }
    if (po != prereq.getOperator()) {
        writer.write('!');
    }
    writer.write("PRESPELLCAST:" + (prereq.isOverrideQualify() ? "Q:" : ""));
    boolean first = true;
    for (Prerequisite p : prereq.getPrerequisites()) {
        if (!first) {
            writer.write(',');
        }
        writer.write("TYPE=" + p.getKey());
        first = false;
    }
    return true;
}
Also used : PrerequisiteOperator(pcgen.core.prereq.PrerequisiteOperator) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 40 with Prerequisite

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

the class PreSubClassWriter 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

Prerequisite (pcgen.core.prereq.Prerequisite)267 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)62 Test (org.junit.Test)61 PrerequisiteOperator (pcgen.core.prereq.PrerequisiteOperator)50 StringTokenizer (java.util.StringTokenizer)36 ArrayList (java.util.ArrayList)35 StringWriter (java.io.StringWriter)19 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)19 CDOMReference (pcgen.cdom.base.CDOMReference)18 ParseResult (pcgen.rules.persistence.token.ParseResult)18 BonusObj (pcgen.core.bonus.BonusObj)13 TreeSet (java.util.TreeSet)12 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)12 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)10 Domain (pcgen.core.Domain)10 QualifiedObject (pcgen.core.QualifiedObject)10 PrerequisiteWriterInterface (pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface)10 PrerequisiteWriter (pcgen.persistence.lst.output.prereq.PrerequisiteWriter)9 Ungranted (pcgen.cdom.base.Ungranted)8 PrerequisiteException (pcgen.core.prereq.PrerequisiteException)8