From 6c1ffbb3268ee2d3ee47c8ecbbbaff624af4fcdf Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 22 Nov 2023 21:58:44 +0100 Subject: [PATCH] Le funny professor duck just got an upgrade (they will love me for sure) --- src/utils/ducks.py | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/utils/ducks.py b/src/utils/ducks.py index 5d547ef9..200a2d72 100644 --- a/src/utils/ducks.py +++ b/src/utils/ducks.py @@ -24,6 +24,18 @@ HOUR = 60 * MINUTE DAY = 24 * HOUR +PRADD_MIN = 0 +PRADD_MAX = 122 + +PRMUL_MIN = 0 +PRMUL_MAX = 13 + +PRDIV_MIN = 1 +PRDIV_MAX = 15 + +PRSUB_MIN = 0 +PRSUB_MAX = 222 + def _(s): return s @@ -711,10 +723,26 @@ class PrDuck(Duck): def __init__(self, bot: MyBot, channel: discord.TextChannel): super().__init__(bot, channel) - r1 = random.randint(0, 100) - r2 = random.randint(0, 100) - self.operation = f"{r1} + {r2}" - self.answer = r1 + r2 + op = random.choices(["+", "*", "/", "-"], weights=[100, 10, 5, 50]) + + if op == "+": + r1 = random.randint(PRADD_MIN, PRADD_MAX) + r2 = random.randint(PRADD_MIN, PRADD_MAX) + self.answer = r1 + r2 + elif op == "*": + r1 = random.randint(PRMUL_MIN, PRMUL_MAX) + r2 = random.randint(PRMUL_MIN, PRMUL_MAX) + self.answer = r1 * r2 + elif op == "/": + r2 = random.randint(PRDIV_MIN, PRDIV_MAX) + r1 = random.randint(PRDIV_MIN, PRDIV_MAX) * r2 # Trick it so that you can always divide properly and makes it very easy too + self.answer = int(r1 / r2) + else: + r1 = random.randint(PRSUB_MIN, PRSUB_MAX) + r2 = random.randint(PRSUB_MIN, PRSUB_MAX) + self.answer = r1 - r2 + + self.operation = f"{r1} {op} {r2}" def serialize(self): return {