diff --git a/docs/conf.py b/docs/conf.py index 6c43557..936fea0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,4 +25,5 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output html_theme = 'sphinx_rtd_theme' +html_favicon = 'favicon.ico' html_static_path = ['_static'] diff --git a/docs/favicon.ico b/docs/favicon.ico new file mode 100644 index 0000000..47e1e8f Binary files /dev/null and b/docs/favicon.ico differ diff --git a/opengsq/protocols/ase.py b/opengsq/protocols/ase.py index 1fb8019..6ee48bf 100644 --- a/opengsq/protocols/ase.py +++ b/opengsq/protocols/ase.py @@ -8,7 +8,9 @@ class ASE(ProtocolBase): - """All-Seeing Eye Protocol""" + """ + This class represents the All-Seeing Eye Protocol. It provides methods to interact with the All-Seeing Eye API. + """ full_name = "All-Seeing Eye Protocol" @@ -17,10 +19,11 @@ class ASE(ProtocolBase): async def get_status(self) -> Status: """ - Asynchronously get the status of the game server. + Asynchronously retrieves the status of the game server. - Returns: - Status: The status of the game server. + This method sends a request to the server and parses the response to create a Status object. + + :return: The status of the game server. """ response = await UdpClient.communicate(self, self._request) @@ -29,15 +32,15 @@ async def get_status(self) -> Status: InvalidPacketException.throw_if_not_equal(header, self._response) return Status( - gamename=br.read_pascal_string(), - gameport=int(br.read_pascal_string()), + game_name=br.read_pascal_string(), + game_port=int(br.read_pascal_string()), hostname=br.read_pascal_string(), - gametype=br.read_pascal_string(), + game_type=br.read_pascal_string(), map=br.read_pascal_string(), version=br.read_pascal_string(), password=br.read_pascal_string() != "0", - numplayers=int(br.read_pascal_string()), - maxplayers=int(br.read_pascal_string()), + num_players=int(br.read_pascal_string()), + max_players=int(br.read_pascal_string()), rules=self.__parse_rules(br), players=self.__parse_players(br), ) diff --git a/opengsq/responses/ase/player.py b/opengsq/responses/ase/player.py index 5545253..0b69c46 100644 --- a/opengsq/responses/ase/player.py +++ b/opengsq/responses/ase/player.py @@ -1,6 +1,6 @@ from __future__ import annotations -from dataclasses import asdict, dataclass +from dataclasses import dataclass @dataclass @@ -26,7 +26,3 @@ class Player: time: int """The time of the player.""" - - @property - def __dict__(self): - return asdict(self) diff --git a/opengsq/responses/ase/status.py b/opengsq/responses/ase/status.py index ee2ab98..466cb88 100644 --- a/opengsq/responses/ase/status.py +++ b/opengsq/responses/ase/status.py @@ -1,6 +1,6 @@ from __future__ import annotations -from dataclasses import asdict, dataclass, field +from dataclasses import dataclass, field from opengsq.responses.ase.player import Player @@ -11,16 +11,16 @@ class Status: Represents the status of a game server. """ - gamename: str + game_name: str """The name of the game.""" - gameport: int + game_port: int """The port number of the game server.""" hostname: str """The hostname of the game server.""" - gametype: str + game_type: str """The type of the game.""" map: str @@ -32,10 +32,10 @@ class Status: password: bool """Whether a password is required to join the game.""" - numplayers: int + num_players: int """The number of players currently in the game.""" - maxplayers: int + max_players: int """The maximum number of players allowed in the game.""" rules: dict[str, str] = field(default_factory=dict) @@ -43,7 +43,3 @@ class Status: players: list[Player] = field(default_factory=list) """The players currently in the game. Defaults to an empty list.""" - - @property - def __dict__(self): - return asdict(self) diff --git a/tests/results/test_ase/test_get_status.json b/tests/results/test_ase/test_get_status.json index c30f99a..bbe0e46 100644 --- a/tests/results/test_ase/test_get_status.json +++ b/tests/results/test_ase/test_get_status.json @@ -1,38 +1,20 @@ { - "gamename": "mta", - "gameport": "22003", + "game_name": "mta", + "game_port": 22003, "hostname": "MTA Türkiye ✖ GÜL GAMİNG FREEROAM ✖ [Roleplay/Askeri/Drift/Drop/Turkey/Tr/Gül Gaming]", - "gametype": "BEDAVA - VIP", + "game_type": "BEDAVA - VIP", "map": "None", "version": "1.6", - "password": "0", - "numplayers": "3", - "maxplayers": "120", + "password": false, + "num_players": 13, + "max_players": 120, "rules": {}, - "players": [ - { - "name": "majorka", - "team": "", - "skin": "", - "score": "", - "ping": "68", - "time": "" - }, - { - "name": "BlueCans43", - "team": "", - "skin": "", - "score": "", - "ping": "254", - "time": "" - }, - { - "name": "AlluringCascades49", - "team": "", - "skin": "", - "score": "", - "ping": "96", - "time": "" - } - ] + "players": { + "name": "ohland", + "team": "", + "skin": "", + "score": 0, + "ping": 53, + "time": 0 + } }