Search in sources :

Example 11 with PcgCombatant

use of gmgen.plugin.PcgCombatant 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 12 with PcgCombatant

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

the class Initiative method removePcgCombatant.

/**
	 * Remove the pcg combatant
	 * @param pc
	 */
public void removePcgCombatant(PlayerCharacter pc) {
    for (int i = 0; i < initList.size(); i++) {
        InitHolder iH = initList.get(i);
        if (iH instanceof PcgCombatant) {
            PcgCombatant c = (PcgCombatant) iH;
            if (c.getPC() == pc) {
                initList.remove(iH);
                removeTab(iH);
            }
        }
    }
}
Also used : PcgCombatant(gmgen.plugin.PcgCombatant) InitHolder(gmgen.plugin.InitHolder)

Example 13 with PcgCombatant

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

the class AttackDialog method handleOk.

/**
	 * Handles actions from the Ok button.  Sets the damage list and hides the dialog.
	 *
	 */
protected void handleOk() {
    m_damageList = new ArrayList<>(m_tableModel.getRowCount());
    m_targetList = new ArrayList(m_tableModel.getRowCount());
    for (int i = 0; i < m_table.getRowCount(); i++) {
        int dmg = m_tableModel.getIntAt(i, m_tableModel.columnFromKey(AttackTableModel.COLUMN_KEY_DMGTOT));
        if (dmg > 0) {
            m_damageList.add(dmg);
            Object target = m_tableModel.getValueAt(i, m_tableModel.columnFromKey(AttackTableModel.COLUMN_KEY_TARGET));
            if ((target != null) && target instanceof PcgCombatant) {
                m_targetList.add(target);
            }
        }
    }
    setVisible(false);
}
Also used : PcgCombatant(gmgen.plugin.PcgCombatant) ArrayList(java.util.ArrayList)

Example 14 with PcgCombatant

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

the class OpposedSkillBasicModel method buildCombatantList.

/**
	 * <p>
	 * Builds the combatant list
	 * </p>
	 *
	 * @param combatantList
	 */
protected void buildCombatantList(List combatantList) {
    for (Iterator i = combatantList.iterator(); i.hasNext(); ) {
        Object o = i.next();
        if (o != null && o instanceof PcgCombatant) {
            PcgCombatant cbt = (PcgCombatant) o;
            addCombatant(cbt);
        }
    }
}
Also used : PcgCombatant(gmgen.plugin.PcgCombatant) Iterator(java.util.Iterator)

Example 15 with PcgCombatant

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

the class GMGenMessageHandler method handleInitHolderListSendMessage.

private void handleInitHolderListSendMessage(TransmitInitiativeValuesBetweenComponentsMessage message) {
    InitHolderList list = message.getInitHolderList();
    for (int i = 0; i < list.size(); i++) {
        InitHolder iH = list.get(i);
        if (iH instanceof PcgCombatant) {
            //TODO: Resolve against the current PC list and add any new characters.
            PcgCombatant pcg = (PcgCombatant) iH;
            PlayerCharacter aPC = pcg.getPC();
            Globals.getPCList().add(aPC);
            aPC.setDirty(true);
        //				addPCTab(aPC);
        }
    }
}
Also used : PcgCombatant(gmgen.plugin.PcgCombatant) PlayerCharacter(pcgen.core.PlayerCharacter) InitHolderList(gmgen.plugin.InitHolderList) InitHolder(gmgen.plugin.InitHolder)

Aggregations

PcgCombatant (gmgen.plugin.PcgCombatant)15 InitHolder (gmgen.plugin.InitHolder)8 XMLCombatant (plugin.initiative.XMLCombatant)5 PlayerCharacter (pcgen.core.PlayerCharacter)4 InitHolderList (gmgen.plugin.InitHolderList)3 ArrayList (java.util.ArrayList)3 List (java.util.List)2 Combatant (gmgen.plugin.Combatant)1 Event (gmgen.plugin.Event)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 Iterator (java.util.Iterator)1 Vector (java.util.Vector)1 JFormattedTextField (javax.swing.JFormattedTextField)1 JFrame (javax.swing.JFrame)1 HyperlinkEvent (javax.swing.event.HyperlinkEvent)1