feature/vysledky: definice funkce win() a její volání z bloku win ve funkci game()

This commit is contained in:
David Spáčil committed 2026-06-27 17:15:47 +02:00
1 parent bdd66379f7
commit 7b0c9cadbb
1 file changed
+13 -2
+13 -2
View File
@@ -4,6 +4,7 @@ from os import system, name
import re import re
import csv import csv
from collections import Counter from collections import Counter
from tabulate import tabulate
score: int = 0 score: int = 0
hodnoty: dict[str, int] = {} hodnoty: dict[str, int] = {}
@@ -233,6 +234,17 @@ def check_win() -> str:
return winner return winner
def win(winner: str, score: int) -> None:
results, d = to_sorted_tuple(aggr)
headers = ["Pořadí", "Hráč", "Skóre"]
table = tabulate(results, headers=headers, tablefmt="fancy_grid")
print(f"Vítězem se stává {winner} s {score} body!")
print("Díky za hru a zase příště.\n")
print(table)
def game(data: tuple) -> None: def game(data: tuple) -> None:
while True: while True:
if data[0] == "count": if data[0] == "count":
@@ -289,8 +301,7 @@ def game(data: tuple) -> None:
score = data[2] score = data[2]
clear() clear()
print(f"Vítězem se stává {winner} s {score} body!") win(winner, score)
print("Díky za hru a zase příště.")
break break
elif data[0] == "exit": elif data[0] == "exit":