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