metoda střídání hráčů

This commit is contained in:
gitea-actions committed 2026-08-19 22:09:06 +02:00
1 parent c56855dc83
commit 98bad373a7
1 file changed
+20 -1
+20 -1
View File
@@ -2,17 +2,22 @@ import sys
from os import name, system
hraci = {}
pointer = ""
first = ""
def clear() -> None:
_ = system('cls') if name == 'nt' else system('clear')
def char_create() -> bool:
global hraci
global pointer
global first
while True:
inp: str = input("Zadejte jméno prvního hráče: ")
if inp:
hraci[inp] = 0
pointer = inp
first = inp
print(f"Hráč/ka {inp} přidán(a).")
break
else:
@@ -31,6 +36,17 @@ def char_create() -> bool:
return True
def next_player() -> None:
global pointer
keys_iter = iter(hraci)
for key in keys_iter:
if key == pointer:
nxt_key = next(keys_iter, first)
break
pointer = nxt_key
def game():
while True:
table()
@@ -43,8 +59,11 @@ def main() -> None:
else:
print("Nastala chyba při vytváření uživatelů.")
sys.exit()
input("Stiskněte libovolnou klávesu pro pokračování. ")
game()
if __name__ == "__main__":