Search in sources :

Example 16 with PCAlignment

use of pcgen.core.PCAlignment in project pcgen by PCGen.

the class PCGVer2Parser method parseAlignmentLine.

private void parseAlignmentLine(String line) {
    final String alignment = line.substring(IOConstants.TAG_ALIGNMENT.length() + 1);
    PCAlignment align = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCAlignment.class, alignment);
    if (align != null) {
        if (!RaceAlignment.canBeAlignment(thePC.getRace(), align)) {
            ShowMessageDelegate.showMessageDialog("Invalid alignment. Setting to <none selected>", Constants.APPLICATION_NAME, MessageType.INFORMATION);
            align = getNoAlignment();
        }
        thePC.setAlignment(align);
        return;
    }
    final String message = LanguageBundle.getFormattedString(//$NON-NLS-1$
    "Warnings.PCGenParser.IllegalAlignment", line);
    warnings.add(message);
}
Also used : PCAlignment(pcgen.core.PCAlignment)

Example 17 with PCAlignment

use of pcgen.core.PCAlignment in project pcgen by PCGen.

the class PCGVer2Creator method appendDeityLine.

/*
	 * ###############################################################
	 * Character Deity/Domain methods
	 * ###############################################################
	 */
private void appendDeityLine(StringBuilder buffer) {
    if (charDisplay.getDeity() != null) {
        final Deity aDeity = charDisplay.getDeity();
        buffer.append(IOConstants.TAG_DEITY).append(':');
        buffer.append(EntityEncoder.encode(aDeity.getKeyName()));
        /*
			 * currently unused information
			 *
			 * author: Thomas Behr 09-09-02
			 */
        buffer.append('|');
        buffer.append(IOConstants.TAG_DEITYDOMAINS).append(':');
        buffer.append('[');
        String del = Constants.EMPTY_STRING;
        for (CDOMReference<Domain> ref : aDeity.getSafeListMods(Deity.DOMAINLIST)) {
            for (Domain d : ref.getContainedObjects()) {
                buffer.append(del);
                buffer.append(IOConstants.TAG_DOMAIN).append(':');
                buffer.append(EntityEncoder.encode(d.getKeyName()));
                //$NON-NLS-1$
                del = "|";
            }
        }
        buffer.append(']');
        buffer.append('|');
        buffer.append(IOConstants.TAG_ALIGNALLOW).append(':');
        //TODO Need to clean this up?
        for (final Description desc : aDeity.getSafeListFor(ListKey.DESCRIPTION)) {
            buffer.append('|');
            buffer.append(IOConstants.TAG_DESC).append(':');
            buffer.append(desc.getPCCText());
        }
        buffer.append('|');
        buffer.append(IOConstants.TAG_DEITYFAVWEAP).append(':');
        buffer.append('[');
        List<CDOMReference<WeaponProf>> dwp = aDeity.getListFor(ListKey.DEITYWEAPON);
        if (dwp != null) {
            del = Constants.EMPTY_STRING;
            for (CDOMReference<WeaponProf> ref : dwp) {
                buffer.append(del);
                buffer.append(IOConstants.TAG_WEAPON).append(':');
                buffer.append(EntityEncoder.encode(ref.getLSTformat(false)));
                //$NON-NLS-1$
                del = "|";
            }
        }
        buffer.append(']');
        buffer.append('|');
        buffer.append(IOConstants.TAG_DEITYALIGN).append(':');
        CDOMSingleRef<PCAlignment> al = aDeity.get(ObjectKey.ALIGNMENT);
        if (al != null) {
            buffer.append(al.getLSTformat(false));
        }
        buffer.append(IOConstants.LINE_SEP);
    }
}
Also used : Deity(pcgen.core.Deity) PCAlignment(pcgen.core.PCAlignment) Description(pcgen.core.Description) WeaponProf(pcgen.core.WeaponProf) Domain(pcgen.core.Domain) CDOMReference(pcgen.cdom.base.CDOMReference)

Example 18 with PCAlignment

use of pcgen.core.PCAlignment in project pcgen by PCGen.

the class PreAlignTester method passes.

@Override
public int passes(final Prerequisite prereq, final CharacterDisplay display, CDOMObject source) throws PrerequisiteException {
    //
    // If game mode doesn't support alignment, then pass the prereq
    //
    int runningTotal = 0;
    if (Globals.getGameModeAlignmentText().isEmpty()) {
        runningTotal = 1;
    } else {
        String desiredAlignment = prereq.getKey();
        final PCAlignment charAlignment = display.getPCAlignment();
        if (prereq.getOperator().equals(PrerequisiteOperator.EQ)) {
            if (alignMatches(display, desiredAlignment, charAlignment)) {
                runningTotal++;
            }
        } else if (prereq.getOperator().equals(PrerequisiteOperator.NEQ)) {
            if (!alignMatches(display, desiredAlignment, charAlignment)) {
                runningTotal++;
            }
        } else {
            throw new PrerequisiteException(LanguageBundle.getFormattedString("PreAlign.error.invalidComparison", prereq.getOperator().toString(), //$NON-NLS-1$
            prereq.toString()));
        }
    }
    return countedTotal(prereq, runningTotal);
}
Also used : PrerequisiteException(pcgen.core.prereq.PrerequisiteException) PCAlignment(pcgen.core.PCAlignment)

Example 19 with PCAlignment

use of pcgen.core.PCAlignment in project pcgen by PCGen.

the class Configuration method getAlignmentOptions.

public List<AlignGeneratorOption> getAlignmentOptions() {
    final List<AlignGeneratorOption> ret = new ArrayList<>();
    for (final GeneratorOption opt : theGeneratorOptions) {
        if (opt instanceof AlignGeneratorOption) {
            ret.add((AlignGeneratorOption) opt);
        }
    }
    for (final PCAlignment align : Globals.getContext().getReferenceContext().getOrderSortedCDOMObjects(PCAlignment.class)) {
        boolean included = false;
        for (AlignGeneratorOption option : ret) {
            if (option.getName().equals(align.getDisplayName())) {
                included = true;
                break;
            }
        }
        if (!align.getKeyName().equals(Constants.NONE) && !included) {
            final AlignGeneratorOption opt = new AlignGeneratorOption();
            opt.setName(align.getDisplayName());
            opt.addChoice(1, align.getKeyName());
            ret.add(opt);
        }
    }
    return ret;
}
Also used : PCAlignment(pcgen.core.PCAlignment) ArrayList(java.util.ArrayList)

Aggregations

PCAlignment (pcgen.core.PCAlignment)19 Before (org.junit.Before)3 Deity (pcgen.core.Deity)3 ArrayList (java.util.ArrayList)2 StringTokenizer (java.util.StringTokenizer)2 CDOMReference (pcgen.cdom.base.CDOMReference)2 PCClass (pcgen.core.PCClass)2 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 Test (org.junit.Test)1 Indirect (pcgen.base.util.Indirect)1 WeightedCollection (pcgen.base.util.WeightedCollection)1 FactKey (pcgen.cdom.enumeration.FactKey)1 FactSetKey (pcgen.cdom.enumeration.FactSetKey)1 Gender (pcgen.cdom.enumeration.Gender)1 Ability (pcgen.core.Ability)1 Description (pcgen.core.Description)1 Domain (pcgen.core.Domain)1 Race (pcgen.core.Race)1 WeaponProf (pcgen.core.WeaponProf)1