/**
* Sweep off the target with the arms that the player selects.
*/
private void brush() {
ToHitData toHitLeft = BrushOffAttackAction.toHit(client.game, cen,
target, BrushOffAttackAction.LEFT);
ToHitData toHitRight = BrushOffAttackAction.toHit(client.game, cen,
target, BrushOffAttackAction.RIGHT);
boolean canHitLeft = (TargetRoll.IMPOSSIBLE != toHitLeft.getValue());
boolean canHitRight = (TargetRoll.IMPOSSIBLE != toHitRight.getValue());
int damageLeft = 0;
int damageRight = 0;
String title = null;
StringBuffer warn = null;
String left = null;
String right = null;
String both = null;
String[] choices = null;
SingleChoiceDialog dlg = null;
// If the entity can't brush off, display an error message and abort.
if (!canHitLeft && !canHitRight) {
clientgui.doAlertDialog(Messages
.getString("PhysicalDisplay.AlertDialog.title"), //$NON-NLS-1$
Messages.getString("PhysicalDisplay.AlertDialog.message")); //$NON-NLS-1$
return;
}
// If we can hit with both arms, the player will have to make a choice.
// Otherwise, the player is just confirming the arm in the attack.
if (canHitLeft && canHitRight) {
both = Messages.getString("PhysicalDisplay.bothArms"); //$NON-NLS-1$
warn = new StringBuffer(Messages
.getString("PhysicalDisplay.whichArm")); //$NON-NLS-1$
title = Messages.getString("PhysicalDisplay.chooseBrushOff"); //$NON-NLS-1$
} else {
warn = new StringBuffer(Messages
.getString("PhysicalDisplay.confirmArm")); //$NON-NLS-1$
title = Messages.getString("PhysicalDisplay.confirmBrushOff"); //$NON-NLS-1$
}
// Build the rest of the warning string.
// Use correct text when the target is an iNarc pod.
if (Targetable.TYPE_INARC_POD == target.getTargetType()) {
warn.append(Messages.getString(
"PhysicalDisplay.brushOff1", new Object[] { target })); //$NON-NLS-1$
} else {
warn.append(Messages.getString("PhysicalDisplay.brushOff2")); //$NON-NLS-1$
}
// If we can hit with the left arm, get
// the damage and construct the string.
if (canHitLeft) {
damageLeft = BrushOffAttackAction.getDamageFor(ce(),
BrushOffAttackAction.LEFT);
left = Messages
.getString("PhysicalDisplay.LAHit", new Object[] {//$NON-NLS-1$
toHitLeft.getValueAsString(),
new Double(Compute.oddsAbove(toHitLeft
.getValue())),
new Integer(damageLeft) });
}
// If we can hit with the right arm, get
// the damage and construct the string.
if (canHitRight) {
damageRight = BrushOffAttackAction.getDamageFor(ce(),
BrushOffAttackAction.RIGHT);
right = Messages
.getString("PhysicalDisplay.RAHit", new Object[] {//$NON-NLS-1$
toHitRight.getValueAsString(),
new Double(Compute.oddsAbove(toHitRight
.getValue())),
new Integer(damageRight) });
}
// Allow the player to cancel or choose which arm(s) to use.