Browse Source

Trying to get the leaderboard ordering to work.

tags/v1.4.0
roxie 6 years ago
parent
commit
c0952d6ccf
2 changed files with 4 additions and 2 deletions
  1. +3
    -2
      cogs/trivia.py
  2. +1
    -0
      load_config.py

+ 3
- 2
cogs/trivia.py View File

import datetime import datetime
from html import unescape from html import unescape
from random import shuffle from random import shuffle
from operator import itemgetter
from collections import OrderedDict from collections import OrderedDict
from discord.ext import commands from discord.ext import commands




def sort_leaderboard(self, scores): def sort_leaderboard(self, scores):
# TODO: Fix this so it works. # TODO: Fix this so it works.
return OrderedDict(sorted(scores.items(), key=lambda kv: kv))
return OrderedDict(sorted(scores.items(), key=scores.get))


def display_leaderboard(self, channel, scores_to_add): def display_leaderboard(self, channel, scores_to_add):
updated_scores = dict(self.games[channel.id]["players"]) updated_scores = dict(self.games[channel.id]["players"])
if not self.games[channel.id]["players"]: if not self.games[channel.id]["players"]:
await message.clear_reactions() await message.clear_reactions()
await ctx.send("No more players to play the game") await ctx.send("No more players to play the game")
break
return False


# Clean up when answers have been submitted # Clean up when answers have been submitted
self.games[channel.id]["current_question"] = None self.games[channel.id]["current_question"] = None

+ 1
- 0
load_config.py View File

"cogs.nsfw", "cogs.nsfw",
"cogs.reddit", "cogs.reddit",
"cogs.selfassign", "cogs.selfassign",
"cogs.trivia",
"cogs.twitch", "cogs.twitch",
"cogs.util", "cogs.util",
#"cogs.gss" #"cogs.gss"

Loading…
Cancel
Save