From 4910bb5ad3db580e24ce816928c99120fb385cec Mon Sep 17 00:00:00 2001 From: Battlefield Duck Date: Tue, 23 Jan 2024 07:52:54 +0800 Subject: [PATCH] Update All-Seeing Eye Protocol --- docs/conf.py | 1 + docs/favicon.ico | Bin 0 -> 15086 bytes opengsq/protocols/ase.py | 21 +++++---- opengsq/responses/ase/player.py | 6 +-- opengsq/responses/ase/status.py | 16 +++---- tests/results/test_ase/test_get_status.json | 46 ++++++-------------- 6 files changed, 34 insertions(+), 56 deletions(-) create mode 100644 docs/favicon.ico 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 0000000000000000000000000000000000000000..47e1e8ff533783e18637c46dbf1f3157d9bc6a60 GIT binary patch literal 15086 zcmeHOX>b%p6dnpne@GSn^$*4>t@0Q6%b%j+eU;#?RUV~+cNK!S1)(f&Ew$A00)ilz zgv3M<19C<1KtMq`M3HdBcx8{7Y<4%BJ)Yk;v%NdB+3e2DZq~$dikIH$>F)Qv*WIsQ zziu>boHkxN;|vXHoz{4ork$y2T3ucC{X|XcLf(l;`Ted5n)VC|oQ^W6qTLE&zWJPL zC2s#NnI0GissqgewSu}pF;E61RVKE{w#kFM$dkOsxy5TQhkBDi^FjMTgP>~TE!Q4- zk~c9-wqq;x8)YYeW`cHuGN5vNM*2H35DPJ3bPfOD`*EOoARRQ)xV*McOmjiU6_Wt@ z<3SICI0n78U90lMMvUVNWkB8xPzY2jEPnYA;|x1~yq^r(H3qONnTa(wr}3L}TzwlW z>3sG9aGwI&S1JC*=LTfa*#TL6P6<7zGDs`sm&Hu%vq6>Fci{Q(nt-f(JS45R1&77f zd{fXY({y97w4Cn70x@%qYXJ?*v+OruUoj&fN576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p2d%5MJ( z?GNXFGCTe%)jwk~TVFQJJ1n$i2iM1N7cYqOqP+bbN&eLL%BzENXmbqLXfTICU7d0H z{0W>h7-=(aB>5|Q&wDVxbXc~GFv3R%p=0p3of9ehUrqhnZO-y50 zgQU!P!}+6hSSBTJcm5YK;11fxg}Q8c5q=hIgYxz0e|_RCU*?%K`Fby$;v+X)^= zz>7S|n{f(;CF(%AIK?pk8wmJM0=)$40hNk%@f*vq>`7>vW1MyQ|G!GrE7T>+vX0`L z#&1U%^KNf8kNzHQWkDI%Ar8ht^50O7`;#A=qSACj2>(wYDEr%EviiQFzAEcFc+=Lj z-WnF8+p@VI-ER2?dUw)V1DrP4QI|MWeLY*h4fP{`q@?G&1n&AL<@3jkoPBlR&dM;P zK713l#XBFnmPbvw?7AszqgZ|8x0JNqiF@nNqiNsm`m+62eqqZk7Ek(W^o>}bJ{sFD zpI2{+i0I1Hhq((>#gy_vDA1i&RBU;j! V<{;bhJbyb83$6EIl~{*${{aq;M+N`@ literal 0 HcmV?d00001 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 + } }