Crain-32 / Multiworld_Client

MIT License
1 stars 4 forks source link

Separation of Dolphin and Server Communication #3

Closed Crain-32 closed 2 years ago

Crain-32 commented 2 years ago

Reason

The current implementation puts both the Server-Client communication with the Client-Dolphin Communication in clientSocket.py, this should instead be refactored into three different files.

clientCommunication.py

This will handle the Client-Server communication. For now a simple copy-paste would work. Future iterations will likely require additional utilization of the stompframemanager.py, as we currently don't communicate with the Server following the proper STOMP guidelines.

abstractGameHandler.py

The eventual Console integration will require a separate Python file to handle its communication, in an effort to prepare for that an AbstractGameHandler class should be created with the following methods.

is_connected() -> bool: give_item(item_id: int) -> None: toggle_event(event_type: str, event_index: int, enable: bool) -> None: get_items() -> dict[int, int]:

dolphinGameHandler.py

This class will be a dolphin-focused implementation of the AbstractGameHandler, and should have all the abstract classes implemented at the very least.

Exceptions

The following should be a list of extensions of RunTimeException|RunTimeWarningthat should be raised in certain events, this will be useful for long-term debugging and end-user experience

CouldNotGiveItemException - If give_item() experiences an unexpected error. DuplicateItemWarning - If the give_item() would create an invalid item (5th Sword, 4th Bow, Second Grapple, etc) EventToggleException - If the toggle_event() function experiences an unexpected error. GameHandlerDisconnectWarning - If the connection between the Client and the AbstractGameHandler fails. ServerDisconnectWarning - If the connection between the Client and the Server fails.