Search in sources :

Example 1 with Combatant

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

the class ExperienceList method averageCR.

/**
	 * Gets the average level for the party.
	 * @return the average party level.
	 */
int averageCR() {
    float groupLevel = 0;
    int num = 0;
    for (int i = 0; i < size(); i++) {
        Combatant cbt = ((ExperienceListItem) get(i)).getCombatant();
        groupLevel += cbt.getCR();
        num++;
    }
    if (num == 0) {
        return 0;
    }
    return ((int) groupLevel) / num;
}
Also used : Combatant(gmgen.plugin.Combatant)

Example 2 with Combatant

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

the class Initiative method addTab.

/**
	 * <p>
	 * Adds a tab to the {@code tpaneInfo} member. All methods adding
	 * character tabs to {@code tpaneInfo} should call this method to do
	 * so, as it provides a standard setup for the text panes and installs
	 * hyperlink listeners.
	 * </p>
	 *
	 * @param cbt Combatant to add.
	 */
void addTab(final Combatant cbt) {
    javax.swing.JTextPane lp = new javax.swing.JTextPane();
    lp.setContentType("text/html");
    InfoCharacterDetails ic = new InfoCharacterDetails(cbt, lp);
    tpaneInfo.addTab(cbt.getName(), ic.getScrollPane());
    lp.setEditable(false);
    lp.addHyperlinkListener(new HyperlinkListener() {

        private final Combatant combatant = cbt;

        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            hyperLinkSelected(e, combatant);
        }
    });
}
Also used : InfoCharacterDetails(gmgen.plugin.InfoCharacterDetails) HyperlinkEvent(javax.swing.event.HyperlinkEvent) HyperlinkListener(javax.swing.event.HyperlinkListener) Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant)

Example 3 with Combatant

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

the class Initiative method doDamage.

/**
	 * <p>Damages specified 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 doDamage(int damage, InitHolder iH) {
    if (iH instanceof Combatant) {
        Combatant cbt = (Combatant) iH;
        State oldStatus = cbt.getStatus();
        cbt.damage(damage);
        State newStatus = cbt.getStatus();
        writeToCombatTabWithRound(cbt.getName() + " (" + cbt.getPlayer() + ") Took " + damage + " Damage: " + cbt.getHP().getCurrent() + '/' + cbt.getHP().getMax());
        doMassiveDamage(cbt, damage);
        if ((oldStatus != newStatus) && (newStatus == State.Dead)) {
            combatantDied(cbt);
        }
    }
}
Also used : State(gmgen.plugin.State) Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant)

Example 4 with Combatant

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

the class Initiative method editTable.

// TODO Change the Status to be a drop down list rather than a text field.
private void editTable(int row, int column) {
    // Figure out which row is the active row
    // Karianna - Commented out this section to fix bug 
    /*
		int activeRow = 0;
		for (int i = 0; i < initList.size(); i++)
		{
			InitHolder c = initList.get(i);
			// IF the InitHolder status is not Dead or showDead is selected (e.g. InitHolder is alive or we're showeing the dead)
			// AND InitHolder is not an Event or we're shoeing events
			// THEN update the active row
			if ((c.getStatus() != Status.Dead || showDead.isSelected())
				&& (!(c instanceof Event) || showEvents.isSelected()))
			{
				activeRow++;
			}
		}
		*/
    // Look up the active row (-1 as arrays are indexed starting at 0)
    //InitHolder iH = initList.get(activeRow - 1);
    InitHolder iH = initList.get(row);
    String oldName = iH.getName();
    Object data = combatantTable.getValueAt(row, column);
    boolean atTop = (currentInit == initList.getMaxInit());
    iH.editRow(columnList, column, data);
    if (!iH.getName().equals(oldName) && (iH instanceof Combatant)) {
        removeTab(oldName);
        addTab((Combatant) iH);
    }
    initHolderUpdated(iH);
    initList.sort();
    if (atTop) {
        setCurrentInit(initList.getMaxInit());
    }
    refreshTable();
}
Also used : Combatant(gmgen.plugin.Combatant) PcgCombatant(gmgen.plugin.PcgCombatant) XMLCombatant(plugin.initiative.XMLCombatant) InitHolder(gmgen.plugin.InitHolder)

Example 5 with Combatant

use of gmgen.plugin.Combatant 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)

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