Compare commits
2 Commits
292db8133d
...
fd5f5a7e7a
Author | SHA1 | Date | |
---|---|---|---|
fd5f5a7e7a | |||
fc2fe0a396 |
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
FROM python:3.10-alpine3.16 AS build
|
FROM python:3.10-alpine3.16 AS build
|
||||||
|
|
||||||
RUN pip install --no-cache-dir discord peewee beautifultable
|
RUN pip install --no-cache-dir discord peewee
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
1
Pipfile
1
Pipfile
@ -8,7 +8,6 @@ discord = "*"
|
|||||||
peewee = "*"
|
peewee = "*"
|
||||||
pylint = "*"
|
pylint = "*"
|
||||||
black = "*"
|
black = "*"
|
||||||
beautifultable = "*"
|
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
|
|
||||||
|
33
Pipfile.lock
generated
33
Pipfile.lock
generated
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "171e06b48e5905ea64caab54728c14bd65292a2957b33964c688f2172e677b62"
|
"sha256": "b6fb0d9cfe588eab84db4024e6b319681e9e70d00c74282b6722fe283ac3e348"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -106,7 +106,7 @@
|
|||||||
"sha256:f973157ffeab5459eefe7b97a804987876dd0a55570b8fa56b4e1954bf11329b",
|
"sha256:f973157ffeab5459eefe7b97a804987876dd0a55570b8fa56b4e1954bf11329b",
|
||||||
"sha256:ff25f48fc8e623d95eca0670b8cc1469a83783c924a602e0fbd47363bb54aaca"
|
"sha256:ff25f48fc8e623d95eca0670b8cc1469a83783c924a602e0fbd47363bb54aaca"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.6'",
|
"markers": "python_full_version >= '3.6.0'",
|
||||||
"version": "==3.8.3"
|
"version": "==3.8.3"
|
||||||
},
|
},
|
||||||
"aiosignal": {
|
"aiosignal": {
|
||||||
@ -130,7 +130,7 @@
|
|||||||
"sha256:2163e1640ddb52b7a8c80d0a67a08587e5d245cc9c553a74a847056bc2976b15",
|
"sha256:2163e1640ddb52b7a8c80d0a67a08587e5d245cc9c553a74a847056bc2976b15",
|
||||||
"sha256:8ca1e4fcf50d07413d66d1a5e416e42cfdf5851c981d679a09851a6853383b3c"
|
"sha256:8ca1e4fcf50d07413d66d1a5e416e42cfdf5851c981d679a09851a6853383b3c"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.6'",
|
"markers": "python_full_version >= '3.6.0'",
|
||||||
"version": "==4.0.2"
|
"version": "==4.0.2"
|
||||||
},
|
},
|
||||||
"attrs": {
|
"attrs": {
|
||||||
@ -141,14 +141,6 @@
|
|||||||
"markers": "python_version >= '3.5'",
|
"markers": "python_version >= '3.5'",
|
||||||
"version": "==22.1.0"
|
"version": "==22.1.0"
|
||||||
},
|
},
|
||||||
"beautifultable": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:040bc987444965678f4ffdfa2f17ac357f1a13e5875b161c9a1899b375319d17",
|
|
||||||
"sha256:b34053a581976c4c23064bb0e918a7f6f22273cf196c787946db323a6a2b7d84"
|
|
||||||
],
|
|
||||||
"index": "pypi",
|
|
||||||
"version": "==1.1.0"
|
|
||||||
},
|
|
||||||
"black": {
|
"black": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:101c69b23df9b44247bd88e1d7e90154336ac4992502d4197bdac35dd7ee3320",
|
"sha256:101c69b23df9b44247bd88e1d7e90154336ac4992502d4197bdac35dd7ee3320",
|
||||||
@ -172,7 +164,7 @@
|
|||||||
"sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845",
|
"sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845",
|
||||||
"sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f"
|
"sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.6'",
|
"markers": "python_full_version >= '3.6.0'",
|
||||||
"version": "==2.1.1"
|
"version": "==2.1.1"
|
||||||
},
|
},
|
||||||
"click": {
|
"click": {
|
||||||
@ -333,7 +325,7 @@
|
|||||||
"sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325",
|
"sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325",
|
||||||
"sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"
|
"sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.6'",
|
"markers": "python_full_version >= '3.6.0'",
|
||||||
"version": "==0.7.0"
|
"version": "==0.7.0"
|
||||||
},
|
},
|
||||||
"multidict": {
|
"multidict": {
|
||||||
@ -425,11 +417,11 @@
|
|||||||
},
|
},
|
||||||
"pathspec": {
|
"pathspec": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:88c2606f2c1e818b978540f73ecc908e13999c6c3a383daf3705652ae79807a5",
|
"sha256:3c95343af8b756205e2aba76e843ba9520a24dd84f68c22b9f93251507509dd6",
|
||||||
"sha256:8f6bf73e5758fd365ef5d58ce09ac7c27d2833a8d7da51712eac6e27e35141b0"
|
"sha256:56200de4077d9d0791465aa9095a01d421861e405b5096955051deefd697d6f6"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.7'",
|
"markers": "python_version >= '3.7'",
|
||||||
"version": "==0.10.2"
|
"version": "==0.10.3"
|
||||||
},
|
},
|
||||||
"peewee": {
|
"peewee": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
@ -467,16 +459,9 @@
|
|||||||
"sha256:07de26b0d8cfc18f871aec595fda24d95b08fef89d147caa861939f37230bf4b",
|
"sha256:07de26b0d8cfc18f871aec595fda24d95b08fef89d147caa861939f37230bf4b",
|
||||||
"sha256:71b952e5721688937fb02cf9d354dbcf0785066149d2855e44531ebdd2b65d73"
|
"sha256:71b952e5721688937fb02cf9d354dbcf0785066149d2855e44531ebdd2b65d73"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.6'",
|
"markers": "python_full_version >= '3.6.0'",
|
||||||
"version": "==0.11.6"
|
"version": "==0.11.6"
|
||||||
},
|
},
|
||||||
"wcwidth": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784",
|
|
||||||
"sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83"
|
|
||||||
],
|
|
||||||
"version": "==0.2.5"
|
|
||||||
},
|
|
||||||
"wrapt": {
|
"wrapt": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:00b6d4ea20a906c0ca56d84f93065b398ab74b927a7a3dbd470f6fc503f95dc3",
|
"sha256:00b6d4ea20a906c0ca56d84f93065b398ab74b927a7a3dbd470f6fc503f95dc3",
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from beautifultable import BeautifulTable
|
|
||||||
|
|
||||||
from database.models import GameModel as Game, GuessModel as Guess
|
from database.models import GameModel as Game, GuessModel as Guess
|
||||||
from game.base import BaseGameManager
|
from game.base import BaseGameManager
|
||||||
from game.process_guess import ProcessGuess
|
from game.process_guess import ProcessGuess
|
||||||
@ -84,33 +82,26 @@ class EndGameManager(BaseGameManager):
|
|||||||
("Play closed!\n" + "However, there were not enough participants.")
|
("Play closed!\n" + "However, there were not enough participants.")
|
||||||
)
|
)
|
||||||
|
|
||||||
message = "Closed this play! Here are the results:"
|
message = (
|
||||||
message += "\n```\n"
|
"Closed this play! Here are the results\n"
|
||||||
|
+ "PLAYER | GUESS | DIFFERENCE | POINTS GAINED | TOTAL POINTS\n"
|
||||||
table = BeautifulTable()
|
)
|
||||||
table.column_headers = [
|
|
||||||
"PLAYER",
|
|
||||||
"GUESS",
|
|
||||||
"DIFFERENCE",
|
|
||||||
"POINTS GAINED",
|
|
||||||
"TOTAL POINTS",
|
|
||||||
]
|
|
||||||
|
|
||||||
pitch_value = await self.update_pitch_value()
|
pitch_value = await self.update_pitch_value()
|
||||||
guess_processor = ProcessGuess(
|
guess_processor = ProcessGuess(
|
||||||
game=self, pitch_value=pitch_value, message=table
|
game=self, pitch_value=pitch_value, message=message
|
||||||
)
|
)
|
||||||
|
|
||||||
(
|
(
|
||||||
table,
|
message,
|
||||||
closest_player_id,
|
closest_player_id,
|
||||||
furthest_player_id,
|
furthest_player_id,
|
||||||
) = guess_processor.process_guesses()
|
) = guess_processor.process_guesses()
|
||||||
|
|
||||||
message += str(table)
|
message += (
|
||||||
message += "\n```\n"
|
f"\nCongrats <@{closest_player_id}>! You were the closest!\n"
|
||||||
message += f"Congrats <@{closest_player_id}>! You were the closest!\n"
|
+ f"Sorry <@{furthest_player_id}>, you were way off"
|
||||||
message += f"Sorry <@{furthest_player_id}>, you were way off\n"
|
)
|
||||||
|
|
||||||
await self.message.channel.send(message)
|
await self.message.channel.send(message)
|
||||||
|
|
||||||
|
@ -27,7 +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"
|
+ "!reset - Removes all players and total points"
|
||||||
+ "!help - Shows this message"
|
+ "!help - Shows this message"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
@ -25,23 +23,22 @@ 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:
|
||||||
table.rows.append([
|
message += (
|
||||||
player.player_name,
|
" | ".join(
|
||||||
str(player.total_points),
|
[
|
||||||
str(player.last_update)[:-10],
|
player.player_name,
|
||||||
])
|
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)
|
||||||
|
@ -134,15 +134,7 @@ class ProcessGuess:
|
|||||||
self.update_difference_value()
|
self.update_difference_value()
|
||||||
self.update_player_total_points()
|
self.update_player_total_points()
|
||||||
|
|
||||||
self.message.rows.append(
|
self.message += f"{guess.player.player_name} | {guess.guess} | {difference} | {difference_score} | {(guess.player.total_points + difference_score)}\n"
|
||||||
[
|
|
||||||
guess.player.player_name,
|
|
||||||
guess.guess,
|
|
||||||
difference,
|
|
||||||
difference_score,
|
|
||||||
guess.player.total_points + difference_score,
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
if guess.guess == winner:
|
if guess.guess == winner:
|
||||||
closest_player_id = guess.player.player_id
|
closest_player_id = guess.player.player_id
|
||||||
|
Loading…
Reference in New Issue
Block a user