private int calcAttackDirection() { return getTargetState().getPosition().direction(getShooterState().getPosition()); }
/** * 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; }
protected void setDamageDirection(EntityState targetState, Coords shooterCoords) { int fromDirection = targetState.getPosition().direction(shooterCoords); setDamageDirection(((fromDirection - targetState.getFacing()) + 6) % 6); }
Mockito.when(mockShooterState.getPosition()).thenReturn(SHOOTER_COORDS); Mockito.when(mockTargetState.getPosition()).thenReturn(TARGET_COORDS_9);
LosEffects.calculateLos(game, enemy.getId(), path.getEntity(), shooterState.getPosition(), targetState.getPosition(), false); actualTarget = new BuildingTarget(targetState.getPosition(), game.getBoard(), false); targetState = new EntityState(actualTarget);
Mockito.when(mockShooterState.getPosition()).thenReturn(mockEnemyPosition); final EntityState mockTargetState = Mockito.mock(EntityState.class); final Coords mockTargetPosition = mockMe.getPosition(); Mockito.when(mockTargetState.getPosition()).thenReturn(mockTargetPosition); Mockito.when(mockTargetState.getPosition()).thenReturn(null); Assert.assertEquals(0.0, testRanker.calculateDamagePotential(mockEnemy, mockShooterState, mockPath, mockTargetState, testDistance, mockGame),
mockShooterState = Mockito.mock(EntityState.class); mockShooterCoords = new Coords(0, 0); Mockito.when(mockShooterState.getPosition()).thenReturn(mockShooterCoords); mockShooterMoveMod = new ToHitData(); mockTargetMoveMod = new ToHitData(); mockTargetCoords = new Coords(10, 0); Mockito.when(mockTargetState.getPosition()).thenReturn(mockTargetCoords);
Mockito.when(mockTargetState.isImmobile()).thenReturn(false); Mockito.when(mockTargetState.getMovementType()).thenReturn(EntityMovementType.MOVE_NONE); Mockito.when(mockTargetState.getPosition()).thenReturn(new Coords(10, 0)); Mockito.when(mockTargetState.isProne()).thenReturn(false); Mockito.when(mockTarget.isAirborne()).thenReturn(false); Mockito.when(mockFighterState.isImmobile()).thenReturn(false); Mockito.when(mockFighterState.getMovementType()).thenReturn(EntityMovementType.MOVE_SAFE_THRUST); Mockito.when(mockFighterState.getPosition()).thenReturn(new Coords(10, 0)); Mockito.when(mockFighterState.isProne()).thenReturn(false); Mockito.doReturn(new Coords(0, 2)).when(testFireControl).getNearestPointInFlightPath(Mockito.any(Coords.class), Mockito.when(mockShooterState.getPosition()).thenReturn(null); expected = new ToHitData(FireControl.TH_NULL_POSITION); assertToHitDataEquals(expected, testFireControl.guessToHitModifierHelperForAnyAttack(mockShooter, 10, mockGame)); Mockito.when(mockShooterState.getPosition()).thenReturn(new Coords(0, 0)); Mockito.when(mockTargetState.getPosition()).thenReturn(null); expected = new ToHitData(FireControl.TH_NULL_POSITION); assertToHitDataEquals(expected, testFireControl.guessToHitModifierHelperForAnyAttack(mockShooter, 10, mockGame)); Mockito.when(mockTargetState.getPosition()).thenReturn(new Coords(10, 0)); Mockito.when(mockTargetState.getPosition()).thenReturn(new Coords(0, 1));
Mockito.anyInt(), Mockito.any(IGame.class)); mockTargetCoords = new Coords(0, 1); Mockito.when(mockTargetState.getPosition()).thenReturn(mockTargetCoords); Mockito.doReturn(true).when(testFireControl).isInArc(Mockito.any(Coords.class), Mockito.anyInt(), Mockito.any(Coords.class), Mockito.anyInt()); final IHex mockShooterHex = Mockito.mock(IHex.class); Mockito.when(mockShooterHex.getLevel()).thenReturn(0); Mockito.when(mockBoard.getHex(Mockito.eq(mockShooterState.getPosition()))).thenReturn(mockShooterHex); Mockito.when(mockShooter.getElevation()).thenReturn(0); Mockito.when(mockShooter.relHeight()).thenReturn(2); Mockito.when(mockBoard.getHex(Mockito.eq(mockTargetState.getPosition()))).thenReturn(mockTargetHex); Mockito.when(mockTarget.getElevation()).thenReturn(0); Mockito.when(mockTarget.getHeight()).thenReturn(2); PhysicalAttackType.LEFT_KICK, mockGame)); Mockito.when(mockTargetState.getPosition()).thenReturn(new Coords(0, 0)); // Move them into my hex. expected = new ToHitData(); expected.addModifier(mockCrew.getPiloting() - 2, FireControl.TH_PHY_BASE); PhysicalAttackType.LEFT_KICK, mockGame)); Mockito.when(mockTargetState.getPosition()).thenReturn(new Coords(0, 1)); Mockito.when(mockTargetState.getPosition()).thenReturn(new Coords(10, 10)); expected = new ToHitData(FireControl.TH_PHY_TOO_FAR); assertToHitDataEquals(expected, testFireControl.guessToHitModifierPhysical(mockShooter, mockShooterState,
Mockito.when(mockTargetState.getPosition()).thenReturn(new Coords(0, 15)); Mockito.when(mockShooter.hasQuirk(Mockito.eq(OptionsConstants.QUIRK_POS_IMP_TARG_L))).thenReturn(true); expected = new ToHitData(mockShooter.getCrew().getGunnery(), FireControl.TH_GUNNERY); mockWeapon, mockGame)); Mockito.when(mockShooter.hasQuirk(Mockito.eq(OptionsConstants.QUIRK_NEG_POOR_TARG_L))).thenReturn(false); Mockito.when(mockTargetState.getPosition()).thenReturn(mockTargetCoords); Mockito.when(mockTargetState.getPosition()).thenReturn(new Coords(0, 5)); Mockito.when(mockShooter.hasQuirk(Mockito.eq(OptionsConstants.QUIRK_POS_IMP_TARG_S))).thenReturn(true); expected = new ToHitData(mockShooter.getCrew().getGunnery(), FireControl.TH_GUNNERY); mockWeapon, mockGame)); Mockito.when(mockShooter.hasQuirk(Mockito.eq(OptionsConstants.QUIRK_NEG_POOR_TARG_S))).thenReturn(false); Mockito.when(mockTargetState.getPosition()).thenReturn(mockTargetCoords); Mockito.when(mockFighterState.isBuilding()).thenReturn(false); Mockito.when(mockFighterState.getHeat()).thenReturn(0); Mockito.when(mockFighterState.getPosition()).thenReturn(mockTargetCoords); expected = new ToHitData(mockShooter.getCrew().getGunnery(), FireControl.TH_GUNNERY); expected.addModifier(FireControl.TH_LONG_RANGE); Mockito.when(mockTargetState.getPosition()).thenReturn(new Coords(5, 0)); expected = new ToHitData(mockShooter.getCrew().getGunnery(), FireControl.TH_GUNNERY); expected.addModifier(FireControl.TH_SHORT_RANGE); mockTarget, mockTargetState, mockWeapon, mockGame)); Mockito.when(mockTargetState.getPosition()).thenReturn(new Coords(1, 0));
setDamageDirection(targetState, shooterState.getPosition());
final int distance = shooterState.getPosition().distance(targetState.getPosition()); if (1 < distance) { return new ToHitData(TH_PHY_TOO_FAR); if (!isInArc(shooterState.getPosition(), shooterState.getSecondaryFacing(), targetState.getPosition(), arc)) { return new ToHitData(TH_PHY_NOT_IN_ARC); final IHex attackerHex = game.getBoard().getHex(shooterState.getPosition()); final IHex targetHex = game.getBoard().getHex(targetState.getPosition()); final int attackerElevation = shooter.getElevation() + attackerHex.getLevel(); final int attackerHeight = shooter.relHeight() + attackerHex.getLevel();
if ((null == shooterState.getPosition()) || (null == targetState.getPosition())) { return new ToHitData(TH_NULL_POSITION); final IAero targetAero = (IAero) target; if (((Entity)targetAero).isNOE()) { final Coords closestInFlightPath = getNearestPointInFlightPath(shooterState.getPosition(), targetAero); final int aeroDistance = closestInFlightPath.distance(shooterState.getPosition()); if (1 >= aeroDistance) { toHitData.addModifier(TH_TAR_AERO_NOE_ADJ); final IHex targetHex = game.getBoard().getHex(targetState.getPosition()); int woodsLevel = targetHex.terrainLevel(Terrains.WOODS); if (targetHex.terrainLevel(Terrains.JUNGLE) > woodsLevel) {
shooterFacing = shooterState.getSecondaryFacing(); final boolean inArc = isInArc(shooterState.getPosition(), shooterFacing, targetState.getPosition(), shooter.getWeaponArc(shooter.getEquipmentNum(weapon))); if (!inArc) { int distance = shooterState.getPosition().distance(targetState.getPosition()); final LosEffects losEffects = getLosEffects(game, shooter.getId(), target, shooterState.getPosition(), targetState.getPosition(), false); final IHex targetHex = game.getBoard().getHex(targetState.getPosition()); Entity targetEntity = null; if (target instanceof Entity) {