Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge collapsible if statements #193

Merged
merged 2 commits into from
Sep 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions werwolf.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,14 +849,13 @@ def generiere_token(name: str, rolle: str) -> str:
:return: A token

"""
if validiere_rolle_original(name, rolle):
if not ist_token_vorhandem(name, rolle):
if validiere_rolle_original(name, rolle) and not ist_token_vorhandem(name, rolle):

token = secrets.token_hex(16)
# write the token and the name and the role to the file tokens.txt
with open("tokens.txt", "a", encoding="UTF8") as file:
file.write("+" + token + "+" + name + "+" + rolle + "+1+ \n")
return token
token = secrets.token_hex(16)
# write the token and the name and the role to the file tokens.txt
with open("tokens.txt", "a", encoding="UTF8") as file:
file.write("+" + token + "+" + name + "+" + rolle + "+1+ \n")
return token


def validiere_token(token: str) -> bool:
Expand Down Expand Up @@ -960,10 +959,9 @@ def status_aus_token(token: str):
# read the file tokens.txt and check if the token is in the file
with open("tokens.txt", "r") as file:
for line in file:
if line != "\n":
if "+" + token + "+" in line and line.count("+") == 5:
# split the line at the + and return the name and the role
return line.split("+")[4]
if line != "\n" and "+" + token + "+" in line and line.count("+") == 5:
# split the line at the + and return the name and the role
return line.split("+")[4]
return "Fehler"


Expand Down