Skip to content
Snippets Groups Projects
Commit db592d64 authored by Florian Schröder's avatar Florian Schröder
Browse files

Refactor argument parser in Overcooked Simulator

The argument parser and related function calls have been moved from the `__main__` function in the Overcooked Simulator to the `main` function. This change streamlines the function calls and improves code readability and management. Furthermore, it ensures that essential configurations are in place before the game server and GUI are initiated.
parent 000c29b0
No related branches found
No related tags found
No related merge requests found
Pipeline #45012 passed
...@@ -23,6 +23,16 @@ def start_pygame_gui(cli_args): ...@@ -23,6 +23,16 @@ def start_pygame_gui(cli_args):
def main(cli_args=None): def main(cli_args=None):
if cli_args is None: if cli_args is None:
parser = argparse.ArgumentParser(
prog="Overcooked Simulator",
description="Game Engine Server + PyGameGUI: Starts overcooked game engine server and a PyGame 2D Visualization window in two processes.",
epilog="For further information, see https://scs.pages.ub.uni-bielefeld.de/cocosy/overcooked-simulator/overcooked_simulator.html",
)
url_and_port_arguments(parser)
disable_websocket_logging_arguments(parser)
add_list_of_manager_ids_arguments(parser)
cli_args = parser.parse_args() cli_args = parser.parse_args()
game_server = None game_server = None
pygame_gui = None pygame_gui = None
...@@ -40,7 +50,7 @@ def main(cli_args=None): ...@@ -40,7 +50,7 @@ def main(cli_args=None):
print("Received Keyboard interrupt") print("Received Keyboard interrupt")
finally: finally:
if game_server is not None and game_server.is_alive(): if game_server is not None and game_server.is_alive():
print("Terminate game server") print("Terminate gparserame server")
game_server.terminate() game_server.terminate()
if pygame_gui is not None and pygame_gui.is_alive(): if pygame_gui is not None and pygame_gui.is_alive():
print("Terminate pygame gui") print("Terminate pygame gui")
...@@ -49,15 +59,4 @@ def main(cli_args=None): ...@@ -49,15 +59,4 @@ def main(cli_args=None):
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser( main()
prog="Overcooked Simulator",
description="Game Engine Server + PyGameGUI: Starts overcooked game engine server and a PyGame 2D Visualization window in two processes.",
epilog="For further information, see https://scs.pages.ub.uni-bielefeld.de/cocosy/overcooked-simulator/overcooked_simulator.html",
)
url_and_port_arguments(parser)
disable_websocket_logging_arguments(parser)
add_list_of_manager_ids_arguments(parser)
args = parser.parse_args()
main(args)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment