move documentation inside functions
This commit is contained in:
parent
711d562af0
commit
f7c300785d
@ -55,21 +55,21 @@ class Game:
|
|||||||
self.gamedata = {}
|
self.gamedata = {}
|
||||||
self.reaction_table = {}
|
self.reaction_table = {}
|
||||||
|
|
||||||
|
def set_owner(self, username: str) -> Member:
|
||||||
"""
|
"""
|
||||||
Set the owner of the game
|
Set the owner of the game
|
||||||
|
|
||||||
:param username: the username of the owner.
|
:param username: the username of the owner.
|
||||||
:return: the Member object created by this method
|
:return: the Member object created by this method
|
||||||
"""
|
"""
|
||||||
def set_owner(self, username: str) -> Member:
|
|
||||||
self.owner = Member(username)
|
self.owner = Member(username)
|
||||||
self.members.append(self.owner)
|
self.members.append(self.owner)
|
||||||
return self.owner
|
return self.owner
|
||||||
|
|
||||||
|
def generateGameResults(self) -> None:
|
||||||
"""
|
"""
|
||||||
TODO + TODO RET TYPE
|
TODO + TODO RET TYPE
|
||||||
"""
|
"""
|
||||||
def generateGameResults(self) -> None:
|
|
||||||
data = {}
|
data = {}
|
||||||
npcs = data["npcs"] = {}
|
npcs = data["npcs"] = {}
|
||||||
for npc_id in self.gamedata["npcs"]:
|
for npc_id in self.gamedata["npcs"]:
|
||||||
@ -83,50 +83,50 @@ class Game:
|
|||||||
player_results[member.username] = member.results
|
player_results[member.username] = member.results
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def generate_data(self) -> None:
|
||||||
"""
|
"""
|
||||||
TODO
|
TODO
|
||||||
"""
|
"""
|
||||||
def generate_data(self) -> None:
|
|
||||||
#TODO Get language from player
|
#TODO Get language from player
|
||||||
self.gamedata, self.reaction_table = generateGameData("FR")
|
self.gamedata, self.reaction_table = generateGameData("FR")
|
||||||
|
|
||||||
|
def get_member(self, username: str) -> Union[Member, None]:
|
||||||
"""
|
"""
|
||||||
Get a Member object from a username
|
Get a Member object from a username
|
||||||
|
|
||||||
:param username: the username of the member to search for
|
:param username: the username of the member to search for
|
||||||
:return the member corresponding to the username, or None if none if found:
|
:return the member corresponding to the username, or None if none if found:
|
||||||
"""
|
"""
|
||||||
def get_member(self, username: str) -> Union[Member, None]:
|
|
||||||
for member in self.members:
|
for member in self.members:
|
||||||
if member.username == username:
|
if member.username == username:
|
||||||
return member
|
return member
|
||||||
|
|
||||||
|
def add_member(self, username: str) -> Union[Member, None]:
|
||||||
"""
|
"""
|
||||||
Add a Member to the game
|
Add a Member to the game
|
||||||
|
|
||||||
:param username: the username of the member to add
|
:param username: the username of the member to add
|
||||||
:return: the Member created, or None if a Member with this username already exists in the game
|
:return: the Member created, or None if a Member with this username already exists in the game
|
||||||
"""
|
"""
|
||||||
def add_member(self, username: str) -> Union[Member, None]:
|
|
||||||
if self.get_member(username):
|
if self.get_member(username):
|
||||||
return None
|
return None
|
||||||
member = Member(username)
|
member = Member(username)
|
||||||
self.members.append(member)
|
self.members.append(member)
|
||||||
return member
|
return member
|
||||||
|
|
||||||
|
def get_npc_reaction(self, npc_id, reaction) -> None:
|
||||||
"""
|
"""
|
||||||
TODO + TODO TYPES
|
TODO + TODO TYPES
|
||||||
"""
|
"""
|
||||||
def get_npc_reaction(self, npc_id, reaction) -> None:
|
|
||||||
if npc_id not in self.reaction_table.keys():
|
if npc_id not in self.reaction_table.keys():
|
||||||
return 0
|
return 0
|
||||||
reaction_id = self.reaction_table[npc_id][int(reaction)]
|
reaction_id = self.reaction_table[npc_id][int(reaction)]
|
||||||
return read_image(f"./truthseeker/static/images/npc/{npc_id}/{reaction_id}.png")
|
return read_image(f"./truthseeker/static/images/npc/{npc_id}/{reaction_id}.png")
|
||||||
|
|
||||||
|
def getPlayerResults(self, responses: dict) -> None:
|
||||||
"""
|
"""
|
||||||
TODO + TODO RETTYPE
|
TODO + TODO RETTYPE
|
||||||
"""
|
"""
|
||||||
def getPlayerResults(self, responses: dict) -> None:
|
|
||||||
results = {}
|
results = {}
|
||||||
try:
|
try:
|
||||||
for npc_id in responses:
|
for npc_id in responses:
|
||||||
@ -137,12 +137,12 @@ class Game:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def has_finished(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Checks if the game has finished by checking if every Member has submitted answers
|
Checks if the game has finished by checking if every Member has submitted answers
|
||||||
|
|
||||||
:return: True if the game has finished, else False
|
:return: True if the game has finished, else False
|
||||||
"""
|
"""
|
||||||
def has_finished(self) -> bool:
|
|
||||||
for member in self.members:
|
for member in self.members:
|
||||||
if member.results == None : return False
|
if member.results == None : return False
|
||||||
return True
|
return True
|
||||||
@ -186,6 +186,7 @@ def check_username(username: str) -> bool:
|
|||||||
:param username: the username to check
|
:param username: the username to check
|
||||||
:return: True or False depending on if the rules are respected
|
:return: True or False depending on if the rules are respected
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not username:
|
if not username:
|
||||||
return False
|
return False
|
||||||
if not username.isalnum():
|
if not username.isalnum():
|
||||||
|
Loading…
Reference in New Issue
Block a user