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: "
|
+ " You can also add a batter's guess with: "
|
||||||
+ "!resolve <value> <discord id #> <guess>\n"
|
+ "!resolve <value> <discord id #> <guess>\n"
|
||||||
+ "!points - Shows a table of the most recent players, and their scores\n"
|
+ "!points - Shows a table of the most recent players, and their scores\n"
|
||||||
|
+ "!reset - Removes all the guesses"
|
||||||
+ "!help - Shows this message"
|
+ "!help - Shows this message"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -14,11 +14,12 @@ from game.new_game import NewGameManager
|
|||||||
from game.end_game import EndGameManager
|
from game.end_game import EndGameManager
|
||||||
from game.guess import GuessManager
|
from game.guess import GuessManager
|
||||||
from game.points import PointsManager
|
from game.points import PointsManager
|
||||||
|
from game.reset import ResetManager
|
||||||
from game.help import HelpManager
|
from game.help import HelpManager
|
||||||
|
|
||||||
|
|
||||||
class GameManager(
|
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)
|
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
|
# pylint: disable=not-an-iterable,missing-module-docstring,too-few-public-methods
|
||||||
|
|
||||||
|
from beautifultable import BeautifulTable
|
||||||
|
|
||||||
from database.models import PlayerModel as Player
|
from database.models import PlayerModel as Player
|
||||||
from game.base import BaseGameManager
|
from game.base import BaseGameManager
|
||||||
|
|
||||||
@@ -23,22 +25,23 @@ class PointsManager(BaseGameManager):
|
|||||||
message = (
|
message = (
|
||||||
"\nPlayers, who played recently, with their points highest to lowest\n\n"
|
"\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(
|
players = Player.select(
|
||||||
Player.player_name, Player.total_points, Player.last_update
|
Player.player_name, Player.total_points, Player.last_update
|
||||||
).order_by(Player.last_update.desc(), Player.total_points.desc())
|
).order_by(Player.last_update.desc(), Player.total_points.desc())
|
||||||
|
|
||||||
for player in players:
|
for player in players:
|
||||||
message += (
|
table.rows.append([
|
||||||
" | ".join(
|
player.player_name,
|
||||||
[
|
str(player.total_points),
|
||||||
player.player_name,
|
str(player.last_update)[:-10],
|
||||||
str(player.total_points),
|
])
|
||||||
str(player.last_update)[:-10],
|
|
||||||
]
|
message += str(table)
|
||||||
)
|
message += "\n```\n"
|
||||||
+ "\n"
|
|
||||||
)
|
|
||||||
|
|
||||||
return await self.message.channel.send(message)
|
return await self.message.channel.send(message)
|
||||||
|
@@ -47,7 +47,7 @@ class ProcessGuess:
|
|||||||
& (Guess.guess > 0)
|
& (Guess.guess > 0)
|
||||||
& (Guess.player.player_id == Player.player_id)
|
& (Guess.player.player_id == Player.player_id)
|
||||||
)
|
)
|
||||||
.order_by(Guess.guess)
|
.order_by(Guess.difference)
|
||||||
)
|
)
|
||||||
return self.guesses
|
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")
|
Reference in New Issue
Block a user