if (((MiscType)(caa.getClub().getType())).hasSubType(MiscType.S_MACE)) {
if (((MiscType)caa.getClub().getType()).hasSubType(MiscType.S_MACE)) {
    private void resolveClubAttack(PhysicalResult pr, int lastEntityId) {        final ClubAttackAction caa = (ClubAttackAction)pr.aaa;        final Entity ae = game.getEntity(caa.getEntityId());        // get damage, ToHitData and roll from the PhysicalResult        int damage = pr.damage;        final ToHitData toHit = pr.toHit;        int roll = pr.roll;        final Targetable target = game.getTarget(caa.getTargetType(), caa.getTargetId());        Entity te = null;        if (target.getTargetType() == Targetable.TYPE_ENTITY) {            te = (Entity)target;        }        boolean throughFront = true;        if (te!=null) {            throughFront = Compute.isThroughFrontHex(game, caa.getEntityId(), te);        }        final boolean targetInBuilding = Compute.isInBuilding( game, te );        final boolean glancing = (game.getOptions().booleanOption("maxtech_glancing_blows") && (roll == toHit.getValue()));        Report r;        // Which building takes the damage?        Building bldg = game.getBoard().getBuildingAt( target.getPosition() );        // restore club attack        caa.getClub().restore();        if (lastEntityId != caa.getEntityId()) {            //who is making the attacks            r = new Report(4005);            r.subject = ae.getId();            r.addDesc(ae);            addReport(r);        }        r = new Report(4145);        r.subject = ae.getId();        r.indent();        r.add(caa.getClub().getName());        r.add(target.getDisplayName());        r.newlines = 0;        addReport(r);        // Flail/Wrecking Ball auto misses on a 2 and hits themself.        if ((((MiscType)(caa.getClub().getType())).hasSubType(MiscType.S_FLAIL) ||                ((MiscType)(caa.getClub().getType())).hasSubType(MiscType.S_WRECKING_BALL))                && roll == 2) {            //miss            r = new Report(4035);            r.subject = ae.getId();            addReport(r);            ToHitData newToHit = new ToHitData(ToHitData.AUTOMATIC_SUCCESS,"hit with own flail/wrecking ball");            pr.damage /=2;            newToHit.setHitTable(ToHitData.HIT_NORMAL);            newToHit.setSideTable(ToHitData.SIDE_FRONT);            pr.toHit = newToHit;            pr.aaa.setTargetId(ae.getId());            pr.aaa.setTargetType(Targetable.TYPE_ENTITY);            pr.roll = Integer.MAX_VALUE;            resolveClubAttack(pr, ae.getId());            game.addPSR(new PilotingRollData(ae.getId(), 0, "missed a flail/wrecking ball attack"));            return;        }        // Need to compute 2d6 damage. and add +3 heat build up.        if ( ((MiscType)(caa.getClub().getType())).hasSubType(MiscType.S_BUZZSAW)) {                        damage = Compute.d6(2);            ae.heatBuildup +=3;            // Buzzsaw's blade will shatter on a roll of 2.            if ( roll == 2 ) {                                Enumeration eqList = ae.getEquipment();                Mounted club = caa.getClub();                while ( eqList.hasMoreElements() ){                    Mounted eq = (Mounted)eqList.nextElement();                    if ( eq.getLocation() == club.getLocation()                            && eq.getType() instanceof MiscType                            && ((MiscType)eq.getType()).hasFlag(MiscType.F_CLUB)                            && ((MiscType)eq.getType()).hasSubType(MiscType.S_BUZZSAW)){                        eq.setDestroyed(true);                        break;                    }                }                r = new Report(4037);                r.subject = ae.getId();                addReport(r);                damage = 0;                return;            }        }        if (toHit.getValue() == ToHitData.IMPOSSIBLE) {            r = new Report(4075);            r.subject = ae.getId();            r.add(toHit.getDesc());            addReport(r);            if (((MiscType)(caa.getClub().getType())).hasSubType(MiscType.S_MACE_THB)) {                game.addPSR(new PilotingRollData(ae.getId(), 0, "missed a mace attack"));            }            if (((MiscType)(caa.getClub().getType())).hasSubType(MiscType.S_MACE)) {                game.addPSR(new PilotingRollData(ae.getId(), 2, "missed a mace attack"));            }            return;        } else if (toHit.getValue() == ToHitData.AUTOMATIC_SUCCESS) {            r = new Report(4080);            r.subject = ae.getId();            r.add(toHit.getDesc());            r.newlines = 0;            addReport(r);            roll = Integer.MAX_VALUE;        } else {            // report the roll            r = new Report(4025);            r.subject = ae.getId();            r.add(toHit.getValue());            r.add(roll);            r.newlines = 0;            addReport(r);            if (glancing) {                r = new Report(4030);                r.subject = ae.getId();                r.newlines = 0;                addReport(r);            }       }        // do we hit?        if (roll < toHit.getValue()) {            //miss            r = new Report(4035);            r.subject = ae.getId();            addReport(r);            if (((MiscType)(caa.getClub().getType())).hasSubType(MiscType.S_MACE_THB)) {                game.addPSR(new PilotingRollData(ae.getId(), 0, "missed a mace attack"));            }            if (((MiscType)(caa.getClub().getType())).hasSubType(MiscType.S_MACE)) {                game.addPSR(new PilotingRollData(ae.getId(), 2, "missed a mace attack"));            }            // If the target is in a building, the building absorbs the damage.            if ( targetInBuilding && bldg != null ) {                // Only report if damage was done to the building.                if ( damage > 0 ) {                    Report buildingReport = damageBuilding( bldg, damage );                    buildingReport.indent();                    buildingReport.subject = ae.getId();                    addReport(buildingReport);                }            }            return;        }        // Targeting a building.        if ( target.getTargetType() == Targetable.TYPE_BUILDING ) {            // The building takes the full brunt of the attack.            r = new Report(4040);            r.subject = ae.getId();            addReport(r);            Report buildingReport = damageBuilding( bldg, damage );            buildingReport.indent();            buildingReport.subject = ae.getId();            addReport(buildingReport);            // Damage any infantry in the hex.            this.damageInfantryIn( bldg, damage );            // And we're done!            return;        }        HitData hit = te.rollHitLocation(toHit.getHitTable(), toHit.getSideTable());        r = new Report(4045);        r.subject = ae.getId();        r.add(toHit.getTableDesc());        r.add(te.getLocationAbbr(hit));        r.newlines = 0;        addReport(r);        // The building shields all units from a certain amount of damage.        // The amount is based upon the building's CF at the phase's start.        if ( targetInBuilding && bldg != null ) {            int bldgAbsorbs = (int) Math.ceil( bldg.getPhaseCF() / 10.0 );            int toBldg = Math.min( bldgAbsorbs, damage );            damage -= toBldg;            addNewLines();            Report buildingReport = damageBuilding( bldg, toBldg );            buildingReport.indent();            buildingReport.subject = ae.getId();            addReport(buildingReport);        }        // A building may absorb the entire shot.        if ( damage == 0 ) {            r = new Report(4050);            r.subject = ae.getId();            r.add(te.getShortName());            r.add(te.getOwner().getName());            r.newlines = 0;            addReport(r);        } else {            if (glancing) {                damage = (int)Math.floor(damage/2.0);            }            addReport(damageEntity(te, hit, damage, false, 0, false, false, throughFront));        }        //On a roll of 10+ a lance hitting a mech/Vehicle can cause 1 point of internal damage        if ( te != null                 && ((MiscType)(caa.getClub().getType())).hasSubType(MiscType.S_LANCE)                && te.getArmor(hit) > 0                && te.getArmorType() != MiscType.T_ARMOR_HARDENED) {                roll = Compute.d6(2);                //Pierce checking report                r = new Report(4021);                r.indent(2);                r.subject = ae.getId();                r.add(te.getLocationAbbr(hit));                r.add(roll);                r.newlines = 1;                addReport(r);                if ( roll >= 10 ){                    hit.makeGlancingBlow();                    addReport(damageEntity(te, hit, 1, false, 0, true, false, throughFront));                }        }                addNewLines();        if (((MiscType)caa.getClub().getType()).hasSubType(MiscType.S_TREE_CLUB)) {            //the club breaks            r = new Report(4150);            r.subject = ae.getId();            r.add(caa.getClub().getName());            addReport(r);            ae.removeMisc(caa.getClub().getName());        }    }