add calculate_sword_damage()
from discord.ext import commands
+import random
+import math
class MobSpawner:
@@ -32,6 +34,32 @@ class MobSpawner:
return commands.check(predicate)
+ async def calculate_sword_damage(self, uid: int, sword: str, multi: float) -> int:
+ if sword == "Netherite Sword":
+ damage = random.randint(7, 10)
+ elif sword == "Diamond Sword":
+ damage = random.randint(6, 7)
+ elif sword == "Gold Sword":
+ damage = random.randint(4, 5)
+ elif sword == "Iron Sword":
+ damage = random.randint(2, 4)
+ elif sword == "Stone Sword":
+ damage = random.randint(1, 3)
+ elif sword == "Wood Sword":
+ damage = random.randint(1, 2)
+ else:
+ raise ValueError(f"{repr(sword)} is not a valid sword.")
+
+ if await self.db.fetch_item(uid, "Sharpness II Book") is not None:
+ damage *= 1.5
+ elif await self.db.fetch_item(uid, "Sharpness I Book") is not None:
+ damage *= 1.25
+
+ if multi > 1:
+ damage /= 1.3
+
+ return math.ceil(damage)
+
def setup(bot):
bot.add_cog(MobSpawner(bot))
