use of gmgen.plugin.State 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.State in project pcgen by PCGen.
the class Initiative method bleed.
private void bleed(Combatant cbt) {
if (cbt.getStatus() == State.Bleeding) {
int stableType = SettingsHandler.getGMGenOption(InitiativePlugin.LOG_NAME + ".Damage.Stable", PreferencesDamagePanel.DAMAGE_STABLE_PERCENT);
if (stableType == PreferencesDamagePanel.DAMAGE_STABLE_PERCENT) {
int roll = new Dice(1, 100).roll();
if (roll <= 10) {
cbt.stabilize();
writeToCombatTabWithRound(cbt.getName() + " (" + cbt.getPlayer() + ") auto-stabilized (" + roll + "%)");
} else {
writeToCombatTabWithRound(cbt.getName() + " (" + cbt.getPlayer() + ") failed to auto-stabilize (" + roll + "%)");
}
} else if (stableType == PreferencesDamagePanel.DAMAGE_STABLE_SAVE) {
SavingThrowDialog dialog = new SavingThrowDialog(GMGenSystem.inst, true, cbt, 20, 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();
//stabilize if the combatant passes the save
if (dialog.getReturnValue() == SavingThrowDialog.PASS_OPTION) {
cbt.stabilize();
}
//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 + ')');
}
//write out the results to the combat tab
if (returnVal == SavingThrowDialog.PASS_OPTION) {
writeToCombatTabWithRound(cbt.getName() + " (" + cbt.getPlayer() + ") Passed a " + sb + " to auto-stabilize");
} else if (returnVal == SavingThrowDialog.FAIL_OPTION) {
writeToCombatTabWithRound(cbt.getName() + " (" + cbt.getPlayer() + ") Failed a " + sb + " to auto-stabilize");
}
}
State oldStatus = cbt.getStatus();
cbt.bleed();
combatantUpdated(cbt);
State newStatus = cbt.getStatus();
if ((oldStatus != newStatus) && (newStatus == State.Dead)) {
combatantDied(cbt);
}
}
}
Aggregations