}    else if ( !attacker.isEnemyOf( defender ) ) { reason.append( "Can only swarm an enemy." );
    public static ToHitData getSwarmMekBaseToHit( Entity attacker,                                                  Entity defender ) {        int men = 0;        int base = ToHitData.IMPOSSIBLE;        StringBuffer reason = new StringBuffer();        // Can only swarm a Mek.        if ( !(defender instanceof Mech) ) {            reason.append( "Defender is not a Mek." );        }        // Can't target a transported entity.        else if ( Entity.NONE != defender.getTransportId() ) {            reason.append("Target is a passenger.");        }        // Attacker can't be swarming.        else if ( Entity.NONE != attacker.getSwarmTargetId() ) {            reason.append( "Attacker is swarming." );        }        // Can't target a entity invloved in a swarm attack.        else if ( Entity.NONE != defender.getSwarmAttackerId() ) {            reason.append("Target is already being swarmed.");        }        // Can't target a entity conducting a swarm attack.        else if ( Entity.NONE != defender.getSwarmTargetId() ) {            reason.append("Target is swarming a Mek.");        }        // Handle BattleArmor attackers.        else if ( attacker instanceof BattleArmor ) {            BattleArmor inf = (BattleArmor) attacker;            // Battle Armor units can't Leg Attack if they're burdened.            if ( inf.isBurdened() ) {                reason.append( "Launcher not jettisoned." );            } else {                men = inf.getShootingStrength();                if ( men >= 4 ) base = 7;                else if ( men >= 1 ) base = 10;                reason.append( men );                reason.append( " trooper(s) active" );            }        }        // Non-BattleArmor infantry need many more men.        else if ( attacker instanceof Infantry ) {            Infantry inf = (Infantry) attacker;            men = inf.getShootingStrength();            if ( men >= 22 ) base = 7;            else if ( men >= 16 ) base = 10;            reason.append( men );            reason.append( " men alive" );        }        // No one else can conduct leg attacks.        else {            reason.append( "Attacker is not infantry." );        }        // Return the ToHitData for this attack.        return new ToHitData( base, reason.toString() );    }