metoda střídání hráčů
This commit is contained in:
1 parent
c56855dc83
commit
98bad373a7
1 file changed
+20
-1
@@ -2,17 +2,22 @@ import sys
|
|||||||
from os import name, system
|
from os import name, system
|
||||||
|
|
||||||
hraci = {}
|
hraci = {}
|
||||||
|
pointer = ""
|
||||||
|
first = ""
|
||||||
|
|
||||||
def clear() -> None:
|
def clear() -> None:
|
||||||
_ = system('cls') if name == 'nt' else system('clear')
|
_ = system('cls') if name == 'nt' else system('clear')
|
||||||
|
|
||||||
def char_create() -> bool:
|
def char_create() -> bool:
|
||||||
global hraci
|
global pointer
|
||||||
|
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:
|
||||||
hraci[inp] = 0
|
hraci[inp] = 0
|
||||||
|
pointer = inp
|
||||||
|
first = inp
|
||||||
print(f"Hráč/ka {inp} přidán(a).")
|
print(f"Hráč/ka {inp} přidán(a).")
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
@@ -31,6 +36,17 @@ def char_create() -> bool:
|
|||||||
|
|
||||||
return True
|
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():
|
def game():
|
||||||
while True:
|
while True:
|
||||||
table()
|
table()
|
||||||
@@ -43,8 +59,11 @@ def main() -> None:
|
|||||||
else:
|
else:
|
||||||
print("Nastala chyba při vytváření uživatelů.")
|
print("Nastala chyba při vytváření uživatelů.")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
input("Stiskněte libovolnou klávesu pro pokračování. ")
|
input("Stiskněte libovolnou klávesu pro pokračování. ")
|
||||||
|
|
||||||
|
game()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in new issue
Block a user