.BANCHO. Add support for tournament client

This commit is contained in:
Nyo
2016-10-05 23:28:26 +02:00
parent 795b6f09be
commit 996287f871
13 changed files with 91 additions and 25 deletions

View File

@@ -143,3 +143,12 @@ def transferHost(stream):
def matchInvite(stream):
return packetHelper.readPacketData(stream, [["userID", dataTypes.UINT32]])
def tournamentMatchInfoRequest(stream):
return packetHelper.readPacketData(stream, [["matchID", dataTypes.UINT32]])
def tournamentJoinMatchChannel(stream):
return packetHelper.readPacketData(stream, [["matchID", dataTypes.UINT32]])
def tournamentLeaveMatchChannel(stream):
return packetHelper.readPacketData(stream, [["matchID", dataTypes.UINT32]])

View File

@@ -88,4 +88,7 @@ class loginLockedException(Exception):
pass
class unknownStreamException(Exception):
pass
class userTournamentException(Exception):
pass

View File

@@ -74,7 +74,9 @@ server_channelInfoEnd = 89
client_matchChangePassword = 90
server_matchChangePassword = 91
server_silenceEnd = 92
client_specialMatchInfoRequest = 93
server_userSilenced = 94
server_userPresenceBundle = 96
client_userPanelRequest = 97
client_tournamentMatchInfoRequest = 93
client_tournamentJoinMatchChannel = 108
client_tournamentLeaveMatchChannel = 109

View File

@@ -50,9 +50,10 @@ def mainMenuIcon(icon):
def userSupporterGMT(supporter, GMT):
result = 1
if supporter:
result += 4
result |= userRanks.SUPPORTER
if GMT:
result += 2
result |= userRanks.BAT
result |= userRanks.TOURNAMENT_STAFF
return packetHelper.buildPacket(packetIDs.server_supporterGMT, [[result, dataTypes.UINT32]])
def friendList(userID):
@@ -78,9 +79,7 @@ def userLogout(userID):
def userPanel(userID, force = False):
# Connected and restricted check
userToken = glob.tokens.getTokenFromUserID(userID)
if userToken is None:
return bytes()
if userToken.restricted == True and force == False:
if userToken is None or ((userToken.restricted) and not force):
return bytes()
# Get user data
@@ -93,16 +92,17 @@ def userPanel(userID, force = False):
# Get username color according to rank
# Only admins and normal users are currently supported
userRank = 0
if username == "FokaBot":
userRank = userRanks.MOD
userRank |= userRanks.MOD
elif userUtils.isInPrivilegeGroup(userID, "community manager"):
userRank = userRanks.MOD
userRank |= userRanks.MOD
elif userUtils.isInPrivilegeGroup(userID, "developer"):
userRank = userRanks.ADMIN
userRank |= userRanks.ADMIN
elif (userToken.privileges & privileges.USER_DONOR) > 0:
userRank = userRanks.SUPPORTER
userRank |= userRanks.SUPPORTER
else:
userRank = userRanks.NORMAL
userRank |= userRanks.NORMAL
return packetHelper.buildPacket(packetIDs.server_userPanel,
[
@@ -120,10 +120,7 @@ def userPanel(userID, force = False):
def userStats(userID, force = False):
# Get userID's token from tokens list
userToken = glob.tokens.getTokenFromUserID(userID)
if userToken is None:
return bytes()
if (userToken.restricted == True or userToken.irc == True) and force == False:
if userToken is None or ((userToken.restricted or userToken.irc or userToken.tournament) and not force):
return bytes()
return packetHelper.buildPacket(packetIDs.server_userStats,
@@ -204,6 +201,7 @@ def createMatch(matchID):
match = glob.matches.matches[matchID]
return packetHelper.buildPacket(packetIDs.server_newMatch, match.getMatchData())
# TODO: Add match object argument to save some CPU
def updateMatch(matchID):
# Make sure the match exists
if matchID not in glob.matches.matches:

View File

@@ -1,8 +1,9 @@
"""Bancho user ranks"""
NORMAL = 0
PLAYER = 1
BAT = 2
SUPPORTER = 4
MOD = 6
PEPPY = 8
ADMIN = 16
TOURNAMENTSTAFF = 32
TOURNAMENT_STAFF = 32