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