/** * Clones this path, will contain a new clone of the steps so that the clone * is independent from the original. * * @return the cloned MovePath */ @Override public MovePath clone() { final MovePath copy = new MovePath(getGame(), getEntity()); copy.steps = new Vector<MoveStep>(steps); copy.careful = careful; copy.containedStepTypes = new HashSet<>(containedStepTypes); copy.fliesOverEnemy = fliesOverEnemy; return copy; }
@Override public String toString() { final StringBuffer sb = new StringBuffer(); sb.append("MOVE PATH:"); sb.append(this.getKey().hashCode()); sb.append(' '); // it's useful to know for debugging purposes which path you're looking at. sb.append("Length: " + this.length()); sb.append("Final Coords: " + this.getFinalCoords()); sb.append(System.lineSeparator()); for (final Enumeration<MoveStep> i = steps.elements(); i.hasMoreElements(); ) { sb.append(i.nextElement().toString()); sb.append(' '); } if(!getGame().getBoard().contains(this.getFinalCoords())) { sb.append("OUT!"); } if(this.getFliesOverEnemy()) { sb.append("E! "); } return sb.toString(); }
/** * Returns the highest elevation in the current path * * @return */ public int getMaxElevation() { int maxElev = 0; for (MoveStep step : steps) { maxElev = Math.max(maxElev, getGame().getBoard().getHex(step.getPosition()).getLevel()); } return maxElev; }
/** * Returns the distance between the highest elevation in the jump path and * the elevation at the landing point. This gives the largest distance the * unit has fallen during the jump. */ public int getJumpMaxElevationChange() { return getMaxElevation() - getGame().getBoard().getHex(getFinalCoords()).getLevel(); }
aerospacePaths.removeIf(path -> !startingEdge.getGame().getBoard().contains(path.getFinalCoords())); if(offBoardPath != null) { aerospacePaths.add(offBoardPath);
/** * Worker function to determine whether we should discard the current path * (due to it being illegal or redundant) or keep generating child nodes * @param path The move path to consider * @return Whether to keep or dicsard. */ @Override protected boolean discardPath(MovePath path, CoordsWithFacing pathDestination) { boolean maxMPExceeded = path.getMpUsed() > path.getEntity().getRunMP(); // having generated the child, we add it and (recursively) any of its children to the list of children to be returned // unless it moves too far or exceeds max thrust if(path.getFinalVelocityLeft() < 0 || maxMPExceeded) { return true; } // terminator conditions: // we've visited this hex already and the path we are considering is longer than the previous path that visited this hex if(visitedCoords.containsKey(pathDestination) && visitedCoords.get(pathDestination).intValue() < path.getMpUsed()) { return true; } // there's no reason to consider off-board paths in the standard flight model. if(!path.getGame().getBoard().contains(pathDestination.getCoords())) { return true; } return false; } }
/** * Determines if the given move path ends on the given board edge * @param movePath The move path to check. * @param edge The edge to check for. * @return True or false. */ private boolean isOnBoardEdge(MovePath movePath, int destinationRegion) { Coords coords = movePath.getFinalCoords(); switch(destinationRegion) { case Board.START_N: return coords.getY() == 0; case Board.START_S: return coords.getY() == movePath.getGame().getBoard().getHeight() - 1; case Board.START_E: return coords.getX() == movePath.getGame().getBoard().getWidth() - 1; case Board.START_W: return coords.getX() == 0; default: return false; } }
/** * Returns the highest elevation along a jump path. * * @return */ public Coords getJumpPathHighestPoint() { Coords highestCoords = null; int highestElevation = 0; for (MoveStep step : steps) { if (getGame().getBoard().getHex(step.getPosition()).getLevel() > highestElevation) { highestElevation = step.getElevation(); highestCoords = step.getPosition(); } } return highestCoords; }
final MovePath expandedPath = adjacent.next(); if (expandedPath.getLastStep().isMovementPossible(getGame(), startingPos, startingElev)) { MovePath expandedPath = candidatePath.clone(); expandedPath.addStep(type); if (expandedPath.getLastStep().isMovementPossible(getGame(), startingPos, startingElev)) {
/** * Returns the final coordinates if a mech were to perform all the steps in * this path. */ public Coords getFinalCoords() { if(getGame().useVectorMove()) { return Compute.getFinalPosition(getEntity().getPosition(), getFinalVectors()); } if (getLastStep() != null) { return getLastStep().getPosition(); } return getEntity().getPosition(); }
int turnCost = currentStep.asfTurnCost(mp.getGame(), stepType, mp.getEntity());
public boolean isMoveLegal() { if (!getGame().getBoard().contains(getFinalCoords())) { return false; IAero a = (IAero) getEntity(); if (getLastStep() == null) { if ((a.getCurrentVelocity() > 0) && !getGame().useVectorMove()) { return false; if ((getLastStep().getVelocityLeft() > 0) && !getGame().useVectorMove() && !(getLastStep().getType() == MovePath.MoveStepType.FLEE || getLastStep().getType() == MovePath.MoveStepType.EJECT)) {
for (int i = 0; i < temp.size(); i++) { MoveStep step = temp.elementAt(i); if ((step.getTargetPosition() != null) && (step.getTarget(getGame()) != null)) { step = new MoveStep(this, step.getType(), step.getTarget(getGame()), step.getTargetPosition()); } else if (step.getTarget(getGame()) != null) { step = new MoveStep(this, step.getType(), step.getTarget(getGame())); } else if (step.getRecoveryUnit() != -1) { step = new MoveStep(this, step.getType(), step.getRecoveryUnit(), -1); boolean isMech = getEntity() instanceof Mech; int elev = getEntity().getElevation(); if (Compute.isEnemyIn(getGame(), getEntity(), pos, false, isMech, elev)) {
step.compile(getGame(), getEntity(), prev); } catch (final RuntimeException re) { || (step.getElevation() + getGame().getBoard().getHex(step.getPosition()).floor() != last.getElevation() + getGame().getBoard().getHex(last.getPosition()).floor()) || steps.stream().filter(s -> s.isStrafingStep()).count() > 5) { step.setMovementType(EntityMovementType.MOVE_ILLEGAL);
IBoard board = movePath.getGame().getBoard(); IHex destHex = board.getHex(dest); Coords src = movePath.getSecondLastStep().getPosition();