From fd5f5a7e7a3457b22e302ea26cadde9981a53023 Mon Sep 17 00:00:00 2001 From: c0de Date: Sat, 10 Dec 2022 12:36:36 -0600 Subject: [PATCH] I Completely disagree with this decision. Remove the table for the original output --- Dockerfile | 2 +- Pipfile | 1 - Pipfile.lock | 33 +++++++++------------------------ game/end_game.py | 29 ++++++++++------------------- game/points.py | 25 +++++++++++-------------- game/process_guess.py | 10 +--------- 6 files changed, 32 insertions(+), 68 deletions(-) diff --git a/Dockerfile b/Dockerfile index dc8ca9c..1850210 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ 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 COPY . . diff --git a/Pipfile b/Pipfile index 2168fd6..b2c0e59 100644 --- a/Pipfile +++ b/Pipfile @@ -8,7 +8,6 @@ discord = "*" peewee = "*" pylint = "*" black = "*" -beautifultable = "*" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index d68f4d9..ff5b968 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "171e06b48e5905ea64caab54728c14bd65292a2957b33964c688f2172e677b62" + "sha256": "b6fb0d9cfe588eab84db4024e6b319681e9e70d00c74282b6722fe283ac3e348" }, "pipfile-spec": 6, "requires": { @@ -106,7 +106,7 @@ "sha256:f973157ffeab5459eefe7b97a804987876dd0a55570b8fa56b4e1954bf11329b", "sha256:ff25f48fc8e623d95eca0670b8cc1469a83783c924a602e0fbd47363bb54aaca" ], - "markers": "python_version >= '3.6'", + "markers": "python_full_version >= '3.6.0'", "version": "==3.8.3" }, "aiosignal": { @@ -130,7 +130,7 @@ "sha256:2163e1640ddb52b7a8c80d0a67a08587e5d245cc9c553a74a847056bc2976b15", "sha256:8ca1e4fcf50d07413d66d1a5e416e42cfdf5851c981d679a09851a6853383b3c" ], - "markers": "python_version >= '3.6'", + "markers": "python_full_version >= '3.6.0'", "version": "==4.0.2" }, "attrs": { @@ -141,14 +141,6 @@ "markers": "python_version >= '3.5'", "version": "==22.1.0" }, - "beautifultable": { - "hashes": [ - "sha256:040bc987444965678f4ffdfa2f17ac357f1a13e5875b161c9a1899b375319d17", - "sha256:b34053a581976c4c23064bb0e918a7f6f22273cf196c787946db323a6a2b7d84" - ], - "index": "pypi", - "version": "==1.1.0" - }, "black": { "hashes": [ "sha256:101c69b23df9b44247bd88e1d7e90154336ac4992502d4197bdac35dd7ee3320", @@ -172,7 +164,7 @@ "sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845", "sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f" ], - "markers": "python_version >= '3.6'", + "markers": "python_full_version >= '3.6.0'", "version": "==2.1.1" }, "click": { @@ -333,7 +325,7 @@ "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325", "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e" ], - "markers": "python_version >= '3.6'", + "markers": "python_full_version >= '3.6.0'", "version": "==0.7.0" }, "multidict": { @@ -425,11 +417,11 @@ }, "pathspec": { "hashes": [ - "sha256:88c2606f2c1e818b978540f73ecc908e13999c6c3a383daf3705652ae79807a5", - "sha256:8f6bf73e5758fd365ef5d58ce09ac7c27d2833a8d7da51712eac6e27e35141b0" + "sha256:3c95343af8b756205e2aba76e843ba9520a24dd84f68c22b9f93251507509dd6", + "sha256:56200de4077d9d0791465aa9095a01d421861e405b5096955051deefd697d6f6" ], "markers": "python_version >= '3.7'", - "version": "==0.10.2" + "version": "==0.10.3" }, "peewee": { "hashes": [ @@ -467,16 +459,9 @@ "sha256:07de26b0d8cfc18f871aec595fda24d95b08fef89d147caa861939f37230bf4b", "sha256:71b952e5721688937fb02cf9d354dbcf0785066149d2855e44531ebdd2b65d73" ], - "markers": "python_version >= '3.6'", + "markers": "python_full_version >= '3.6.0'", "version": "==0.11.6" }, - "wcwidth": { - "hashes": [ - "sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784", - "sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83" - ], - "version": "==0.2.5" - }, "wrapt": { "hashes": [ "sha256:00b6d4ea20a906c0ca56d84f93065b398ab74b927a7a3dbd470f6fc503f95dc3", diff --git a/game/end_game.py b/game/end_game.py index d1f00de..e47aeb3 100644 --- a/game/end_game.py +++ b/game/end_game.py @@ -6,8 +6,6 @@ import datetime -from beautifultable import BeautifulTable - from database.models import GameModel as Game, GuessModel as Guess from game.base import BaseGameManager from game.process_guess import ProcessGuess @@ -84,33 +82,26 @@ class EndGameManager(BaseGameManager): ("Play closed!\n" + "However, there were not enough participants.") ) - message = "Closed this play! Here are the results:" - message += "\n```\n" - - table = BeautifulTable() - table.column_headers = [ - "PLAYER", - "GUESS", - "DIFFERENCE", - "POINTS GAINED", - "TOTAL POINTS", - ] + message = ( + "Closed this play! Here are the results\n" + + "PLAYER | GUESS | DIFFERENCE | POINTS GAINED | TOTAL POINTS\n" + ) pitch_value = await self.update_pitch_value() guess_processor = ProcessGuess( - game=self, pitch_value=pitch_value, message=table + game=self, pitch_value=pitch_value, message=message ) ( - table, + message, closest_player_id, furthest_player_id, ) = guess_processor.process_guesses() - message += str(table) - message += "\n```\n" - message += f"Congrats <@{closest_player_id}>! You were the closest!\n" - message += f"Sorry <@{furthest_player_id}>, you were way off\n" + message += ( + f"\nCongrats <@{closest_player_id}>! You were the closest!\n" + + f"Sorry <@{furthest_player_id}>, you were way off" + ) await self.message.channel.send(message) diff --git a/game/points.py b/game/points.py index c4664ba..b0bc284 100644 --- a/game/points.py +++ b/game/points.py @@ -4,8 +4,6 @@ # 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 @@ -25,23 +23,22 @@ class PointsManager(BaseGameManager): message = ( "\nPlayers, who played recently, with their points highest to lowest\n\n" ) - - message += "```\n" - table = BeautifulTable() - table.column_headers = ["Player", "Total Points", "Last Played"] + message += "Player | Total Points | Last Played\n" 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: - table.rows.append([ - player.player_name, - str(player.total_points), - str(player.last_update)[:-10], - ]) - - message += str(table) - message += "\n```\n" + message += ( + " | ".join( + [ + player.player_name, + str(player.total_points), + str(player.last_update)[:-10], + ] + ) + + "\n" + ) return await self.message.channel.send(message) diff --git a/game/process_guess.py b/game/process_guess.py index 3233002..f0b907a 100644 --- a/game/process_guess.py +++ b/game/process_guess.py @@ -134,15 +134,7 @@ class ProcessGuess: self.update_difference_value() self.update_player_total_points() - self.message.rows.append( - [ - guess.player.player_name, - guess.guess, - difference, - difference_score, - guess.player.total_points + difference_score, - ] - ) + self.message += f"{guess.player.player_name} | {guess.guess} | {difference} | {difference_score} | {(guess.player.total_points + difference_score)}\n" if guess.guess == winner: closest_player_id = guess.player.player_id