/** * Convenience method to determine whether this path is happening on a ground map with an atmosphere */ public boolean isOnAtmosphericGroundMap() { return getEntity().isOnAtmosphericGroundMap(); }
/** * Helper function that appends an unjam RAC command to the end of a qualifying path. * @param path The path to process. */ private void unjamRAC(MovePath path) { if(path.getEntity().canUnjamRAC() && (path.getMpUsed() <= path.getEntity().getWalkMP()) && !path.isJumping()) { path.addStep(MoveStepType.UNJAM_RAC); } }
@SuppressWarnings("unchecked") public static List<TargetRoll> getPSRList(MovePath md) { // certain types of entities, such as airborne aero units, do not require many of the checks // carried out in the full PSR Check. So, we call a method that skips most of those. if(md.getEntity().isAirborne()) { return (List<TargetRoll>) getAeroSpecificPSRList(md, false); } else { return (List<TargetRoll>) doPSRCheck(md, false); } }
/** * Returns the final facing if a mech were to perform all the steps in this * path. */ public int getFinalFacing() { MoveStep last = getLastStep(); if (last != null) { return last.getFacing(); } return getEntity().getFacing(); }
double calculateMyKickDamagePotential(MovePath path, Entity enemy, IGame game) { if (!(path.getEntity() instanceof Mech)) { return 0.0; } PhysicalInfo myKick = new PhysicalInfo(path.getEntity(), new EntityState(path), enemy, null, PhysicalAttackType.RIGHT_KICK, game, getOwner(), true); if (myKick.getProbabilityToHit() <= 0.5) { return 0; } return myKick.getExpectedDamageOnHit() * myKick.getProbabilityToHit(); }
private MovePath generateMockPath(int x, int y, Entity mockEntity) { final MovePath mockPath = Mockito.mock(MovePath.class); Mockito.when(mockPath.getEntity()).thenReturn(mockEntity); final Coords mockMyCoords = new Coords(x, y); Mockito.when(mockPath.getFinalCoords()).thenReturn(mockMyCoords); Mockito.when(mockPath.getFinalFacing()).thenReturn(0); return mockPath; }
/** * Returns the final vector for advanced movement */ public int[] getFinalVectors() { if (getLastStep() != null) { return getLastStep().getVectors(); } return getEntity().getVectors(); }
/** * Determines if the aircraft undertaking the given path will become a lawn dart * @param movePath the path to check * @return True or false */ public static boolean willCrash(MovePath movePath) { return movePath.getEntity().isAero() && (movePath.getFinalAltitude() < 1) && !movePath.contains(MoveStepType.VLAND) && !movePath.contains(MoveStepType.LAND); }
/** * get final altitude */ public int getFinalAltitude() { if (getLastStep() != null) { return getLastStep().getAltitude(); } return getEntity().getAltitude(); }
/** * get final elevation relative to the tops of any buildings in the hex * @return */ public int getFinalClearance() { if (getLastStep() != null) { return getLastStep().getClearance(); } IHex hex = entity.getGame().getBoard().getHex(getEntity().getPosition()); if (hex.containsTerrain(Terrains.BLDG_ELEV)) { return getEntity().getElevation() - hex.terrainLevel(Terrains.BLDG_ELEV); } return getEntity().getElevation(); }
/** * get final elevation relative to the hex. */ public int getFinalElevation() { if (getLastStep() != null) { return getLastStep().getElevation(); } return getEntity().getElevation(); }
/** * If the path contains mode conversions, this will determine the movement mode at the end * of movement. Note that LAMs converting from AirMech to Biped mode require two convert commands. * * @return The movement mode resulting from any mode conversions in the path. */ public EntityMovementMode getFinalConversionMode() { if (getLastStep() != null) { return getLastStep().getMovementMode(); } return getEntity().getMovementMode(); }
/** * 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(); }
double calculateKickDamagePotential(Entity enemy, MovePath path, IGame game) { if (!(enemy instanceof Mech)) { return 0.0; } // if they can kick me, and probably hit, they probably will. PhysicalInfo theirKick = new PhysicalInfo(enemy, null, path.getEntity(), new EntityState(path), PhysicalAttackType.RIGHT_KICK, game, getOwner(), true); if (theirKick.getProbabilityToHit() <= 0.5) { return 0.0; } return theirKick.getExpectedDamageOnHit() * theirKick.getProbabilityToHit(); }
/** * Gives the "utility" of a path; a number representing how good it is. * Rankers that extend this class should override this function */ RankedPath rankPath(MovePath path, IGame game) { double fallTolerance = getOwner().getBehaviorSettings().getFallShameIndex() / 10d; Entity me = path.getEntity(); int homeDistance = distanceToHomeEdge(me.getPosition(), getOwner().getHomeEdge(me), game); int maxWeaponRange = me.getMaxWeaponRange(); List<Entity> enemies = getOwner().getEnemyEntities(); List<Entity> friends = getOwner().getFriendEntities(); Coords allyCenter = calcAllyCenter(me.getId(), friends, game); return rankPath(path, game, maxWeaponRange, fallTolerance, homeDistance, enemies, allyCenter); }