@Before public void setUp() { mockTarget = Mockito.mock(Targetable.class); testFiringPlan = Mockito.spy(new FiringPlan(mockTarget)); mockWeaponFireInfoMG = Mockito.mock(WeaponFireInfo.class); testFiringPlan.add(mockWeaponFireInfoMG); Mounted mockMG = Mockito.mock(Mounted.class); Mockito.when(mockWeaponFireInfoMG.getWeapon()).thenReturn(mockMG); mockWeaponAttackActionMG = Mockito.mock(WeaponAttackAction.class); Mockito.when(mockWeaponFireInfoMG.getWeaponAttackAction()).thenReturn(mockWeaponAttackActionMG); mockWeaponFireInfoPPC = Mockito.mock(WeaponFireInfo.class); testFiringPlan.add(mockWeaponFireInfoPPC); mockPPC = Mockito.mock(Mounted.class); Mockito.when(mockWeaponFireInfoPPC.getWeapon()).thenReturn(mockPPC); mockWeaponAttackActionPPC = Mockito.mock(WeaponAttackAction.class); Mockito.when(mockWeaponFireInfoPPC.getWeaponAttackAction()).thenReturn(mockWeaponAttackActionPPC); mockWeaponFireInfoERML = Mockito.mock(WeaponFireInfo.class); testFiringPlan.add(mockWeaponFireInfoERML); Mounted mockERML = Mockito.mock(Mounted.class); Mockito.when(mockWeaponFireInfoERML.getWeapon()).thenReturn(mockERML); mockWeaponAttackActionERML = Mockito.mock(WeaponAttackAction.class); Mockito.when(mockWeaponFireInfoERML.getWeaponAttackAction()).thenReturn(mockWeaponAttackActionERML); }
@Test public void testGetEntityActionVector() { Vector<EntityAction> expected; // Test a no-twist plan. Mockito.when(testFiringPlan.getTwist()).thenReturn(0); expected = new Vector<>(3); expected.add(mockWeaponAttackActionMG); expected.add(mockWeaponAttackActionPPC); expected.add(mockWeaponAttackActionERML); Assert.assertEquals(expected, testFiringPlan.getEntityActionVector()); // todo Test torso-twists. // Test an empty firing plan. //noinspection MismatchedQueryAndUpdateOfCollection FiringPlan emptyPlan = new FiringPlan(mockTarget); expected = new Vector<>(0); Assert.assertEquals(expected, emptyPlan.getEntityActionVector()); }
private FiringPlan getBestFiringPlanUnderHeat(final Targetable target, final Entity shooter, final FiringPlan[] allPlans) { // Determine the best plan taking into account our heat tolerance. FiringPlan bestPlan = new FiringPlan(target); final boolean isAero = shooter.isAero(); final int heatTolerance = calcHeatTolerance(shooter, isAero); calculateUtility(bestPlan, heatTolerance, isAero); for (final FiringPlan firingPlan : allPlans) { calculateUtility(firingPlan, heatTolerance, isAero); if ((bestPlan.getUtility() < firingPlan.getUtility())) { bestPlan = firingPlan; } } return bestPlan; }
expected = new FiringPlan(mockTarget); expected.add(mockPPCFireInfo); expected.add(mockLRMFireInfo); expected = new FiringPlan(mockTarget); Assert.assertEquals(expected, testFireControl.guessFullFiringPlan(mockShooter, mockShooterState, mockTarget, mockTargetState, mockGame)); expected = new FiringPlan(mockTarget); Assert.assertEquals(expected, testFireControl.guessFullFiringPlan(mockShooter, mockShooterState, mockTarget, mockTargetState, mockGame));
expected = new FiringPlan(mockTarget); expected.add(mockPPCFireInfo); expected.add(mockLRMFireInfo); expected = new FiringPlan(mockTarget); Assert.assertEquals(expected, testFireControl.guessFullAirToGroundPlan(mockShooter, mockTarget, mockTargetState, mockFlightPath, expected = new FiringPlan(mockTarget); Assert.assertEquals(expected, testFireControl.guessFullAirToGroundPlan(mockShooter, mockTarget, mockTargetState, mockFlightPath,
expected = new FiringPlan(mockTarget); expected.add(mockPPCFireInfo); expected.add(mockLRMFireInfo); expected = new FiringPlan(mockTarget); Assert.assertEquals(expected, testFireControl.getFullFiringPlan(mockShooter, mockTarget, testToHitThreshold, mockGame)); expected = new FiringPlan(mockTarget); Assert.assertEquals(expected, testFireControl.getFullFiringPlan(mockShooter, mockTarget, testToHitThreshold, mockGame)); expected = new FiringPlan(mockTarget); expected.add(mockPPCFireInfo); Assert.assertEquals(expected, testFireControl.getFullFiringPlan(mockShooter, mockTarget,
Mockito.when(mockAmmoTypeSRM.getDamagePerShot()).thenReturn(2); FiringPlan testPlan = Mockito.spy(new FiringPlan(mockTarget)); testPlan.add(mockInfoLL); testPlan.add(mockInfoSRM); FiringPlan expectedOrder = new FiringPlan(mockTarget); expectedOrder.add(mockInfoLL); expectedOrder.add(mockInfoSRM); testPlan.add(mockInfoLL); testPlan.add(mockInfoSRM); expectedOrder = new FiringPlan(mockTarget); expectedOrder.add(mockInfoLBX); expectedOrder.add(mockInfoLL);
final boolean passedOverTarget, final boolean guess) { final FiringPlan diveBombPlan = new FiringPlan(target); final HexTarget hexToBomb = new HexTarget(target.getPosition(), game.getBoard(), shooter.isAero() ? Targetable.TYPE_HEX_AERO_BOMB : Targetable.TYPE_HEX_BOMB);
final NumberFormat DECF = new DecimalFormat("0.000"); final FiringPlan myPlan = new FiringPlan(target);
bestPlans[0] = new FiringPlan(target, alphaStrike.getFlipArms()); final FiringPlan nonZeroHeatOptions = new FiringPlan(target); final FiringPlan swarmAttack = new FiringPlan(target); final FiringPlan legAttack = new FiringPlan(target); final FiringPlan fieldGuns = new FiringPlan(target); double fieldGunMassAlreadyFired = 0.0; //We need to track the tonnage of field guns being fired, because trying to fire more than the current possible total(# of men left) results in nothing being fired. for (final WeaponFireInfo weaponFireInfo : alphaStrike) { bestPlans[heatLevel] = new FiringPlan(target); final FiringPlan testPlan = new FiringPlan(target, alphaStrike.getFlipArms()); testPlan.addAll(bestPlans[heatLevel - weaponFireInfo.getHeat()]); testPlan.add(weaponFireInfo);
@Test public void testCalcFiringPlansUnderHeat() { final FiringPlan alphaStrike = new FiringPlan(mockTarget); expected[0] = new FiringPlan(mockTarget); expected[0].add(mockMGFireInfo); expected[0].setUtility(1.2); expected[1] = new FiringPlan(mockTarget); expected[1].add(mockMGFireInfo); expected[1].add(mockLRMFireInfo); expected[1].setUtility(3.0); expected[2] = new FiringPlan(mockTarget); expected[2].add(mockMGFireInfo); expected[2].add(mockLRMFireInfo); expected[2].setUtility(3.0); expected[3] = new FiringPlan(mockTarget); expected[3].add(mockMGFireInfo); expected[3].add(mockMLFireInfo); expected[3].setUtility(4.2); expected[4] = new FiringPlan(mockTarget); expected[4].add(mockMGFireInfo); expected[4].add(mockLRMFireInfo); expected[4].add(mockMLFireInfo); expected[4].setUtility(6.0); expected[5] = new FiringPlan(mockTarget); expected[5].add(mockMGFireInfo); expected[5].add(mockLRMFireInfo); expected[5].add(mockMLFireInfo); expected[5].setUtility(6.0); expected[6] = new FiringPlan(mockTarget);
FiringPlan testFiringPlan = Mockito.spy(new FiringPlan(mockTarget)); Mockito.doReturn(15.0).when(testFiringPlan).getExpectedDamage(); Mockito.doReturn(0.46129).when(testFiringPlan).getExpectedCriticals(); testFiringPlan = Mockito.spy(new FiringPlan(mockTarget)); Mockito.doReturn(15.0).when(testFiringPlan).getExpectedDamage(); Mockito.doReturn(0.46129).when(testFiringPlan).getExpectedCriticals(); testFiringPlan = Mockito.spy(new FiringPlan(mockTarget)); Mockito.doReturn(15.0).when(testFiringPlan).getExpectedDamage(); Mockito.doReturn(0.46129).when(testFiringPlan).getExpectedCriticals(); testTargets.add("0606"); Mockito.when(mockBehavior.getStrategicBuildingTargets()).thenReturn(testTargets); testFiringPlan = Mockito.spy(new FiringPlan(mockBuilding)); Mockito.doReturn(15.0).when(testFiringPlan).getExpectedDamage(); Mockito.doReturn(0.46129).when(testFiringPlan).getExpectedCriticals(); TOLERANCE); Mockito.when(mockBuilding.getPosition()).thenReturn(new Coords(10, 10)); // A building not on the list. testFiringPlan = Mockito.spy(new FiringPlan(mockBuilding)); Mockito.doReturn(15.0).when(testFiringPlan).getExpectedDamage(); Mockito.doReturn(0.46129).when(testFiringPlan).getExpectedCriticals(); testPriorityUnits.add(MOCK_TARGET_ID); Mockito.when(mockPrincess.getPriorityUnitTargets()).thenReturn(testPriorityUnits); testFiringPlan = Mockito.spy(new FiringPlan(mockTarget)); Mockito.doReturn(15.0).when(testFiringPlan).getExpectedDamage(); Mockito.doReturn(0.46129).when(testFiringPlan).getExpectedCriticals();
FiringPlan retval = new FiringPlan();
return new FiringPlan(target); final FiringPlan myPlan = new FiringPlan(target);
FiringPlan bestPlan = new FiringPlan(target);
final FiringPlan myPlan = new FiringPlan(target);