cleary a cisteni
This commit is contained in:
1 parent
283c1a8eb9
commit
727e5dd378
1 file changed
+11
-6
@@ -14,7 +14,7 @@ def clear() -> None:
|
|||||||
def char_create() -> bool:
|
def char_create() -> bool:
|
||||||
global pointer
|
global pointer
|
||||||
global first
|
global first
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
inp: str = input("Zadejte jméno prvního hráče: ")
|
inp: str = input("Zadejte jméno prvního hráče: ")
|
||||||
if inp:
|
if inp:
|
||||||
@@ -22,17 +22,21 @@ def char_create() -> bool:
|
|||||||
score[inp] = 0
|
score[inp] = 0
|
||||||
pointer = inp
|
pointer = inp
|
||||||
first = inp
|
first = inp
|
||||||
|
clear()
|
||||||
print(f"Hráč/ka {inp} přidán(a).")
|
print(f"Hráč/ka {inp} přidán(a).")
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
clear()
|
||||||
print("Jméno nesmí být prázdné.")
|
print("Jméno nesmí být prázdné.")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
inp = input("Zadejte jméno dalšího hráče (nebo nechte prázdné pro ukončení zadávání): ")
|
inp = input("Zadejte jméno dalšího hráče (nebo nechte prázdné pro ukončení zadávání): ")
|
||||||
if inp:
|
if inp:
|
||||||
if inp in hraci:
|
if inp in hraci:
|
||||||
|
clear()
|
||||||
print("Je potřeba zadávat unikátní jména.")
|
print("Je potřeba zadávat unikátní jména.")
|
||||||
else:
|
else:
|
||||||
|
clear()
|
||||||
hraci[inp] = []
|
hraci[inp] = []
|
||||||
score[inp] = 0
|
score[inp] = 0
|
||||||
print(f"Hráč/ka {inp} přidán(a).")
|
print(f"Hráč/ka {inp} přidán(a).")
|
||||||
@@ -46,10 +50,10 @@ def next_player() -> None:
|
|||||||
|
|
||||||
keys_iter = iter(hraci)
|
keys_iter = iter(hraci)
|
||||||
for key in keys_iter:
|
for key in keys_iter:
|
||||||
if key == pointer:
|
if key == pointer:
|
||||||
nxt_key = next(keys_iter, first)
|
nxt_key = next(keys_iter, first)
|
||||||
break
|
break
|
||||||
|
|
||||||
pointer = nxt_key
|
pointer = nxt_key
|
||||||
|
|
||||||
table_header = ["Hráč", "Skóre"]
|
table_header = ["Hráč", "Skóre"]
|
||||||
@@ -77,9 +81,10 @@ def game():
|
|||||||
add_score(pointer, inp_int)
|
add_score(pointer, inp_int)
|
||||||
next_player()
|
next_player()
|
||||||
# break
|
# break
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
|
clear()
|
||||||
if char_create():
|
if char_create():
|
||||||
clear()
|
clear()
|
||||||
print("Vytvoření hráči:", ", ".join(list(hraci.keys())))
|
print("Vytvoření hráči:", ", ".join(list(hraci.keys())))
|
||||||
@@ -91,7 +96,7 @@ def main() -> None:
|
|||||||
|
|
||||||
game()
|
game()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
Reference in new issue
Block a user