*/
@SuppressWarnings("null")
@Test
public void testAttackCanHitreturnTruedamage30() {
MockStendlRPWorld.get();
final StendhalRPZone zone = new StendhalRPZone("testzone");
final RPEntity attacker = new RPEntity() {
@Override
protected void dropItemsOn(final Corpse corpse) {
// do nothing
}
@Override
public boolean canHit(final RPEntity defender) {
return true;
}
@Override
public int damageDone(final RPEntity defender, double attackingWeaponsValue, Nature damageType) {
return 30;
}
@Override
public void logic() {
// do nothing
}
};
final RPEntity defender = new RPEntity() {
@Override
protected void dropItemsOn(final Corpse corpse) {
// do nothing
}
@Override
public void onDamaged(final Entity attacker, final int damage) {
assertEquals(30, damage);
}
@Override
public void logic() {
// do nothing
}
};
zone.add(attacker);
zone.add(defender);
attacker.setTarget(defender);
defender.setHP(100);
assertTrue(zone.has(defender.getID()));
assertThat(defender.getHP(), greaterThan(0));
for (RPEvent ev : attacker.events()) {
assertFalse(ev instanceof AttackEvent);
}