Browse Source

Better code for trivia

tags/v1.8.0
Roxie Gibson 6 years ago
parent
commit
acf674e6ae
1 changed files with 6 additions and 6 deletions
  1. +6
    -6
      roxbot/cogs/trivia.py

+ 6
- 6
roxbot/cogs/trivia.py View File

incorrect = question["incorrect_answers"] incorrect = question["incorrect_answers"]
correct = question["correct_answer"] correct = question["correct_answer"]
choices = [correct, *incorrect] choices = [correct, *incorrect]
for x in range(len(choices)):
choices[x] = unescape(choices[x])
for x, choice in enumerate(choices):
choices[x] = unescape(choice)
shuffle(choices) shuffle(choices)


# Then get the index of the correct answer # Then get the index of the correct answer
correct = choices.index(unescape(correct)) correct = choices.index(unescape(correct))
# Create output # Create output
answers = "" answers = ""
for x in range(len(choices)):
answers += "{} {}\n".format(str(self.emojis[x]), choices[x])
for x, choice in enumerate(choices):
answers += "{} {}\n".format(str(self.emojis[x]), choice)
return embed, answers, correct return embed, answers, correct


def calculate_scores(self, channel, time_asked): def calculate_scores(self, channel, time_asked):
for x in range(amount): for x in range(amount):
await message.add_reaction(self.emojis[x]) await message.add_reaction(self.emojis[x])


async def game(self, ctx, channel, questions, *, mobile_comp=False, solo=False):
async def game(self, ctx, channel, questions, *, mobile_comp=False):
# For loop all the questions for the game, Maybe I should move the game dictionary here instead. # For loop all the questions for the game, Maybe I should move the game dictionary here instead.
question_count = 1 question_count = 1
for question in questions: for question in questions:
await ctx.send(embed=discord.Embed(description="Game isn't being played here.", colour=self.error_colour)) await ctx.send(embed=discord.Embed(description="Game isn't being played here.", colour=self.error_colour))


def setup(Bot): def setup(Bot):
Bot.add_cog(Trivia(Bot))
Bot.add_cog(Trivia(Bot))

Loading…
Cancel
Save