public ToHitData toHit(Game game, MovePath md) { final Entity ae = game.getEntity(getEntityId()); final Targetable target = getTarget(game); Coords chargeSrc = ae.getPosition(); MoveStep chargeStep = null;   if (!md.contains(MovePath.STEP_CHARGE)) { return new ToHitData(ToHitData.IMPOSSIBLE, "Charge action not found in movment path"); }   if (md.contains(MovePath.STEP_START_JUMP)) { return new ToHitData(ToHitData.IMPOSSIBLE, "No jumping allowed while charging"); }   if (md.contains(MovePath.STEP_BACKWARDS) || md.contains(MovePath.STEP_LATERAL_LEFT_BACKWARDS) || md.contains(MovePath.STEP_LATERAL_RIGHT_BACKWARDS)) { return new ToHitData(ToHitData.IMPOSSIBLE, "No backwards movement allowed while charging"); }   md.compile(game, ae); for (final Enumeration i = md.getSteps(); i.hasMoreElements();) { final MoveStep step = (MoveStep) i.nextElement(); if (step.getMovementType() == Entity.MOVE_ILLEGAL) { break; } else { if (step.getType() == MovePath.STEP_CHARGE) { chargeStep = step; } else { chargeSrc = step.getPosition(); } } }   if (chargeStep == null || !target.getPosition().equals(chargeStep.getPosition())) { return new ToHitData(ToHitData.IMPOSSIBLE, "Could not reach target with movement"); }  return toHitCharge(game, getEntityId(), target, chargeSrc, chargeStep.getMovementType());
public ToHitData toHit(Game game) { final Entity entity = game.getEntity(getEntityId()); return toHitCharge( game, getEntityId(), game.getTarget(getTargetType(), getTargetId()), entity.getPosition(), entity.moved);
    public ToHitData toHit(Game game, MovePath md) {        final Entity ae = game.getEntity(getEntityId());        final Targetable target = getTarget(game);        Coords chargeSrc = ae.getPosition();        MoveStep chargeStep = null;        // let's just check this        if (!md.contains(MovePath.STEP_CHARGE)) {            return new ToHitData(ToHitData.IMPOSSIBLE, "Charge action not found in movment path");        }        // no jumping        if (md.contains(MovePath.STEP_START_JUMP)) {            return new ToHitData(ToHitData.IMPOSSIBLE, "No jumping allowed while charging");        }        // no backwards        if (md.contains(MovePath.STEP_BACKWARDS)            || md.contains(MovePath.STEP_LATERAL_LEFT_BACKWARDS)            || md.contains(MovePath.STEP_LATERAL_RIGHT_BACKWARDS)) {            return new ToHitData(ToHitData.IMPOSSIBLE, "No backwards movement allowed while charging");        }        // determine last valid step        md.compile(game, ae);        for (final Enumeration i = md.getSteps(); i.hasMoreElements();) {            final MoveStep step = (MoveStep) i.nextElement();            if (step.getMovementType() == Entity.MOVE_ILLEGAL) {                break;            } else {                if (step.getType() == MovePath.STEP_CHARGE) {                    chargeStep = step;                } else {                    chargeSrc = step.getPosition();                }            }        }        // need to reach target        if (chargeStep == null || !target.getPosition().equals(chargeStep.getPosition())) {            return new ToHitData(ToHitData.IMPOSSIBLE, "Could not reach target with movement");        }        return toHitCharge(game, getEntityId(), target, chargeSrc, chargeStep.getMovementType());    }