Search in sources :

Example 6 with InitHolder

use of gmgen.plugin.InitHolder in project pcgen by PCGen.

the class Initiative method getUnSelected.

/**
	 *  Looks at each line in the table, and returns an ArrayList of lines that are not Selected.
	 *
	 *@return    An ArrayList of currently selected InitHolders
	 */
private List<InitHolder> getUnSelected() {
    final List<InitHolder> retList = new ArrayList<>();
    int j = -1;
    for (int i = 0; i < combatantTable.getRowCount(); i++) {
        j++;
        InitHolder iH = initList.get(j);
        if ((iH.getStatus() == State.Dead) && !showDead.isSelected()) {
            i--;
            continue;
        }
        if ((iH instanceof Event) && !showEvents.isSelected()) {
            i--;
            continue;
        }
        if (!combatantTable.isRowSelected(i)) {
            retList.add(iH);
        }
    }
    return retList;
}
Also used : ArrayList(java.util.ArrayList) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ActionEvent(java.awt.event.ActionEvent) Event(gmgen.plugin.Event) InitHolder(gmgen.plugin.InitHolder)

Example 7 with InitHolder

use of gmgen.plugin.InitHolder in project pcgen by PCGen.

the class Initiative method doHeal.

//** End Functions implementing button calls for the bottom toolbar **
//** Functions called by dialogs **
/**
	 *  Do an amount of healing to the selected combatants
	 *
	 *@param  heal  The amount of healing to do
	 */
private void doHeal(int heal) {
    final List<InitHolder> selectedList = getSelected();
    while (!selectedList.isEmpty()) {
        InitHolder iH = selectedList.remove(0);
        if (iH instanceof Combatant) {
            Combatant cbt = (Combatant) iH;
            cbt.heal(heal);
            combatantUpdated(cbt);
            writeToCombatTabWithRound(cbt.getName() + " (" + cbt.getPlayer() + ") Gained " + heal + " Healing: " + cbt.getHP().getCurrent() + '/' + cbt.getHP().getMax());
        }
    }
    initList.sort();
    refreshTable();
}
Also used : Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant) InitHolder(gmgen.plugin.InitHolder)

Example 8 with InitHolder

use of gmgen.plugin.InitHolder in project pcgen by PCGen.

the class Initiative method raiseCombatant.

/**  Raises the selected combatants from the dead */
private void raiseCombatant() {
    final List selectedList = getSelected();
    while (!selectedList.isEmpty()) {
        InitHolder iH = (InitHolder) selectedList.remove(0);
        if (iH instanceof Combatant) {
            Combatant cbt = (Combatant) iH;
            writeToCombatTabWithRound(iH.getName() + " (" + cbt.getPlayer() + ") Raised");
            cbt.raise();
            combatantUpdated(cbt);
        }
    }
    initList.sort();
    refreshTable();
}
Also used : Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant) List(java.util.List) InitHolderList(gmgen.plugin.InitHolderList) ArrayList(java.util.ArrayList) InitHolder(gmgen.plugin.InitHolder)

Example 9 with InitHolder

use of gmgen.plugin.InitHolder in project pcgen by PCGen.

the class Initiative method bDuplicateCombatantActionPerformed.

/**
	 * @param evt
	 */
private void bDuplicateCombatantActionPerformed(ActionEvent evt) {
    //TODO: This only works for saved pcgen files and xml combatants.
    //For pcgen files, it reloads the file, since there's no good way
    //curently to clone a PlayerCharacter.
    DefaultFormatter formatter = new NumberFormatter();
    formatter.setAllowsInvalid(false);
    formatter.setCommitsOnValidEdit(true);
    formatter.setValueClass(Integer.class);
    JFormattedTextField field = new JFormattedTextField(formatter);
    field.setValue(1);
    int choice = JOptionPane.showConfirmDialog(GMGenSystem.inst, field, "How many copies?", JOptionPane.OK_CANCEL_OPTION);
    if (choice == JOptionPane.CANCEL_OPTION) {
        return;
    }
    int count = ((Number) field.getValue()).intValue();
    for (InitHolder holderToCopy : getSelected()) {
        if ((holderToCopy instanceof XMLCombatant) || (holderToCopy instanceof PcgCombatant)) {
            if (holderToCopy instanceof PcgCombatant) {
                if ((((PcgCombatant) holderToCopy).getPC().getFileName() != null) && (!((PcgCombatant) holderToCopy).getPC().getFileName().isEmpty())) {
                    pasteNew(holderToCopy, count);
                } else {
                    JOptionPane.showMessageDialog(GMGenSystem.inst, "Combatant " + holderToCopy.getName() + " cannot be duplicated because it has not been saved to a valid .pcg file.", "Cannot Duplicate", JOptionPane.WARNING_MESSAGE);
                }
            } else {
                pasteNew(holderToCopy, count);
            }
        } else {
            JOptionPane.showMessageDialog(GMGenSystem.inst, "Combatant " + holderToCopy.getName() + " cannot be duplicated because it is not a PCGen or XML combatant.", "Cannot Duplicate", JOptionPane.WARNING_MESSAGE);
        }
    }
}
Also used : PcgCombatant(gmgen.plugin.PcgCombatant) JFormattedTextField(javax.swing.JFormattedTextField) DefaultFormatter(javax.swing.text.DefaultFormatter) InitHolder(gmgen.plugin.InitHolder) XMLCombatant(plugin.initiative.XMLCombatant) NumberFormatter(javax.swing.text.NumberFormatter)

Example 10 with InitHolder

use of gmgen.plugin.InitHolder in project pcgen by PCGen.

the class Initiative method rollSave.

//** End Functions implementing button calls for top toolbar **
//** Functions implementing button calls for the bottom toolbar **
/**
	 * Save the initiative roll
	 */
private void rollSave() {
    final List<InitHolder> selectedList = getSelected();
    //int dc = 0;
    //int type = SavingThrowDialog.NULL_SAVE;
    SaveModel model = new SaveModel();
    while (!selectedList.isEmpty()) {
        InitHolder iH = selectedList.remove(0);
        if (iH instanceof Combatant) {
            model = performSave(model, iH);
        }
    }
    refreshTable();
}
Also used : SaveModel(plugin.initiative.SaveModel) Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant) InitHolder(gmgen.plugin.InitHolder)

Aggregations

InitHolder (gmgen.plugin.InitHolder)31 PcgCombatant (gmgen.plugin.PcgCombatant)18 XMLCombatant (plugin.initiative.XMLCombatant)13 Combatant (gmgen.plugin.Combatant)11 InitHolderList (gmgen.plugin.InitHolderList)7 ArrayList (java.util.ArrayList)7 Event (gmgen.plugin.Event)6 ActionEvent (java.awt.event.ActionEvent)6 HyperlinkEvent (javax.swing.event.HyperlinkEvent)6 ListSelectionEvent (javax.swing.event.ListSelectionEvent)6 List (java.util.List)5 Vector (java.util.Vector)2 Element (org.jdom2.Element)2 SaveModel (plugin.initiative.SaveModel)2 Spell (gmgen.plugin.Spell)1 SystemHP (gmgen.plugin.SystemHP)1 SystemInitiative (gmgen.plugin.SystemInitiative)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 Writer (java.io.Writer)1