diff options
author | 2019-03-19 23:09:42 +0000 | |
---|---|---|
committer | 2019-03-19 23:09:42 +0000 | |
commit | 722ed131b59982caf8e54ca8bfbc36989ec2aae4 (patch) | |
tree | b3f242431a2756672a7eeedb28b40d3d2569e3e2 | |
parent | Spooky Rating (diff) |
Spooky Rating - Fixed Requested Changes
- Removed the documentation on how Users are converted
- Changed random to a local state rather than using global seed
- Changed the JSON minimum to -1 due to how bisect works
-rw-r--r-- | bot/resources/halloween/spooky_rating.json | 2 | ||||
-rw-r--r-- | bot/seasons/halloween/spookyrating.py | 14 |
2 files changed, 4 insertions, 12 deletions
diff --git a/bot/resources/halloween/spooky_rating.json b/bot/resources/halloween/spooky_rating.json index 2c459926..b83624fe 100644 --- a/bot/resources/halloween/spooky_rating.json +++ b/bot/resources/halloween/spooky_rating.json @@ -1,5 +1,5 @@ { - "0": { + "-1": { "title": "\uD83D\uDD6F You're not scarin' anyone \uD83D\uDD6F", "text": "No matter what you say or do, nobody even flinches when you try to scare them. Was your costume this year only a white sheet with holes for eyes? Or did you even bother with a costume at all? Either way, don't expect too many treats when going from door-to-door.", "image": "https://www.thoughtco.com/thmb/qv6FUFM6V_p7YUAk9lT6fZG8s3M=/768x0/filters:no_upscale():max_bytes(150000):strip_icc()/smoke-trailing-from-extinguished-white-candle-565954737-584daec23df78c491e6282a5.jpg" diff --git a/bot/seasons/halloween/spookyrating.py b/bot/seasons/halloween/spookyrating.py index 92f71b9e..8c4f1b12 100644 --- a/bot/seasons/halloween/spookyrating.py +++ b/bot/seasons/halloween/spookyrating.py @@ -23,6 +23,7 @@ class SpookyRating: def __init__(self, bot): self.bot = bot + self.local_random = random.Random() @commands.command() @commands.cooldown(rate=1, per=5, type=commands.BucketType.user) @@ -30,14 +31,6 @@ class SpookyRating: """ Calculates the spooky rating of someone. - This command accepts an optional user as an argument, defaulting to the command executor. - Users are converted from: - - User ID - - Mention - - name#discrim - - name - - nickname - Any user will always yield the same result, no matter who calls the command """ @@ -45,9 +38,8 @@ class SpookyRating: who = ctx.author # This ensures that the same result over multiple runtimes - random.seed(who.id) - - spooky_percent = random.randint(1, 100) + self.local_random.seed(who.id) + spooky_percent = self.local_random.randint(1, 101) # We need the -1 due to how bisect returns the point # see the documentation for further detail |