Search in sources :

Example 16 with Combatant

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

the class Initiative method performSave.

private SaveModel performSave(SaveModel model, InitHolder iH) {
    Combatant cbt = (Combatant) iH;
    SavingThrowDialog dialog = new SavingThrowDialog(GMGenSystem.inst, true, cbt, model);
    dialog.setVisible(true);
    dialog.dispose();
    int returnVal = dialog.getReturnValue();
    int roll = dialog.getRoll();
    int total = dialog.getTotal();
    model = dialog.getSaveModel();
    StringBuilder sb = new StringBuilder();
    sb.append(dialog.getSaveAbbrev(dialog.getSaveType()));
    sb.append(" save DC " + model.getDc());
    if (roll > 0) {
        sb.append(" with a roll of " + (roll + total));
        sb.append(" (" + total + " + Roll: " + roll + ')');
    }
    if (returnVal == SavingThrowDialog.PASS_OPTION) {
        writeToCombatTabWithRound(iH.getName() + " (" + iH.getPlayer() + ") Passed a " + sb);
    } else if (returnVal == SavingThrowDialog.FAIL_OPTION) {
        writeToCombatTabWithRound(iH.getName() + " (" + iH.getPlayer() + ") Failed a " + sb);
    }
    return model;
}
Also used : Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant)

Example 17 with Combatant

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

the class Initiative method rerollCombatant.

/**  Re-rolls the selected combatant's initiatives */
private void rerollCombatant() {
    final List<InitHolder> selectedList = getSelected();
    while (!selectedList.isEmpty()) {
        InitHolder iH = selectedList.remove(0);
        if (iH instanceof Combatant) {
            Combatant cbt = (Combatant) iH;
            cbt.init.check(0);
            writeToCombatTabWithRound(cbt.getName() + " (" + cbt.getPlayer() + ") Rerolled");
            combatantUpdated(cbt);
        }
    }
    initList.sort();
    refreshTable();
}
Also used : Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant) InitHolder(gmgen.plugin.InitHolder)

Example 18 with Combatant

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

the class Initiative method doNonLethal.

/**
	 * <p>Applies non-lethal combatant.  This allows other methods to damage
	 * combatants who are not necessarily selected at the time.</p>
	 *
	 * @param damage
	 *             Points of damage to do.
	 * @param iH
	 *             InitHolder to damage.
	 */
private void doNonLethal(int damage, InitHolder iH) {
    if (iH instanceof Combatant) {
        Combatant cbt = (Combatant) iH;
        boolean isEnough = false;
        if (cbt instanceof XMLCombatant) {
            XMLCombatant xmlcbt = (XMLCombatant) cbt;
            if (damage > xmlcbt.getHP().getAttribute().getValue()) {
                isEnough = true;
            }
        }
        if (cbt instanceof PcgCombatant) {
            PcgCombatant pcgcbt = (PcgCombatant) cbt;
            PlayerCharacter pc = pcgcbt.getPC();
            PCStat stat = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCStat.class, "CON");
            if (damage > pc.getTotalStatFor(stat)) {
                isEnough = true;
            }
        }
        if (isEnough) {
            SavingThrowDialog dialog = new SavingThrowDialog(GMGenSystem.inst, true, cbt, 15, SavingThrowDialog.FORT_SAVE);
            dialog.setVisible(true);
            dialog.dispose();
            //Show the dialog and get it's results
            int returnVal = dialog.getReturnValue();
            int roll = dialog.getRoll();
            int total = dialog.getTotal();
            int dc = dialog.getDC();
            //Create a message out with the results
            StringBuilder sb = new StringBuilder();
            sb.append(dialog.getSaveAbbrev(dialog.getSaveType()));
            sb.append(" save DC " + dc);
            if (roll > 0) {
                sb.append(" with a roll of " + (roll + total));
                sb.append(" (" + total + " + Roll: " + roll + ')');
            }
            if (returnVal == SavingThrowDialog.PASS_OPTION) {
                writeToCombatTabWithRound(cbt.getName() + " (" + cbt.getPlayer() + ") Passed a " + sb + " to avoid unconsiousness");
                cbt.nonLethalDamage(false);
            } else if (returnVal == SavingThrowDialog.FAIL_OPTION) {
                writeToCombatTabWithRound(cbt.getName() + " (" + cbt.getPlayer() + ") Failed a " + sb + " to avoid unconsiousness");
                cbt.nonLethalDamage(true);
            }
        }
        combatantUpdated(cbt);
    }
}
Also used : PcgCombatant(gmgen.plugin.PcgCombatant) PlayerCharacter(pcgen.core.PlayerCharacter) Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant) PCStat(pcgen.core.PCStat) XMLCombatant(plugin.initiative.XMLCombatant)

Example 19 with Combatant

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

the class Initiative method refreshTabs.

//** End Initialization Functions **
/**
	 * Refresh the tabs
	 */
