def __init__(self, ctx, weapon: Weapon, armor: str, bonus: int, **kwargs): super(EmbedDamage, self).__init__(ctx, **kwargs) roll = weapon.roll_damage(armor, bonus) damage_dealt = weapon.lookup_damage(roll.total) self.title = f"{weapon.name} Damage ({damage_dealt})" table = "" for indx, d in enumerate(weapon.damage): table += str(d) if indx + 1 is not roll.total else f"__**{d}**__" if len(weapon.damage) - 1 is not indx: table += " | " table = f" {table} " dmg_txt = f"Damage Dealt:\n{table}\n\n**{damage_dealt}** damage was dealt." roll_breakdown_txt = f"Roll Breakdown:\n{roll.result}" self.description = f"\n{roll_breakdown_txt}\n\n{dmg_txt}"
def test_attack_damage_mod_roll(mocker): '''Sometimes there are bonuses on damage rolls''' mocker.patch.object(dice, 'roll_d6', return_value=2) w = Weapon(range(7)) r = w.roll_damage(damage_bonus=2) assert r.total == 4
def test_armor_offset_unarmored_roll(mocker): '''Ignoring armor should have no effect on unarmored foes''' mocker.patch.object(dice, 'roll_d6', return_value=2) w = Weapon(range(7), ignore_armor=True) r = w.roll_damage() assert r.total == 2
def test_ignore_armor_offset_roll(mocker): '''Some weapons ignore one point of the armor offset''' mocker.patch.object(dice, 'roll_d6', return_value=3) w = Weapon(range(7), ignore_armor=True) r = w.roll_damage(armor="Moderate") assert r.total == 2
def test_basic_armor_offset_roll(mocker): '''Armor offset should reduce damage roll to a minimum of 1''' mocker.patch.object(dice, 'roll_d6', return_value=2) w = Weapon(range(7)) r = w.roll_damage(armor="Medium") assert r.total == 1
def test_basic_damage_roll(mocker): '''A basic test of damage rolls''' mocker.patch.object(dice, 'roll_d6', return_value=4) w = Weapon(range(7)) r = w.roll_damage() assert r.total == 4