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_weapon_lookup_damage_bad_index(): w = Weapon(range(7)) with pytest.raises(ValueError): w.lookup_damage(0)
def test_weapon_lookup_damage_ceiling(): damage = range(7) w = Weapon(damage) assert w.lookup_damage(9) == damage[6]
def test_weapon_lookup_damage(): damage = range(7) w = Weapon(damage) assert w.lookup_damage(4) == damage[3]