feature: multiplayer – registrace hráčů, střídání tahů a agregace skóre #9
@@ -6,6 +6,8 @@ import csv
|
||||
|
||||
score = 0
|
||||
hodnoty = {}
|
||||
players = {}
|
||||
pointer = ""
|
||||
|
||||
with open("hodnoty.csv", "r") as csv_file:
|
||||
csv_reader = csv.reader(csv_file)
|
||||
@@ -100,6 +102,33 @@ def check_value(throw: str) -> bool:
|
||||
|
||||
return hodnota
|
||||
|
||||
def add_players(iter=False):
|
||||
global players
|
||||
global pointer
|
||||
|
||||
if not iter:
|
||||
var = "prvního hráče"
|
||||
else:
|
||||
var = "dalšího hráče nebo [x] pro ukončení zadávání hráčů"
|
||||
|
||||
inp = input(f"Zadejte jméno {var}: ")
|
||||
|
||||
if inp == "x":
|
||||
if not iter:
|
||||
add_players()
|
||||
elif inp == "":
|
||||
print("Jméno nemůže být prázdné.")
|
||||
add_players(iter)
|
||||
else:
|
||||
if inp in players:
|
||||
print("Zadávejte, prosím, unikátní jména.")
|
||||
else:
|
||||
players[inp] = []
|
||||
print(f"Do seznamu přidáno jméno {inp}.")
|
||||
if not iter:
|
||||
pointer = inp
|
||||
add_players(True)
|
||||
|
||||
def game(data: tuple):
|
||||
if data[0] == "count":
|
||||
count = data[1]
|
||||
@@ -136,6 +165,7 @@ def game(data: tuple):
|
||||
|
||||
def main():
|
||||
print("Vítejte ve hře v kostky!")
|
||||
add_players()
|
||||
input("Prosím, stiskněte enter pro první hod:")
|
||||
data = ("count", 6, "")
|
||||
game(data)
|
||||
|
||||
Reference in New Issue
Block a user