use of gmgen.plugin.PlayerCharacterOutput in project pcgen by PCGen.
the class SavingThrowDialog method setDefaults.
/**
* <p>
* Sets all field defaults based on the combatant, dc, save type, etc.
* </p>
* @param saveType
*/
private void setDefaults(int saveType) {
int base = 0;
int ability = 0;
int magic = 0;
int misc = 0;
if (cbt instanceof PcgCombatant) {
PcgCombatant pcgcbt = (PcgCombatant) cbt;
PlayerCharacter pc = pcgcbt.getPC();
new PlayerCharacterOutput(pc);
List<PCCheck> checkList = Globals.getContext().getReferenceContext().getOrderSortedCDOMObjects(PCCheck.class);
if (saveType == FORT_SAVE) {
PCCheck fort = checkList.get(0);
base = pc.calculateSaveBonus(fort, "BASE");
ability = pc.calculateSaveBonus(fort, "STATMOD");
magic = pc.calculateSaveBonus(fort, "MAGIC");
misc = pc.calculateSaveBonus(fort, "MISC.NOMAGIC.NOSTAT");
} else if (saveType == REF_SAVE) {
PCCheck ref = checkList.get(1);
base = pc.calculateSaveBonus(ref, "BASE");
ability = pc.calculateSaveBonus(ref, "STATMOD");
magic = pc.calculateSaveBonus(ref, "MAGIC");
misc = pc.calculateSaveBonus(ref, "MISC.NOMAGIC.NOSTAT");
} else if (saveType == WILL_SAVE) {
PCCheck will = checkList.get(2);
base = pc.calculateSaveBonus(will, "BASE");
ability = pc.calculateSaveBonus(will, "STATMOD");
magic = pc.calculateSaveBonus(will, "MAGIC");
misc = pc.calculateSaveBonus(will, "MISC.NOMAGIC.NOSTAT");
}
} else if (cbt instanceof XMLCombatant) {
XMLCombatant xmlcbt = (XMLCombatant) cbt;
if (saveType == FORT_SAVE) {
int mod = new SystemAttribute("Constitution", xmlcbt.getAttribute("Constitution")).getModifier();
ability = mod;
base = xmlcbt.getSave("Fortitude") - mod;
} else if (saveType == REF_SAVE) {
int mod = new SystemAttribute("Dexterity", xmlcbt.getAttribute("Dexterity")).getModifier();
ability = mod;
base = xmlcbt.getSave("Reflex") - mod;
} else if (saveType == WILL_SAVE) {
int mod = new SystemAttribute("Wisdom", xmlcbt.getAttribute("Wisdom")).getModifier();
ability = mod;
base = xmlcbt.getSave("Will") - mod;
}
magic = parseInt(saveMagic.getText());
misc = parseInt(saveMisc.getText());
}
setDefaults(base, ability, magic, misc, parseInt(saveTemp.getText()));
}
Aggregations