diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..0bf248f --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,11 @@ +AnyChange: + - changed-files: + - any-glob-to-any-file: '**' + +python: + - changed-files: + - any-glob-to-any-file: '**/*.py' + +docs: + - changed-files: + - any-glob-to-any-file: ['README.md', 'docs/**'] diff --git a/source/__init__.py b/source/__init__.py new file mode 100644 index 0000000..6c43a8f --- /dev/null +++ b/source/__init__.py @@ -0,0 +1,27 @@ +VERSION = 1 +LOGO = """ +███████╗██╗ ██╗ ██████╗ ██╗ ██╗ ██████╗ ███████╗███████╗ +██╔════╝██║ ██║██╔═══██╗██║ ██║██╔═══██╗██╔════╝██╔════╝ +███████╗███████║██║ ██║██║ █╗ ██║██║ ██║█████╗ █████╗ +╚════██║██╔══██║██║ ██║██║███╗██║██║ ██║██╔══╝ ██╔══╝ +███████║██║ ██║╚██████╔╝╚███╔███╔╝╚██████╔╝██║ ██║ +╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝ +""" + +MENU = """ +[1] - Add a match +[2] - View your matches +[3] - Statistics review +[4] - Data export +[5] - Manage coach mode +[6] - About +[7] - Exit + +""" + +INFO = f""" +{LOGO} +v{VERSION} - meeko 2026 +""" + +DESCRIPTION = "A simple basketball statistics tracker, written to be easy to use and to be informational.\nhttps://github.com/worthyworm/showoff" diff --git a/source/data_handler.py b/source/data_handler.py index 8fe796f..9d62d74 100644 --- a/source/data_handler.py +++ b/source/data_handler.py @@ -21,16 +21,18 @@ def add_match(name, date, points, assists, rebounds, blocks, steals, missed, mis "missedFT": int(missedFT), "turnovers": int(TO), "Won": bool(Result) - } + } db["games"].append(new_game) + def save(): with open('data.json', 'w', encoding='utf-8') as f: - json.dump(db, f, ensure_ascii=False, indent = 4) + json.dump(db, f, ensure_ascii=False, indent=4) + ''' def enableCoachMode(players): db["coachMode"] = True for i in range(players): -''' \ No newline at end of file +''' diff --git a/source/main.py b/source/main.py index 7a0d887..2482702 100644 --- a/source/main.py +++ b/source/main.py @@ -1,44 +1,42 @@ import data_handler import ui_handler -from ui_handler import menu +from ui_handler import Menu import statistics_handler -VERSION = 1 db = data_handler ui = ui_handler stats = statistics_handler games = data_handler.db["games"] -def main(): +def main(): while True: - menu.showInfo(VERSION, False) - user_choice = menu.createMenu() + Menu.show_info(False) + user_choice = Menu.create_menu() if user_choice == 1: - stats.addMatch() + stats.add_match() print("Added!") db.save() - input() - menu.clearScreen() + input("Enter to continue... ") + Menu.clear_screen() elif user_choice == 2: gamescount = len(games) for i in range(gamescount): - print(f"{i + 1} - {str(games[i]["name"])}") + print(f"{i + 1} - {str(games[i]['name'])}") choice = input("What match to show?(leave blank to exit)\n") if choice != '' and int(choice) - 1 in range(gamescount): - stats.showStats(int(choice) - 1) + stats.show_stats(int(choice) - 1) else: print("Game index out of range.") - input() - menu.clearScreen() + input("Enter to continue... ") + Menu.clear_screen() elif user_choice == 3: - menu.clearScreen() - stats.statsReview() - input() - menu.clearScreen() + stats.stats_review() + input("Enter to continue... ") + Menu.clear_screen() elif user_choice == 5: ''' @@ -51,18 +49,20 @@ def main(): pass ''' print("Coach mode is currently under work. Stay tuned for updates") - input() - menu.clearScreen() + input("Enter to continue... ") + Menu.clear_screen() pass elif user_choice == 6: - menu.clearScreen() - menu.showInfo(VERSION, True) - input() - menu.clearScreen() + Menu.clear_screen() + Menu.show_info(True) + input("Enter to continue... ") + Menu.clear_screen() elif user_choice == 7: break -main() -db.save() -exit(0) \ No newline at end of file + +if __name__ == '__main__': + main() + db.save() + exit() diff --git a/source/statistics_handler.py b/source/statistics_handler.py index 7576e3f..a2b2a8d 100644 --- a/source/statistics_handler.py +++ b/source/statistics_handler.py @@ -1,10 +1,12 @@ +from pip._internal.utils.misc import tabulate + import data_handler -from tabulate import tabulate db = data_handler games = data_handler.db["games"] -def statsReview(): + +def stats_review(): allPoints = sum(game["points"] for game in games) allAssists = sum(game["assists"] for game in games) allRebounds = sum(game["rebounds"] for game in games) @@ -14,12 +16,11 @@ def statsReview(): allMissedFreeThrows = sum(game["missedFT"] for game in games) allTurnOvers = sum(game["turnovers"] for game in games) allGames = len(games) - efficiency = calculateEfficiency(allPoints, allRebounds, allAssists, allSteals, allBlocks, allMissed, allMissedFreeThrows, allTurnOvers) + efficiency = calculate_efficiency(allPoints, allRebounds, allAssists, allSteals, allBlocks, allMissed, + allMissedFreeThrows, allTurnOvers) if allGames == 0: print("You have no saved games.") - return - - ''' + return ''' Points : {allPoints} Assists : {allAssists} Rebounds : {allRebounds} @@ -38,39 +39,49 @@ def statsReview(): Turnovers Per game : {allTurnOvers / allGames} Games : {allGames} Efficiency : {efficiency} - ''' - table = [["Points", allPoints, allPoints / allGames], ["Assists", allAssists, allAssists / allGames], ["Rebounds", allRebounds, allRebounds / allGames], ["Blocks", allBlocks, allBlocks / allGames], ["Steals", allSteals, allSteals / allGames], ["Missed", allMissed, allMissed / allGames], ["Missed Free Throws", allMissedFreeThrows, allMissedFreeThrows / allGames], ["Turnovers", allTurnOvers, allTurnOvers / allGames]] +''' + table = [["Points", allPoints, allPoints / allGames], ["Assists", allAssists, allAssists / allGames], + ["Rebounds", allRebounds, allRebounds / allGames], ["Blocks", allBlocks, allBlocks / allGames], + ["Steals", allSteals, allSteals / allGames], ["Missed", allMissed, allMissed / allGames], + ["Missed Free Throws", allMissedFreeThrows, allMissedFreeThrows / allGames], + ["Turnovers", allTurnOvers, allTurnOvers / allGames]] - print(tabulate(table, headers=["Type", "All-time", "Per-Game"])) + print(f"{'STAT':<20} {'ALL-TIME':<10} {'PER-GAME'}") + print("─" * 35) + for stat, ag, pg in table: + print(f"{stat:<20} {ag:<10} {pg}") + print("─" * 35) print(f"Games: {allGames}\nEfficiency: {efficiency}") - -def addMatch(): + print("─" * 35) + + +def add_match(): db.add_match(input("Enter name for a match: "), - input("Enter date: "), - int(input("Enter points: ")), - int(input("Enter assists: ")), - int(input("Enter rebounds: ")), - int(input("Enter blocks: ")), - int(input("Enter steals: ")), - int(input("Enter missed shots excluding free throws: ")), - int(input("Enter missed free throws: ")), - int(input("Enter turnovers: ")), - bool(input("Result (True for W/False for L): "))) + input("Enter date: "), + int(input("Enter points: ")), + int(input("Enter assists: ")), + int(input("Enter rebounds: ")), + int(input("Enter blocks: ")), + int(input("Enter steals: ")), + int(input("Enter missed shots excluding free throws: ")), + int(input("Enter missed free throws: ")), + int(input("Enter turnovers: ")), + bool(input("Result (True for W/False for L): "))) + -def calculateEfficiency(points, rebounds, assists, steals, blocks, missed, missedFT, turnovers): +def calculate_efficiency(points, rebounds, assists, steals, blocks, missed, missedFT, turnovers): efficiency = (points + rebounds + assists + steals + blocks) - (missed + missedFT + turnovers) return efficiency -def showStats(matchIndex): - ''' -Points : {str(games[matchIndex]["points"])} -Assists : {str(games[matchIndex]["assists"])} -Rebounds : {str(games[matchIndex]["rebounds"])} -Blocks : {str(games[matchIndex]["blocks"])} -Steals : {str(games[matchIndex]["steals"])} -Shots Missed : {str(games[matchIndex]["missed"])} -Free Throws Missed : {str(games[matchIndex]["missedFT"])} -Turnovers : {str(games[matchIndex]["turnovers"])} - ''' - table = [["Points", str(games[matchIndex]["points"])], ["Assists", str(games[matchIndex]["assists"])], ["Rebounds", str(games[matchIndex]["rebounds"])], ["Blocks", str(games[matchIndex]["blocks"])], ["Steals", str(games[matchIndex]["steals"])], ["Missed", str(games[matchIndex]["missed"])], ["Missed Free Throws", str(games[matchIndex]["missedFT"])], ["Turnovers", str(games[matchIndex]["turnovers"])], ["Won", str(games[matchIndex]["Won"])]] - print(tabulate(table)) \ No newline at end of file + +def show_stats(matchIndex): + table = [["Points", str(games[matchIndex]["points"])], ["Assists", str(games[matchIndex]["assists"])], + ["Rebounds", str(games[matchIndex]["rebounds"])], ["Blocks", str(games[matchIndex]["blocks"])], + ["Steals", str(games[matchIndex]["steals"])], ["Missed", str(games[matchIndex]["missed"])], + ["Missed Free Throws", str(games[matchIndex]["missedFT"])], + ["Turnovers", str(games[matchIndex]["turnovers"])], ["Won", str(games[matchIndex]["Won"])]] + print(f"{'STAT':<20} {'VALUE'}") + print("─" * 35) + for stat, value in table: + print(f"{stat:<20} {value}") + print("─" * 35) diff --git a/source/ui_handler.py b/source/ui_handler.py index e627b1b..20e9c87 100644 --- a/source/ui_handler.py +++ b/source/ui_handler.py @@ -1,46 +1,23 @@ import os -class menu: - - def createMenu(): +from source import MENU, INFO, DESCRIPTION - choice = int(input(''' -[1] - Add a match -[2] - View your matches -[3] - Statistics review -[4] - Data export -[5] - Manage coach mode -[6] - About -[7] - Exit ->''')) + +class Menu: + + @staticmethod + def create_menu(): + print(MENU) + choice = int(input("Select >> ")) return choice - - def showInfo(version, full): + @staticmethod + def show_info(full): if full == False: - print(f''' -███████╗██╗ ██╗ ██████╗ ██╗ ██╗ ██████╗ ███████╗███████╗ -██╔════╝██║ ██║██╔═══██╗██║ ██║██╔═══██╗██╔════╝██╔════╝ -███████╗███████║██║ ██║██║ █╗ ██║██║ ██║█████╗ █████╗ -╚════██║██╔══██║██║ ██║██║███╗██║██║ ██║██╔══╝ ██╔══╝ -███████║██║ ██║╚██████╔╝╚███╔███╔╝╚██████╔╝██║ ██║ -╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝ - -v{version} - meeko 2026 - ''') + print(INFO) else: - print(f''' -███████╗██╗ ██╗ ██████╗ ██╗ ██╗ ██████╗ ███████╗███████╗ -██╔════╝██║ ██║██╔═══██╗██║ ██║██╔═══██╗██╔════╝██╔════╝ -███████╗███████║██║ ██║██║ █╗ ██║██║ ██║█████╗ █████╗ -╚════██║██╔══██║██║ ██║██║███╗██║██║ ██║██╔══╝ ██╔══╝ -███████║██║ ██║╚██████╔╝╚███╔███╔╝╚██████╔╝██║ ██║ -╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝ + print(INFO, DESCRIPTION) -v{version} - meeko 2026 -A simple basketball statistics tracker, written to be easy to use and to be informational. -https://github.com/worthyworm/showoff - ''') - - def clearScreen(): - os.system('cls' if os.name == 'nt' else 'clear') \ No newline at end of file + @staticmethod + def clear_screen(): + os.system('cls' if os.name == 'nt' else 'clear')