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