Package megamek.common

Examples of megamek.common.ToHitData


    /**
     * Make a protomech physical attack on the target.
     */
    private void proto() {
        ToHitData proto = ProtomechPhysicalAttackAction.toHit(client.game, cen,
                target);
        String title = Messages
                .getString(
                        "PhysicalDisplay.ProtoMechAttackDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$
        String message = Messages.getString(
                "PhysicalDisplay.ProtoMechAttackDialog.message", new Object[] {//$NON-NLS-1$
                        proto.getValueAsString(),
                        new Double(Compute.oddsAbove(proto.getValue())),
                        proto.getDesc(),
                        ProtomechPhysicalAttackAction.getDamageFor(ce())
                                + proto.getTableDesc() });
        if (clientgui.doYesNoDialog(title, message)) {
            disableButtons();
            // declare searchlight, if possible
            if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) {
                doSearchlight();
View Full Code Here


            ready();
        }
    }

    private void breakGrapple() {
        ToHitData toHit = BreakGrappleAttackAction.toHit(client.game, cen,
                target);
        String title = Messages
                .getString(
                        "PhysicalDisplay.BreakGrappleDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$
        String message = Messages.getString(
                "PhysicalDisplay.BreakGrappleDialog.message", new Object[] { //$NON-NLS-1$
                toHit.getValueAsString(),
                        new Double(Compute.oddsAbove(toHit.getValue())),
                        toHit.getDesc() });
        if (clientgui.doYesNoDialog(title, message)) {
            disableButtons();
            // declare searchlight, if possible
            if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) {
                doSearchlight();
View Full Code Here

            ready();
        }
    }

    private void explosives() {
        ToHitData explo = LayExplosivesAttackAction.toHit(client.game, cen,
                target);
        String title = Messages
                .getString(
                        "PhysicalDisplay.LayExplosivesAttackDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$
        String message = Messages
                .getString(
                        "PhysicalDisplay.LayExplosivesAttackDialog.message", new Object[] {//$NON-NLS-1$
                                explo.getValueAsString(),
                                new Double(Compute.oddsAbove(explo.getValue())),
                                explo.getDesc() });
        if (clientgui.doYesNoDialog(title, message)) {
            disableButtons();
            attacks.addElement(new LayExplosivesAttackAction(cen, target
                    .getTargetType(), target.getTargetId()));
            ready();
View Full Code Here

            ready();
        }
    }

    public void jumpjetatt() {
        ToHitData toHit;
        int leg;
        int damage;
        if (ce().isProne()) {
            toHit = JumpJetAttackAction.toHit(client.game, cen, target,
                    JumpJetAttackAction.BOTH);
            leg = JumpJetAttackAction.BOTH;
            damage = JumpJetAttackAction.getDamageFor(ce(),
                    JumpJetAttackAction.BOTH);
        } else {
            ToHitData left = JumpJetAttackAction.toHit(client.game, cen,
                    target, JumpJetAttackAction.LEFT);
            ToHitData right = JumpJetAttackAction.toHit(client.game, cen,
                    target, JumpJetAttackAction.RIGHT);
            int d_left = JumpJetAttackAction.getDamageFor(ce(),
                    JumpJetAttackAction.LEFT);
            int d_right = JumpJetAttackAction.getDamageFor(ce(),
                    JumpJetAttackAction.RIGHT);
            if (d_left * Compute.oddsAbove(left.getValue()) > d_right
                    * Compute.oddsAbove(right.getValue())) {
                toHit = left;
                leg = JumpJetAttackAction.LEFT;
                damage = d_left;
            } else {
                toHit = right;
View Full Code Here

    public void club() {
        Mounted club = chooseClub();
        if (null == club) {
            return;
        }
        ToHitData toHit = ClubAttackAction.toHit(client.game, cen, target,
                club, ash.getAimTable());
        String title = Messages
                .getString(
                        "PhysicalDisplay.ClubDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$
        String message = Messages.getString(
                "PhysicalDisplay.ClubDialog.message", new Object[] { //$NON-NLS-1$
                        toHit.getValueAsString(),
                        new Double(Compute.oddsAbove(toHit.getValue())),
                        toHit.getDesc(),
                        ClubAttackAction.getDamageFor(ce(), club,
                                (target instanceof Infantry) &&
                                !(target instanceof BattleArmor))
                                + toHit.getTableDesc() });
        if (clientgui.doYesNoDialog(title, message)) {
            disableButtons();
            // declare searchlight, if possible
            if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) {
                doSearchlight();
View Full Code Here

    /**
     * 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.
View Full Code Here

     */
    public void club(Mounted club) {
        if (null == club) {
            return;
        }
        ToHitData toHit = ClubAttackAction.toHit(client.game, cen, target,
                club, ash.getAimTable());
        String title = Messages
                .getString(
                        "PhysicalDisplay.ClubDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$
        String message = Messages.getString(
                "PhysicalDisplay.ClubDialog.message", new Object[] { //$NON-NLS-1$
                        toHit.getValueAsString(),
                        new Double(Compute.oddsAbove(toHit.getValue())),
                        toHit.getDesc(),
                        ClubAttackAction.getDamageFor(ce(), club,
                                (target instanceof Infantry) &&
                                !(target instanceof BattleArmor))
                                + toHit.getTableDesc() });
        if (clientgui.doYesNoDialog(title, message)) {
            disableButtons();
            // declare searchlight, if possible
            if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) {
                doSearchlight();
View Full Code Here

     * Thrash at the target, unless the player cancels the action.
     */
    void thrash() {
        ThrashAttackAction act = new ThrashAttackAction(cen, target
                .getTargetType(), target.getTargetId());
        ToHitData toHit = act.toHit(client.game);

        String title = Messages
                .getString(
                        "PhysicalDisplay.TrashDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$
        String message = Messages.getString(
                "PhysicalDisplay.TrashDialog.message", new Object[] {//$NON-NLS-1$
                        toHit.getValueAsString(),
                        new Double(Compute.oddsAbove(toHit.getValue())),
                        toHit.getDesc(),
                        ThrashAttackAction.getDamageFor(ce())
                                + toHit.getTableDesc() });

        // Give the user to cancel the attack.
        if (clientgui.doYesNoDialog(title, message)) {
            disableButtons();
            attacks.addElement(act);
View Full Code Here

    /**
     * Make a protomech physical attack on the target.
     */
    private void proto() {
        ToHitData proto = ProtomechPhysicalAttackAction.toHit(client.game, cen,
                target);
        String title = Messages
                .getString(
                        "PhysicalDisplay.ProtoMechAttackDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$
        String message = Messages.getString(
                "PhysicalDisplay.ProtoMechAttackDialog.message", new Object[] { //$NON-NLS-1$
                        proto.getValueAsString(),
                        new Double(Compute.oddsAbove(proto.getValue())),
                        proto.getDesc(),
                        ProtomechPhysicalAttackAction.getDamageFor(ce())
                                + proto.getTableDesc() });
        if (clientgui.doYesNoDialog(title, message)) {
            disableButtons();
            // declare searchlight, if possible
            if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) {
                doSearchlight();
View Full Code Here

            ready();
        }
    }

    private void explosives() {
        ToHitData explo = LayExplosivesAttackAction.toHit(client.game, cen,
                target);
        String title = Messages
                .getString(
                        "PhysicalDisplay.LayExplosivesAttackDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$
        String message = Messages
                .getString(
                        "PhysicalDisplay.LayExplosivesAttackDialog.message", new Object[] { //$NON-NLS-1$
                                explo.getValueAsString(),
                                new Double(Compute.oddsAbove(explo.getValue())),
                                explo.getDesc() });
        if (clientgui.doYesNoDialog(title, message)) {
            disableButtons();
            attacks.addElement(new LayExplosivesAttackAction(cen, target
                    .getTargetType(), target.getTargetId()));
            ready();
View Full Code Here

TOP

Related Classes of megamek.common.ToHitData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.