/** * Check for MASC use */ public boolean hasActiveMASC() { for (final Enumeration<MoveStep> i = getSteps(); i.hasMoreElements(); ) { final MoveStep step = i.nextElement(); if (step.isUsingMASC()) { return true; } } return false; }
/** * Returns the starting {@link Coords} of this path. */ @Nullable public Coords getStartCoords() { for (final Enumeration<MoveStep> e = getSteps(); e.hasMoreElements(); ) { final MoveStep step = e.nextElement(); final Coords coords = step.getPosition(); if (coords != null) { return coords; } } return null; }
/** * Checks if a target lies under a move path, to see if an aero unit can attack it. * * @param flightPath move path to check * @param targetState used for targets position * @return TRUE if the target is under the path. */ boolean isTargetUnderFlightPath(final MovePath flightPath, final EntityState targetState) { final Coords targetCoords = targetState.getPosition(); for (final Enumeration<MoveStep> step = flightPath.getSteps(); step.hasMoreElements(); ) { final Coords stepCoords = step.nextElement().getPosition(); if (targetCoords.equals(stepCoords)) { return true; } } return false; }
public Coords getSecondFinalPosition(Coords startPos) { Coords priorPos = startPos; Coords finalPos = getFinalCoords(); // if we moved one or fewer hexes, then just return starting position if (getHexesMoved() < 2) { return priorPos; } for (final Enumeration<MoveStep> i = getSteps(); i.hasMoreElements(); ) { final MoveStep step = i.nextElement(); if (step.getPosition() != finalPos) { priorPos = step.getPosition(); } } return priorPos; }
/** * Method that determines whether a given path goes through a given set of x/y coordinates * Useful for debugging mainly. * Note that battletech map coordinates begin at 1, while the internal representation begins at 0 * so subtract 1 from each axis to get the actual coordinates. * @param x X-coordinate * @param y Y-coordinate * @return Whether this path goes through the set of coordinates. */ public boolean goesThroughCoords(int x, int y) { Enumeration<MoveStep> steps = getSteps(); while(steps.hasMoreElements()) { MoveStep step = steps.nextElement(); if(step.getPosition().getX() == x && step.getPosition().getY() == y) { return true; } } return false; }
for (MovePath p : paths) { for (Enumeration<MoveStep> e = p.getSteps(); e .hasMoreElements();) { Coords cord = (e.nextElement()).getPosition();
@Test public void testIsTargetUnderFlightPath() { // Test the target being under the path. Vector<MoveStep> pathSteps = new Vector<>(1); MoveStep mockStep = Mockito.mock(MoveStep.class); pathSteps.add(mockStep); MovePath mockPath = Mockito.mock(MovePath.class); Mockito.when(mockPath.getSteps()).thenReturn(pathSteps.elements()); Mockito.when(mockStep.getPosition()).thenReturn(mockTargetCoords); Assert.assertTrue(testFireControl.isTargetUnderFlightPath(mockPath, mockTargetState)); // Test the target not being under the path. pathSteps = new Vector<>(1); mockStep = Mockito.mock(MoveStep.class); pathSteps.add(mockStep); mockPath = Mockito.mock(MovePath.class); Mockito.when(mockPath.getSteps()).thenReturn(pathSteps.elements()); Mockito.when(mockStep.getPosition()).thenReturn(mockShooterCoords); Assert.assertFalse(testFireControl.isTargetUnderFlightPath(mockPath, mockTargetState)); }
for (final Enumeration<MoveStep> i = md.getSteps(); i.hasMoreElements();) { final MoveStep step = i.nextElement(); j++;
for (Enumeration<MoveStep> i = md.getSteps(); i.hasMoreElements(); ) { final MoveStep step = i.nextElement(); if ((null != previousStep)
for (final Enumeration<MoveStep> i = md.getSteps(); i.hasMoreElements();) { final MoveStep step = i.nextElement(); if (step.getMovementType(md.isEndStep(step)) == EntityMovementType.MOVE_ILLEGAL) {
for (final Enumeration<MoveStep> i = md.getSteps(); i.hasMoreElements(); ) { final MoveStep step = i.nextElement(); if (step.getMovementType(md.isEndStep(step)) == EntityMovementType.MOVE_ILLEGAL) {
final Enumeration<MoveStep> steps = path.getSteps(); while (steps.hasMoreElements()) { final MoveStep step = steps.nextElement();
for (final Enumeration<MoveStep> i = md.getSteps(); i.hasMoreElements(); ) { final MoveStep step = i.nextElement(); if (step.getMovementType(md.isEndStep(step)) == EntityMovementType.MOVE_ILLEGAL) {
for (final Enumeration<MoveStep> i = md.getSteps(); i.hasMoreElements();) { final MoveStep step = i.nextElement();
for (final Enumeration<MoveStep> i = md.getSteps(); i.hasMoreElements(); ) { final MoveStep step = i.nextElement(); if (!step.isLegal(md)) {
for (final Enumeration<MoveStep> i = md.getSteps(); i.hasMoreElements();) { final MoveStep step = i.nextElement(); boolean isPavementStep = step.isPavementStep();