feature/hraci: pomocná funkce next_player
This commit is contained in:
@@ -8,6 +8,7 @@ score = 0
|
|||||||
hodnoty = {}
|
hodnoty = {}
|
||||||
players = {}
|
players = {}
|
||||||
pointer = ""
|
pointer = ""
|
||||||
|
first = ""
|
||||||
|
|
||||||
with open("hodnoty.csv", "r") as csv_file:
|
with open("hodnoty.csv", "r") as csv_file:
|
||||||
csv_reader = csv.reader(csv_file)
|
csv_reader = csv.reader(csv_file)
|
||||||
@@ -55,6 +56,17 @@ def evaluate(inp: Any, count: int, throw: str) -> tuple:
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def next_player() -> None:
|
||||||
|
global pointer
|
||||||
|
|
||||||
|
keys_iter = iter(players)
|
||||||
|
for key in keys_iter:
|
||||||
|
if key == pointer:
|
||||||
|
nxt_key = next(keys_iter, first)
|
||||||
|
break
|
||||||
|
|
||||||
|
pointer = nxt_key
|
||||||
|
|
||||||
inp = str(inp)
|
inp = str(inp)
|
||||||
if re.search("^\d+$", inp):
|
if re.search("^\d+$", inp):
|
||||||
if len(inp) > count:
|
if len(inp) > count:
|
||||||
@@ -108,6 +120,7 @@ def check_value(throw: str) -> bool:
|
|||||||
def add_players(iter=False):
|
def add_players(iter=False):
|
||||||
global players
|
global players
|
||||||
global pointer
|
global pointer
|
||||||
|
global first
|
||||||
|
|
||||||
if not iter:
|
if not iter:
|
||||||
var = "prvního hráče"
|
var = "prvního hráče"
|
||||||
@@ -130,6 +143,7 @@ def add_players(iter=False):
|
|||||||
print(f"Do seznamu přidáno jméno {inp}.")
|
print(f"Do seznamu přidáno jméno {inp}.")
|
||||||
if not iter:
|
if not iter:
|
||||||
pointer = inp
|
pointer = inp
|
||||||
|
first = inp
|
||||||
add_players(True)
|
add_players(True)
|
||||||
|
|
||||||
def game(data: tuple):
|
def game(data: tuple):
|
||||||
|
|||||||
Reference in New Issue
Block a user