Skip to content

Commit 553b6d5

Browse files
committed
Adding Halo1 Support
1 parent 2e8e2b4 commit 553b6d5

6 files changed

Lines changed: 92 additions & 0 deletions

File tree

docs/tests/protocols/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Protocols Tests
55

66
.. toctree::
77
test_cod4/index
8+
test_halo1/index
89
test_flatout2/index
910
test_battlefield2/index
1011
test_source/index
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. _test_halo1:
2+
3+
test_halo1
4+
==========
5+
6+
.. toctree::
7+
test_get_status
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
test_get_status
2+
===============
3+
4+
Here are the results for the test method.
5+
6+
.. code-block:: json
7+
8+
{
9+
"info": {
10+
"hostname": "YoMama",
11+
"gamever": "01.00.00.0564",
12+
"hostport": "",
13+
"maxplayers": "4",
14+
"password": "0",
15+
"mapname": "beavercreek",
16+
"dedicated": "0",
17+
"gamemode": "openplaying",
18+
"game_classic": "0",
19+
"numplayers": "1",
20+
"gametype": "Oddball",
21+
"teamplay": "0",
22+
"gamevariant": "Juggernaut",
23+
"fraglimit": "15",
24+
"player_flags": "1129320516,2",
25+
"game_flags": "12579"
26+
},
27+
"players": [
28+
{
29+
"player": "New001",
30+
"score": ":00",
31+
"ping": "",
32+
"team": "0"
33+
}
34+
],
35+
"teams": []
36+
}

opengsq/protocols/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from opengsq.protocols.gamespy2 import GameSpy2
1818
from opengsq.protocols.gamespy3 import GameSpy3
1919
from opengsq.protocols.gamespy4 import GameSpy4
20+
from opengsq.protocols.halo1 import Halo1
2021
from opengsq.protocols.kaillera import Kaillera
2122
from opengsq.protocols.killingfloor import KillingFloor
2223
from opengsq.protocols.minecraft import Minecraft

opengsq/protocols/halo1.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from __future__ import annotations
2+
3+
from opengsq.protocols.gamespy2 import GameSpy2
4+
5+
6+
class Halo1(GameSpy2):
7+
"""Halo 1 Multiplayer Protocol (based on GameSpy2)"""
8+
9+
full_name = "Halo 1 Multiplayer"
10+
11+
def __init__(self, host: str, port: int = 2302, timeout: float = 5.0):
12+
"""
13+
Initialize the Halo 1 protocol.
14+
15+
:param host: The server host address
16+
:param port: The server port (default: 2302)
17+
:param timeout: The timeout for the connection (default: 5.0 seconds)
18+
"""
19+
super().__init__(host, port, timeout)
20+
21+
22+
if __name__ == "__main__":
23+
import asyncio
24+
25+
async def main_async():
26+
halo1 = Halo1(host="172.29.100.29", port=2302, timeout=5.0)
27+
status = await halo1.get_status()
28+
print(status)
29+
30+
asyncio.run(main_async())
31+

tests/protocols/test_halo1.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import pytest
2+
from opengsq.protocols.halo1 import Halo1
3+
4+
from ..result_handler import ResultHandler
5+
6+
handler = ResultHandler(__file__)
7+
handler.enable_save = True
8+
9+
# bfv
10+
test = Halo1(host="172.29.100.29", port=2302)
11+
12+
13+
@pytest.mark.asyncio
14+
async def test_get_status():
15+
result = await test.get_status()
16+
await handler.save_result("test_get_status", result)

0 commit comments

Comments
 (0)