/** * @return The total heat for all weapons being fired with this plan. */ synchronized int getHeat() { int heat = 0; for (WeaponFireInfo weaponFireInfo : this) { heat += weaponFireInfo.getHeat(); } return heat; }
/** * Test to make sure that Princess will choose a FiringPlan that shots at * a MechWarrior, instead of choosing to do nothing. */ @Test public void testCalcFiringPlansAtMechwarrior() { mockTarget = Mockito.mock(MechWarrior.class); Mockito.when(mockPPCFireInfo.getProbabilityToHit()).thenReturn(0.6); Mockito.when(mockPPCFireInfo.getHeat()).thenReturn(10); Mockito.when(mockPPCFireInfo.getExpectedDamageOnHit()).thenReturn(10.0); Mockito.when(mockMLFireInfo.getProbabilityToHit()).thenReturn(0.6); Mockito.when(mockMLFireInfo.getHeat()).thenReturn(3); Mockito.when(mockMLFireInfo.getExpectedDamageOnHit()).thenReturn(5.0); Mockito.when(mockLRMFireInfo.getProbabilityToHit()).thenReturn(0.6); Mockito.when(mockLRMFireInfo.getHeat()).thenReturn(1); Mockito.when(mockLRMFireInfo.getExpectedDamageOnHit()).thenReturn(3.0); Mockito.doReturn(0.0).when(testFireControl).calcDamageAllocationUtility(Mockito.any(Targetable.class), Mockito.anyDouble()); Mockito.when(mockShooter.getPosition()).thenReturn(mockShooterCoords); Mockito.when(mockTarget.getPosition()).thenReturn(mockTargetCoords); Mockito.when(mockShooter.getWeaponList()).thenReturn(shooterWeapons); final FiringPlan plan = testFireControl.getBestFiringPlan(mockShooter, mockTarget, mockGame, testToHitThreshold); Assert.assertFalse("Expected not 0.0. Got " + plan.getUtility(), 0.00001 > Math.abs(0 - plan.getUtility())); } }
msg.append("\n\tHeat: ").append(getHeat());
Mockito.when(mockPPCFireInfo.getHeat()).thenReturn(10); Mockito.when(mockPPCFireInfo.getExpectedDamageOnHit()).thenReturn(10.0); Mockito.when(mockPPCFireInfo.getExpectedCriticals()).thenReturn(0.46); Mockito.when(mockMLFireInfo.getHeat()).thenReturn(3); Mockito.when(mockMLFireInfo.getExpectedDamageOnHit()).thenReturn(5.0); Mockito.when(mockMLFireInfo.getExpectedCriticals()).thenReturn(0.0); Mockito.when(mockLRMFireInfo.getHeat()).thenReturn(1); Mockito.when(mockLRMFireInfo.getExpectedDamageOnHit()).thenReturn(3.0); Mockito.when(mockLRMFireInfo.getExpectedCriticals()).thenReturn(0.0); final WeaponFireInfo mockMGFireInfo = Mockito.mock(WeaponFireInfo.class); Mockito.when(mockMGFireInfo.getProbabilityToHit()).thenReturn(0.6); Mockito.when(mockMGFireInfo.getHeat()).thenReturn(0); Mockito.when(mockMGFireInfo.getExpectedDamageOnHit()).thenReturn(2.0); Mockito.when(mockMGFireInfo.getExpectedCriticals()).thenReturn(0.0);
myPlan.getHeat() + shoot.getHeat() + shooter.getHeat() <= shooter.getHeatCapacity() && 0 < shoot.getExpectedDamage()) { myPlan.add(shoot);