Skip to content
Snippets Groups Projects

Resolve "Too large number of selected players does not break the gui and environment"

2 files
+ 45
48
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -47,7 +47,9 @@ log = logging.getLogger(__name__)
class PlayerKeySet:
"""Set of keyboard keys for controlling a player.
First four keys are for movement. Order: Down, Up, Left, Right. 5th key is for interacting with counters. 6th key ist for picking up things or dropping them.
First four keys are for movement. Order: Down, Up, Left, Right.
5th key is for interacting with counters.
6th key ist for picking up things or dropping them.
"""
def __init__(
@@ -123,7 +125,7 @@ class PyGameGUI:
self.participant_id = uuid.uuid4().hex
self.game_screen: pygame.Surface = None
self.game_screen: pygame.Surface | None = None
self.running = True
self.key_sets: list[PlayerKeySet] = []
@@ -1282,9 +1284,9 @@ class PyGameGUI:
if self.menu_state == MenuStates.ControllerTutorial:
answer = requests.post(
f"{self.request_url}/connect_to_tutorial/{self.participant_id}"
).json()
if answer["status_code"] == 200:
self.player_info = answer["data"]
)
if answer.status_code == 200:
self.player_info = answer.json()
self.player_info = {self.player_info["player_id"]: self.player_info}
else:
self.menu_state = MenuStates.Start
@@ -1292,10 +1294,10 @@ class PyGameGUI:
else:
answer = requests.post(
f"{self.request_url}/get_game_connection/{self.participant_id}"
).json()
if answer["status_code"] == 200:
self.player_info = answer["data"]["player_info"]
self.level_info = answer["data"]["level_info"]
)
if answer.status_code == 200:
self.player_info = answer.json()["player_info"]
self.level_info = answer.json()["level_info"]
self.last_level = self.level_info["last_level"]
else:
log.warning("COULD NOT GET GAME CONNECTION")
@@ -1538,14 +1540,13 @@ class PyGameGUI:
def start_study(self):
answer = requests.post(
f"{self.request_url}/start_study/{self.participant_id}/{self.number_humans_to_be_added}"
).json()
if answer["status_code"] == 200:
)
if answer.status_code == 200:
self.last_level = False
self.player_info = answer["data"]
self.get_game_connection(tutorial=False)
else:
self.menu_state = MenuStates.Start
print("COULD NOT START STUDY; Response:", answer["status_code"])
print("COULD NOT START STUDY; Response:", answer.status_code)
def send_level_done(self):
_ = requests.post(f"{self.request_url}/level_done/{self.participant_id}").json()
Loading