public void refreshTabs() {
    initList.stream().filter(anInitList -> ((anInitList.getStatus() != State.Dead) || showDead.isSelected()) && (anInitList instanceof Combatant)).forEach(anInitList -> {
        Combatant cbt = (Combatant) anInitList;
        removeTab(cbt);
        addTab(cbt);
    });
}
Also used : PluginManager(pcgen.pluginmgr.PluginManager) Globals(pcgen.core.Globals) Combatant(gmgen.plugin.Combatant) InfoCharacterDetails(gmgen.plugin.InfoCharacterDetails) HyperlinkEvent(javax.swing.event.HyperlinkEvent) JDialog(javax.swing.JDialog) DiceRollModel(plugin.initiative.DiceRollModel) JTableHeader(javax.swing.table.JTableHeader) TableCellRenderer(javax.swing.table.TableCellRenderer) NumberFormatter(javax.swing.text.NumberFormatter) PcgCombatant(gmgen.plugin.PcgCombatant) Document(org.jdom2.Document) Dice(gmgen.plugin.dice.Dice) Vector(java.util.Vector) SettingsHandler(pcgen.core.SettingsHandler) LogUtilities(gmgen.util.LogUtilities) JFileChooser(javax.swing.JFileChooser) DefaultFormatter(javax.swing.text.DefaultFormatter) JComboBox(javax.swing.JComboBox) ListSelectionEvent(javax.swing.event.ListSelectionEvent) FlippingSplitPane(gmgen.gui.FlippingSplitPane) InitHolder(gmgen.plugin.InitHolder) DefaultTableModel(javax.swing.table.DefaultTableModel) Format(org.jdom2.output.Format) Logging(pcgen.util.Logging) Spell(gmgen.plugin.Spell) PCStat(pcgen.core.PCStat) SpellModel(plugin.initiative.SpellModel) GMGenSystem(gmgen.GMGenSystem) Component(java.awt.Component) Collectors(java.util.stream.Collectors) SystemInitiative(gmgen.plugin.SystemInitiative) List(java.util.List) InitHolderList(gmgen.plugin.InitHolderList) CheckModel(plugin.initiative.CheckModel) JSeparator(javax.swing.JSeparator) Writer(java.io.Writer) JCheckBox(javax.swing.JCheckBox) JTable(javax.swing.JTable) XMLCombatant(plugin.initiative.XMLCombatant) Element(org.jdom2.Element) State(gmgen.plugin.State) PlayerCharacter(pcgen.core.PlayerCharacter) PObjectModel(plugin.initiative.PObjectModel) TableColumnModel(javax.swing.table.TableColumnModel) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) InitiativePlugin(plugin.initiative.InitiativePlugin) ArrayList(java.util.ArrayList) AttackModel(plugin.initiative.AttackModel) PCGenMessageHandler(pcgen.pluginmgr.PCGenMessageHandler) SystemHP(gmgen.plugin.SystemHP) LanguageBundle(pcgen.system.LanguageBundle) PCGenSettings(pcgen.system.PCGenSettings) HyperlinkListener(javax.swing.event.HyperlinkListener) SAXBuilder(org.jdom2.input.SAXBuilder) JButton(javax.swing.JButton) JFormattedTextField(javax.swing.JFormattedTextField) TableColumn(javax.swing.table.TableColumn) FileWriter(java.io.FileWriter) IOException(java.io.IOException) JOptionPane(javax.swing.JOptionPane) FileFilter(javax.swing.filechooser.FileFilter) ActionEvent(java.awt.event.ActionEvent) File(java.io.File) DefaultCellEditor(javax.swing.DefaultCellEditor) XMLOutputter(org.jdom2.output.XMLOutputter) CombatantHasBeenUpdatedMessage(gmgen.pluginmgr.messages.CombatantHasBeenUpdatedMessage) Event(gmgen.plugin.Event) SaveModel(plugin.initiative.SaveModel) Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant)

Example 20 with Combatant

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

the class Initiative method stabilizeCombatant.

/**  Stabilizes the selected combatants */
private void stabilizeCombatant() {
    final List<InitHolder> selectedList = getSelected();
    while (!selectedList.isEmpty()) {
        InitHolder iH = selectedList.remove(0);
        if (iH instanceof Combatant) {
            Combatant cbt = (Combatant) iH;
            writeToCombatTabWithRound(iH.getName() + " (" + cbt.getPlayer() + ") Stabilized");
            cbt.stabilize();
            combatantUpdated(cbt);
        }
    }
    initList.sort();
    refreshTable();
}
Also used : Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant) InitHolder(gmgen.plugin.InitHolder)

Aggregations

Combatant (gmgen.plugin.Combatant)24 PcgCombatant (gmgen.plugin.PcgCombatant)18 XMLCombatant (plugin.initiative.XMLCombatant)18 InitHolder (gmgen.plugin.InitHolder)13 InitHolderList (gmgen.plugin.InitHolderList)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 HyperlinkEvent (javax.swing.event.HyperlinkEvent)4 Event (gmgen.plugin.Event)3 InfoCharacterDetails (gmgen.plugin.InfoCharacterDetails)3 State (gmgen.plugin.State)3 ActionEvent (java.awt.event.ActionEvent)3 HyperlinkListener (javax.swing.event.HyperlinkListener)3 GMGenSystem (gmgen.GMGenSystem)2 FlippingSplitPane (gmgen.gui.FlippingSplitPane)2 Spell (gmgen.plugin.Spell)2 SystemHP (gmgen.plugin.SystemHP)2 SystemInitiative (gmgen.plugin.SystemInitiative)2 Dice (gmgen.plugin.dice.Dice)2 CombatantHasBeenUpdatedMessage (gmgen.pluginmgr.messages.CombatantHasBeenUpdatedMessage)2