/** * Constructor including the shooter and target's state information. * * @param shooter The {@link megamek.common.Entity} doing the attacking. * @param shooterState The current {@link megamek.client.bot.princess.EntityState} of the attacker. * @param target The {@link megamek.common.Targetable} of the attack. * @param targetState The current {@link megamek.client.bot.princess.EntityState} of the target. * @param physicalAttackType The type of attack being made. * @param game The {@link megamek.common.IGame} in progress. * @param owner The owning {@link Princess} bot. * @param guess Set TRUE to estimate the chance to hit rather than doing the full calculation. */ PhysicalInfo(Entity shooter, EntityState shooterState, Targetable target, EntityState targetState, PhysicalAttackType physicalAttackType, IGame game, Princess owner, boolean guess) { this.owner = owner; setShooter(shooter); setTarget(target); setAttackType(physicalAttackType); initDamage(physicalAttackType, shooterState, targetState, guess, game); }
testPhysicalInfo.setAttackType(punch); testPhysicalInfo.initDamage(punch, mockShooterState, mockTargetState, true, mockGame); Assert.assertEquals(0.583, testPhysicalInfo.getProbabilityToHit(), TOLERANCE); testPhysicalInfo.setAttackType(kick); testPhysicalInfo.initDamage(kick, mockShooterState, mockTargetState, true, mockGame); Assert.assertEquals(0.583, testPhysicalInfo.getProbabilityToHit(), TOLERANCE); testPhysicalInfo.setAttackType(punch); testPhysicalInfo.initDamage(punch, mockShooterState, mockTargetState, true, mockGame); Assert.assertEquals(0.583, testPhysicalInfo.getProbabilityToHit(), TOLERANCE); Mockito.when(mockShooter.getWeight()).thenReturn(100.0); testPhysicalInfo.setShooter(mockShooter); testPhysicalInfo.setAttackType(punch); testPhysicalInfo.initDamage(punch, mockShooterState, mockTargetState, true, mockGame); Assert.assertEquals(0.583, testPhysicalInfo.getProbabilityToHit(), TOLERANCE);