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