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);
}
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);
}
}
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);
}
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;
}
Aggregations