Search in sources :

Example 6 with XMLCombatant

use of plugin.initiative.XMLCombatant 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()));
}
Also used : SystemAttribute(gmgen.plugin.SystemAttribute) PlayerCharacterOutput(gmgen.plugin.PlayerCharacterOutput) PcgCombatant(gmgen.plugin.PcgCombatant) PlayerCharacter(pcgen.core.PlayerCharacter) PCCheck(pcgen.core.PCCheck) XMLCombatant(plugin.initiative.XMLCombatant)

Aggregations

XMLCombatant (plugin.initiative.XMLCombatant)6 PcgCombatant (gmgen.plugin.PcgCombatant)5 InitHolder (gmgen.plugin.InitHolder)3 PlayerCharacter (pcgen.core.PlayerCharacter)2 Combatant (gmgen.plugin.Combatant)1 Event (gmgen.plugin.Event)1 InitHolderList (gmgen.plugin.InitHolderList)1 PlayerCharacterOutput (gmgen.plugin.PlayerCharacterOutput)1 Spell (gmgen.plugin.Spell)1 SystemAttribute (gmgen.plugin.SystemAttribute)1 SystemHP (gmgen.plugin.SystemHP)1 SystemInitiative (gmgen.plugin.SystemInitiative)1 ActionEvent (java.awt.event.ActionEvent)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 JFormattedTextField (javax.swing.JFormattedTextField)1 HyperlinkEvent (javax.swing.event.HyperlinkEvent)1 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1 DefaultFormatter (javax.swing.text.DefaultFormatter)1 NumberFormatter (javax.swing.text.NumberFormatter)1