From eb8b884d470539e2fab459602f1f7910e99b002a Mon Sep 17 00:00:00 2001 From: ddorn Date: Mon, 27 Apr 2020 23:11:49 +0200 Subject: [PATCH] :sparkles: don't draw problems that can't be accepted --- src/cogs/tirage_logic.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cogs/tirage_logic.py b/src/cogs/tirage_logic.py index 3de1836..972e9db 100644 --- a/src/cogs/tirage_logic.py +++ b/src/cogs/tirage_logic.py @@ -222,7 +222,7 @@ class Phase: async def dice(self, ctx: Context, author, dice): raise UnwantedCommand() - async def choose_problem(self, ctx: Context, author, problem): + async def choose_problem(self, ctx: Context, author): raise UnwantedCommand() async def accept(self, ctx: Context, author, yes): @@ -319,7 +319,7 @@ class TiragePhase(Phase): def available(self, problem): return all(team.accepted_problems[self.round] != problem for team in self.teams) - async def choose_problem(self, ctx: Context, author, problem): + async def choose_problem(self, ctx: Context, author): team = self.current_team if self.team_for(author) != team: raise UnwantedCommand( @@ -337,6 +337,12 @@ class TiragePhase(Phase): "ou de le refuser (`!no)`." ) + # Choose an *available* problem + problems = [ + p for p in PROBLEMS if self.available(p) and not p in team.accepted_problems + ] + problem = random.choice(problems) + await ctx.send(f"{team.mention} a tiré **{problem}** !") if not self.available(problem): await ctx.send(