Compare commits
3 Commits
d7f4540dcd
...
febdfaf355
Author | SHA1 | Date | |
---|---|---|---|
febdfaf355 | |||
9702e1e77a | |||
ff5e7f310a |
@ -27,6 +27,7 @@ class HelpManager(BaseGameManager):
|
||||
+ " You can also add a batter's guess with: "
|
||||
+ "!resolve <value> <discord id #> <guess>\n"
|
||||
+ "!points - Shows a table of the most recent players, and their scores\n"
|
||||
+ "!reset - Removes all the guesses"
|
||||
+ "!help - Shows this message"
|
||||
)
|
||||
|
||||
|
@ -14,11 +14,12 @@ from game.new_game import NewGameManager
|
||||
from game.end_game import EndGameManager
|
||||
from game.guess import GuessManager
|
||||
from game.points import PointsManager
|
||||
from game.reset import ResetManager
|
||||
from game.help import HelpManager
|
||||
|
||||
|
||||
class GameManager(
|
||||
NewGameManager, EndGameManager, GuessManager, PointsManager, HelpManager
|
||||
NewGameManager, EndGameManager, GuessManager, PointsManager, ResetManager, HelpManager
|
||||
):
|
||||
"""
|
||||
Represents what this bot is able to do on a channel (or DMs)
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
# pylint: disable=not-an-iterable,missing-module-docstring,too-few-public-methods
|
||||
|
||||
from beautifultable import BeautifulTable
|
||||
|
||||
from database.models import PlayerModel as Player
|
||||
from game.base import BaseGameManager
|
||||
|
||||
@ -23,22 +25,23 @@ class PointsManager(BaseGameManager):
|
||||
message = (
|
||||
"\nPlayers, who played recently, with their points highest to lowest\n\n"
|
||||
)
|
||||
message += "Player | Total Points | Last Played\n"
|
||||
|
||||
message += "```\n"
|
||||
table = BeautifulTable()
|
||||
table.column_headers = ["Player", "Total Points", "Last Played"]
|
||||
|
||||
players = Player.select(
|
||||
Player.player_name, Player.total_points, Player.last_update
|
||||
).order_by(Player.last_update.desc(), Player.total_points.desc())
|
||||
|
||||
for player in players:
|
||||
message += (
|
||||
" | ".join(
|
||||
[
|
||||
player.player_name,
|
||||
str(player.total_points),
|
||||
str(player.last_update)[:-10],
|
||||
]
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
table.rows.append([
|
||||
player.player_name,
|
||||
str(player.total_points),
|
||||
str(player.last_update)[:-10],
|
||||
])
|
||||
|
||||
message += str(table)
|
||||
message += "\n```\n"
|
||||
|
||||
return await self.message.channel.send(message)
|
||||
|
@ -47,7 +47,7 @@ class ProcessGuess:
|
||||
& (Guess.guess > 0)
|
||||
& (Guess.player.player_id == Player.player_id)
|
||||
)
|
||||
.order_by(Guess.guess)
|
||||
.order_by(Guess.difference)
|
||||
)
|
||||
return self.guesses
|
||||
|
||||
|
22
game/reset.py
Normal file
22
game/reset.py
Normal file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright 2022 - c0de <c0de@c0de.dev>
|
||||
# Licensed under the MIT License (https://opensource.org/licenses/MIT)
|
||||
|
||||
# pylint: disable=missing-module-docstring,too-few-public-methods
|
||||
|
||||
from database.models import GuessModel as Guess
|
||||
from game.base import BaseGameManager
|
||||
|
||||
|
||||
class ResetManager(BaseGameManager):
|
||||
"""Commands that run when a player asks for help"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.commands.append(("reset", self.reset))
|
||||
|
||||
async def reset(self):
|
||||
"""Reset command purges all guesses"""
|
||||
Guess.delete().where(True).execute()
|
||||
|
||||
return await self.message.channel.send("ok")
|
Loading…
Reference in New Issue
Block a user