&& (getMp() > 0 || stepType == MovePath.STEP_TURN_LEFT || stepType == MovePath.STEP_TURN_RIGHT) && (!(isProne() || isHullDown()) || parent.contains(MovePath.STEP_GET_UP))) {
&& getMp() > 0) {  if(stepType != MovePath.STEP_TURN_LEFT && stepType != MovePath.STEP_TURN_RIGHT && stepType != MovePath.STEP_GET_UP && (isProne() || isHullDown())) { movementType = IEntityMovementType.MOVE_ILLEGAL; return; }
    void compileIllegal(final IGame game, final Entity entity,                        final MoveStep prev) {        final int stepType = getType();        final boolean isInfantry = entity instanceof Infantry;        Coords curPos = getPosition();        Coords lastPos = prev.getPosition();        boolean isUnjammingRAC = entity.isUnjammingRAC();        prevStepOnPavement = prev.isPavementStep();        isTurning = prev.isTurning();        isUnloaded = prev.isUnloaded();                // Infantry get a first step if all they've done is spin on the spot.        if (isInfantry && (getMpUsed() - getMp()) == 0) {            setFirstStep( true );            //   getMpUsed() is the MPs used in the whole MovePath            //   getMp() is the MPs used in the last (illegal) step (this step)            //   if the difference between the whole path and this step is 0            //   then this must be their first step                    }        // guilty until proven innocent        movementType = IEntityMovementType.MOVE_ILLEGAL;                if(prev.isDiggingIn) {            isDiggingIn = true;            if(type != MovePath.STEP_TURN_LEFT            && type != MovePath.STEP_TURN_RIGHT) {                return; //can't move when digging in            }            movementType = IEntityMovementType.MOVE_LEGAL;        }        else if (type == MovePath.STEP_DIG_IN ||                 type == MovePath.STEP_FORTIFY) {            if(!isInfantry                || !isFirstStep()) {                    return; //can't dig in                }            Infantry inf = (Infantry)entity;            if(inf.getDugIn() != Infantry.DUG_IN_NONE                && inf.getDugIn() != Infantry.DUG_IN_COMPLETE) {                return; //already dug in            }            if(game.getBoard().getHex(curPos).containsTerrain(Terrains.FORTIFIED)) {                return; //already fortified - pointless            }            isDiggingIn = true;            movementType = IEntityMovementType.MOVE_LEGAL;                  }                // check to see if it's trying to flee and can legally do so.        if (type == MovePath.STEP_FLEE                && entity.canFlee()) {            movementType = IEntityMovementType.MOVE_LEGAL;        }                // anyone who can and does lay mines is legal        if (type == MovePath.STEP_LAY_MINE && entity.canLayMine()) {            movementType = IEntityMovementType.MOVE_LEGAL;        }        if (type == MovePath.STEP_CLIMB_MODE_ON ||            type == MovePath.STEP_CLIMB_MODE_OFF) {            movementType = IEntityMovementType.MOVE_LEGAL;        }        // check for ejection (always legal?)        if (type == MovePath.STEP_EJECT) {            movementType = IEntityMovementType.MOVE_NONE;        }        if (type == MovePath.STEP_SEARCHLIGHT) {            movementType = IEntityMovementType.MOVE_LEGAL;        }        if (type == MovePath.STEP_UNJAM_RAC) {            movementType = IEntityMovementType.MOVE_NONE;        }        // infantry are allowed to clear mines        if (type == MovePath.STEP_CLEAR_MINEFIELD && entity instanceof Infantry) {            movementType = IEntityMovementType.MOVE_NONE;        }        // check for valid jump mp        if ( parent.isJumping()             && getMpUsed() <= entity.getJumpMPWithTerrain()             && !isProne()             && !isHullDown()             && !( entity instanceof Protomech                   && (entity.getInternal(Protomech.LOC_LEG)                       == IArmorState.ARMOR_DESTROYED) )             && (!entity.isStuck() || entity.canUnstickByJumping()) ) {            movementType = IEntityMovementType.MOVE_JUMP;        }                // legged Protos may make one facing change        if (isFirstStep()            && entity instanceof Protomech            && (entity.getInternal(Protomech.LOC_LEG)                == IArmorState.ARMOR_DESTROYED)            && (stepType == MovePath.STEP_TURN_LEFT                 || stepType == MovePath.STEP_TURN_RIGHT)            && !entity.isStuck()) {            movementType = IEntityMovementType.MOVE_WALK;        }        // Infantry that is first stepping and turning is legal         if (isInfantry &&             (stepType == MovePath.STEP_TURN_LEFT || stepType == MovePath.STEP_TURN_RIGHT) &&            isFirstStep()) {            if (parent.isJumping()) {                movementType = IEntityMovementType.MOVE_JUMP;            } else {                movementType = IEntityMovementType.MOVE_WALK;            }        }        int tmpWalkMP = entity.getWalkMP();                if ( parent.getEntity().getMovementMode() == IEntityMovementMode.BIPED_SWIM                || parent.getEntity().getMovementMode() == IEntityMovementMode.QUAD_SWIM )            tmpWalkMP = entity.getActiveUMUCount();                if ((parent.getEntity().getMovementMode() == IEntityMovementMode.VTOL)                && (getElevation() != 0)                && !(parent.getEntity() instanceof VTOL)) {            tmpWalkMP = entity.getJumpMP();        }        // check for valid walk/run mp        if (!parent.isJumping()            && !entity.isStuck()            && tmpWalkMP > 0            && (getMp() > 0                    || stepType == MovePath.STEP_TURN_LEFT                    || stepType == MovePath.STEP_TURN_RIGHT)            && (!(isProne() || isHullDown())                || parent.contains(MovePath.STEP_GET_UP))) {            if (getMpUsed() <= tmpWalkMP) {                if (parent.getEntity().getMovementMode() == IEntityMovementMode.VTOL &&                    getElevation() > 0)                    movementType = IEntityMovementType.MOVE_VTOL_WALK;                else                    movementType = IEntityMovementType.MOVE_WALK;            // Vehicles moving along pavement get "road bonus" of 1 MP.            // N.B. The Ask Precentor Martial forum said that a 4/6            //      tank on a road can move 5/7, **not** 5/8.            } else if (entity instanceof Tank && !(entity instanceof VTOL) && isOnlyPavement()                       && getMpUsed() == tmpWalkMP + 1) {                // store if we got the pavement Bonus for end of phase                // gravity psr                movementType = IEntityMovementType.MOVE_WALK;                entity.gotPavementBonus = true;            } else if (getMpUsed() <= entity.getRunMPwithoutMASC()                       && !isRunProhibited()) {                if (parent.getEntity().getMovementMode() == IEntityMovementMode.VTOL)                    movementType = IEntityMovementType.MOVE_VTOL_RUN;                else                    movementType = IEntityMovementType.MOVE_RUN;            } else if (getMpUsed() <= entity.getRunMP()                       && !isRunProhibited()) {                setUsingMASC(true);                Mech m = (Mech) entity;                setTargetNumberMASC(m.getMASCTarget());                movementType = IEntityMovementType.MOVE_RUN;            } else if (                entity instanceof Tank                    && !(entity instanceof VTOL)                    && isOnlyPavement()                    && getMpUsed() <= (entity.getRunMP() + 1)                    && !isRunProhibited()) {                movementType = IEntityMovementType.MOVE_RUN;                // store if we got the pavement Bonus for end of phase                // gravity psr                entity.gotPavementBonus = true;            }        }        // Mechs with busted Gyro may make only one facing change        if (entity.getBadCriticals(CriticalSlot.TYPE_SYSTEM,                                   Mech.SYSTEM_GYRO, Mech.LOC_CT) > 1                && !isFirstStep() ) {            movementType = IEntityMovementType.MOVE_ILLEGAL;        }        // Mechs with 1 MP are allowed to get up, except        // if they've used that 1MP up already        if (MovePath.STEP_GET_UP==stepType && 1==entity.getRunMP()                && entity.mpUsed < 1 && !entity.isStuck()) {            movementType = IEntityMovementType.MOVE_RUN;        }        // amnesty for the first step        if (isFirstStep()                && movementType == IEntityMovementType.MOVE_ILLEGAL                && entity.getWalkMP() > 0                && !entity.isProne()                && !entity.isHullDown()                && !entity.isStuck()                && stepType == MovePath.STEP_FORWARDS) {            movementType = IEntityMovementType.MOVE_RUN;        }        // Is the entity unloading passengers?        if (stepType == MovePath.STEP_UNLOAD) {            if (isFirstStep()) {                if (getMpUsed() <= entity.getRunMP()) {                    movementType = IEntityMovementType.MOVE_RUN;                    if (getMpUsed() <= entity.getWalkMP()) {                        movementType = IEntityMovementType.MOVE_WALK;                    }                }            }            // Prone Meks are able to unload, if they have the MP.            if (getMpUsed() <= entity.getRunMP()                    && (entity.isProne() || entity.isHullDown())                    && movementType == IEntityMovementType.MOVE_ILLEGAL) {                movementType = IEntityMovementType.MOVE_RUN;                if (getMpUsed() <= entity.getWalkMP()) {                    movementType = IEntityMovementType.MOVE_WALK;                }            }            // Can't unload units into prohibited terrain            // or into stacking violation.            Targetable target = getTarget(game);            if (target instanceof Entity) {                Entity other = (Entity) target;                if (null != Compute.stackingViolation(game, other,                                                      curPos, entity)                    || other.isHexProhibited(game.getBoard().getHex(curPos))) {                    movementType = IEntityMovementType.MOVE_ILLEGAL;                }            } else {                movementType = IEntityMovementType.MOVE_ILLEGAL;            }        }        // Can't run or jump if unjamming a RAC.        if (isUnjammingRAC                && (movementType == IEntityMovementType.MOVE_RUN                || movementType == IEntityMovementType.MOVE_VTOL_RUN                || parent.isJumping())) {            movementType = IEntityMovementType.MOVE_ILLEGAL;        }        // only standing mechs may go prone        if (stepType == MovePath.STEP_GO_PRONE            && (isProne() || !(entity instanceof Mech) || entity.isStuck())) {            movementType = IEntityMovementType.MOVE_ILLEGAL;        }        // only standing quads may go hull down        if (stepType == MovePath.STEP_HULL_DOWN) {            if((isProne() || isHullDown()  || !(entity instanceof QuadMech || entity instanceof Tank) || entity.isStuck())) {                movementType = IEntityMovementType.MOVE_ILLEGAL;            }            if(entity instanceof Tank && !(game.getBoard().getHex(curPos).containsTerrain(Terrains.FORTIFIED))) {                movementType = IEntityMovementType.MOVE_ILLEGAL;            }        }                // initially prone mechs can't charge        if((stepType == MovePath.STEP_CHARGE                || stepType == MovePath.STEP_DFA)                 && entity.isProne()) {            movementType = IEntityMovementType.MOVE_ILLEGAL;        }        // check if this movement is illegal for reasons other than points        if (!isMovementPossible(game, lastPos, prev.getElevation()) || isUnloaded) {            movementType = IEntityMovementType.MOVE_ILLEGAL;        }        // If the previous step is always illegal, then so is this one        if ( prev != null && IEntityMovementType.MOVE_ILLEGAL == prev.movementType ) {            movementType = IEntityMovementType.MOVE_ILLEGAL;        }        // Don't compute danger if the step is illegal.        if (movementType == IEntityMovementType.MOVE_ILLEGAL) {            return;        }        int prevEl = getElevation();        if (prev != null) {            prevEl = prev.getElevation();        }        danger            |= Compute.isPilotingSkillNeeded(                game,                entity.getId(),                lastPos,                curPos,                movementType,                isTurning,                prevStepOnPavement,                prevEl,                getElevation());        // getting up is also danger        if (stepType == MovePath.STEP_GET_UP) {            danger = true;        }        // set past danger        pastDanger |= danger;        // Record if we're turning *after* check for danger,        // because the danger lies in moving *after* turn.        switch (stepType) {            case MovePath.STEP_TURN_LEFT :            case MovePath.STEP_TURN_RIGHT :                setTurning(true);                break;            case MovePath.STEP_UNLOAD :                // Unloading must be the last step.                setUnloaded(true);                break;            default :                setTurning(false);                break;        }        // update prone state        if (stepType == MovePath.STEP_GO_PRONE) {            setProne(true);            setHullDown(false);        } else if (stepType == MovePath.STEP_GET_UP) {            setProne(false);            setHullDown(false);        } else if (stepType == MovePath.STEP_HULL_DOWN) {            setProne(false);            setHullDown(true);        }    }