slay.py

 1from slay import Info
 2
 3def GlobalChatHistory(limit: int = 25):
 4    return f'{{"gcHistory":{{"channel":"global","limit":{limit}}}}}'
 5
 6def GameList():
 7    return "req-games-list"
 8
 9def JoinGameRoom(id: int):
10    """ Server will not respond if the game room not found """
11
12    return f"join-game${id}"
13
14def JoinGame(team_id: int = 1):
15    return f"joinTeam${team_id}"
16
17def LeaveGame():
18    return "leave-game"
19
20def LogIn(username: str, password: str):
21    return f"login${username}${password}"
22
23def StartMoving(direction: Info.MovingDirection):
24    return f"kd${direction.value}"
25
26def StopMoving(direction: Info.MovingDirection):
27    return f"ku${direction.value}"
28
29def JoinRandomGameRoom(mode: Info.GameMode):
30    return f"joinRandomGame$undefined${mode.id}"
31
32def UpdateHeadDirection(direction: Info.HeadDirection):
33    return f"dirU${direction.value}"
34
35def UseAbility(ability: Info.Ability):
36    return f"ab${ability.value}"
37
38def Respawn():
39    return "respawn"
40
41def UpdateProfileText(text: str):
42    if len(text) > 255:
43        raise OverflowError("The length of profile text cannot be over 255.")
44
45    return f"update-profile-text${text}"
46
47def MessageInGame(content: str):
48
49    if len(content) > 140:
50        raise OverflowError("The length of message in game cannot be over 140.")
51
52    return f"chat{content}"
53
54def CreateGame(
55    map_id: int,
56    round_minutes: int,
57    maximum_number_of_bots: int,
58    mode_id: int,
59    is_private: bool = False,
60):
61    return f"create-game${map_id}${round_minutes}${maximum_number_of_bots}${mode_id}${int(is_private)}"
62
63def ClanInfo(clan_tag: str):
64    if clan_tag:
65        return f"myClanInfo${clan_tag}"
66    else:
67        return "myClanInfo"
68
69def ClanMemberList(clan_tag: str):
70    return f"getMemberList${clan_tag}"
def GlobalChatHistory(limit: int = 25):
4def GlobalChatHistory(limit: int = 25):
5    return f'{{"gcHistory":{{"channel":"global","limit":{limit}}}}}'
def GameList():
7def GameList():
8    return "req-games-list"
def JoinGameRoom(id: int):
10def JoinGameRoom(id: int):
11    """ Server will not respond if the game room not found """
12
13    return f"join-game${id}"

Server will not respond if the game room not found

def JoinGame(team_id: int = 1):
15def JoinGame(team_id: int = 1):
16    return f"joinTeam${team_id}"
def LeaveGame():
18def LeaveGame():
19    return "leave-game"
def LogIn(username: str, password: str):
21def LogIn(username: str, password: str):
22    return f"login${username}${password}"
def StartMoving(direction: slay.data.info.game.MovingDirection):
24def StartMoving(direction: Info.MovingDirection):
25    return f"kd${direction.value}"
def StopMoving(direction: slay.data.info.game.MovingDirection):
27def StopMoving(direction: Info.MovingDirection):
28    return f"ku${direction.value}"
def JoinRandomGameRoom(mode: slay.data.info.game.GameMode):
30def JoinRandomGameRoom(mode: Info.GameMode):
31    return f"joinRandomGame$undefined${mode.id}"
def UpdateHeadDirection(direction: slay.data.info.game.HeadDirection):
33def UpdateHeadDirection(direction: Info.HeadDirection):
34    return f"dirU${direction.value}"
def UseAbility(ability: slay.data.info.game.Ability):
36def UseAbility(ability: Info.Ability):
37    return f"ab${ability.value}"
def Respawn():
39def Respawn():
40    return "respawn"
def UpdateProfileText(text: str):
42def UpdateProfileText(text: str):
43    if len(text) > 255:
44        raise OverflowError("The length of profile text cannot be over 255.")
45
46    return f"update-profile-text${text}"
def MessageInGame(content: str):
48def MessageInGame(content: str):
49
50    if len(content) > 140:
51        raise OverflowError("The length of message in game cannot be over 140.")
52
53    return f"chat{content}"
def CreateGame( map_id: int, round_minutes: int, maximum_number_of_bots: int, mode_id: int, is_private: bool = False):
55def CreateGame(
56    map_id: int,
57    round_minutes: int,
58    maximum_number_of_bots: int,
59    mode_id: int,
60    is_private: bool = False,
61):
62    return f"create-game${map_id}${round_minutes}${maximum_number_of_bots}${mode_id}${int(is_private)}"
def ClanInfo(clan_tag: str):
64def ClanInfo(clan_tag: str):
65    if clan_tag:
66        return f"myClanInfo${clan_tag}"
67    else:
68        return "myClanInfo"
def ClanMemberList(clan_tag: str):
70def ClanMemberList(clan_tag: str):
71    return f"getMemberList${clan_tag}"