From fb18e01440f5c806b566d0d8bf45ffd773e07c63 Mon Sep 17 00:00:00 2001 From: cubernetes Date: Fri, 11 Aug 2023 03:36:18 +0200 Subject: [PATCH] Cleanpu --- "\\" | 31 ------------------------------- game.py | 4 +--- utils.py | 3 +++ 3 files changed, 4 insertions(+), 34 deletions(-) delete mode 100644 "\\" diff --git "a/\\" "b/\\" deleted file mode 100644 index 9915f27..0000000 --- "a/\\" +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python3 - -from time import sleep -from typing import NoReturn - -from utils import * - -def start_game() -> None: - proc = Popen(['./start_game.sh']) - proc.communicate() - -def show_highscore() -> None: - Popen([ - 'tmux', - 'display-popup', - '-E', - 'watch', - '-tcn0', - r"""sh -c 'for _ in $(seq $(($(tput lines) / 3))); do printf "\n"; done; figlet -w $(tput cols) -c $(cat "/home/tosuman/42/hackthelobby/.score")'""", - ]) - -def main() -> NoReturn: - show_matrix() - show_highscore() - while True: - if found_hands(): - start_game() - sleep(1) - -if __name__ == '__main__': - main() diff --git a/game.py b/game.py index 0e67795..e6b5b83 100755 --- a/game.py +++ b/game.py @@ -160,7 +160,5 @@ def main() -> int: i += 1 if __name__ == '__main__': - score: int = main() - with open('./.score', 'w') as score_file: - score_file.write(str(score)) + save_score(main()) sys.exit(0) diff --git a/utils.py b/utils.py index aa90538..eec250f 100644 --- a/utils.py +++ b/utils.py @@ -34,6 +34,9 @@ class FingerType(Enum): PINKY_KNUCKLE_2 = 19 PINKY_TIP = 20 +def save_score(score: int) -> None: + with open('./.score', 'w') as score_file: + score_file.write(str(score)) def collect_sfx() -> None: Popen(['paplay', './assets/sfx/collect.mp3'])