Skip to content

Commit

Permalink
Update All-Seeing Eye Protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
BattlefieldDuck committed Jan 22, 2024
1 parent bbc0ba0 commit 4910bb5
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 56 deletions.
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Binary file added docs/favicon.ico
Binary file not shown.
21 changes: 12 additions & 9 deletions opengsq/protocols/ase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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)

Expand All @@ -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),
)
Expand Down
6 changes: 1 addition & 5 deletions opengsq/responses/ase/player.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from dataclasses import asdict, dataclass
from dataclasses import dataclass


@dataclass
Expand All @@ -26,7 +26,3 @@ class Player:

time: int
"""The time of the player."""

@property
def __dict__(self):
return asdict(self)
16 changes: 6 additions & 10 deletions opengsq/responses/ase/status.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand All @@ -32,18 +32,14 @@ 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)
"""The rules of the game. Defaults to an empty dictionary."""

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)
46 changes: 14 additions & 32 deletions tests/results/test_ase/test_get_status.json
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 4910bb5

Please sign in to comment.