Skip to content
Snippets Groups Projects

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

2 files
+ 15
13
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -189,6 +189,8 @@ class PyGameGUI:
self.last_state: StateRepresentation
self.player_info = {"0": {"name": "0"}}
self.level_info = {"name": "Level", "recipe_graphs": []}
self.last_level = False
self.beeped_once = False
self.all_completed_meals = []
@@ -1023,13 +1025,12 @@ class PyGameGUI:
if self.CONNECT_WITH_STUDY_SERVER:
self.send_level_done()
else:
self.stop_game_on_server("finished_button_pressed")
pass
# self.stop_game_on_server("finished_button_pressed")
self.disconnect_websockets()
self.update_postgame_screen(self.last_state)
self.update_screen_elements()
for el in self.last_completed_meals:
el.show()
self.beeped_once = False
def draw_game_screen_frame(self):
@@ -1145,8 +1146,7 @@ class PyGameGUI:
environment_config = file.read()
num_players = 1 if tutorial else self.number_players
seed = 1234
print("GUI MANAGER ID", self.manager_id)
seed = int(random.random() * 100000)
creation_json = CreateEnvironmentConfig(
manager_id=self.manager_id,
number_players=num_players,
@@ -1164,6 +1164,8 @@ class PyGameGUI:
)
if env_info.status_code == 403:
raise ValueError(f"Forbidden Request: {env_info.json()['detail']}")
elif env_info.status_code == 409:
print("CONFLICT")
env_info = env_info.json()
assert isinstance(env_info, dict), "Env info must be a dictionary"
self.current_env_id = env_info["env_id"]
@@ -1549,18 +1551,17 @@ class PyGameGUI:
_ = requests.post(f"{self.request_url}/level_done/{self.participant_id}").json()
def button_continue_postgame_pressed(self):
if not self.CONNECT_WITH_STUDY_SERVER:
if self.CONNECT_WITH_STUDY_SERVER:
if not self.last_level:
self.get_game_connection(tutorial=False)
else:
self.current_layout_idx += 1
self.create_env_on_game_server(tutorial=False)
if self.current_layout_idx == len(self.layout_file_paths) - 1:
self.last_level = True
else:
log.debug(f"LEVEL: {self.layout_file_paths[self.current_layout_idx]}")
else:
if not self.last_level:
if self.CONNECT_WITH_STUDY_SERVER:
self.get_game_connection(tutorial=False)
else:
self.create_env_on_game_server(tutorial=False)
self.menu_state = MenuStates.PreGame
def manage_button_event(self, event):
Loading