# Path: constants/dataTypes.py
# BYTE = 0
# UINT16 = 1
# SINT16 = 2
# UINT32 = 3
# SINT32 = 4
# UINT64 = 5
# SINT64 = 6
# STRING = 7
# FFLOAT = 8		# 'float' is a keyword
# BBYTES = 9      # 'bytes' is a keyword
# INT_LIST = 10   # TODO: Maybe there are some packets that still use uInt16 + uInt32 thing somewhere.
# 
# Path: constants/packetIDs.py

# 
# Path: constants/userRanks.py
# NORMAL			= 0
# PLAYER			= 1
# BAT				= 2
# SUPPORTER		= 4
# MOD				= 6
# PEPPY			= 8
# ADMIN			= 16
# TOURNAMENT_STAFF = 32
# 
# Path: objects/glob.py
# 		VERSION = f.read().strip()
# 	VERSION = "Unknown"
# DATADOG_PREFIX = "peppy"


from common.constants import privileges
from common.ripple import userUtils
from constants import dataTypes
from constants import packetIDs
from constants import userRanks
from helpers import packetHelper
from objects import glob

""" Login packets """
def userID(uid):
	return packetHelper.buildPacket(packetIDs.server_userID, [[uid, dataTypes.SINT32]])

def silenceEndTime(seconds):
	return packetHelper.buildPacket(packetIDs.server_silenceEnd, [[seconds, dataTypes.UINT32]])

def protocolVersion(version = 19):
	return packetHelper.buildPacket(packetIDs.server_protocolVersion, [[version, dataTypes.UINT32]])

def mainMenuIcon(icon):
	return packetHelper.buildPacket(packetIDs.server_mainMenuIcon, [[icon, dataTypes.STRING]])

def userSupporterGMT(supporter, GMT, tournamentStaff):
	result = 1
	if supporter:
		result |= userRanks.SUPPORTER
	if GMT:
		result |= userRanks.BAT
	if tournamentStaff:
		result |= userRanks.TOURNAMENT_STAFF
	return packetHelper.buildPacket(packetIDs.server_supporterGMT, [[result, dataTypes.UINT32]])

def friendList(userID):
	friends = userUtils.getFriendList(userID)
	return packetHelper.buildPacket(packetIDs.server_friendsList, [[friends, dataTypes.INT_LIST]])

def onlineUsers():
	userIDs = []

# Path: constants/dataTypes.py
# BYTE = 0
# UINT16 = 1
# SINT16 = 2
# UINT32 = 3
# SINT32 = 4
# UINT64 = 5
# SINT64 = 6
# STRING = 7
# FFLOAT = 8		# 'float' is a keyword
# BBYTES = 9      # 'bytes' is a keyword
# INT_LIST = 10   # TODO: Maybe there are some packets that still use uInt16 + uInt32 thing somewhere.
# 
# Path: constants/packetIDs.py

# 
# Path: constants/userRanks.py
# NORMAL			= 0
# PLAYER			= 1
# BAT				= 2
# SUPPORTER		= 4
# MOD				= 6
# PEPPY			= 8
# ADMIN			= 16
# TOURNAMENT_STAFF = 32
# 
# Path: objects/glob.py
# 		VERSION = f.read().strip()
# 	VERSION = "Unknown"
# DATADOG_PREFIX = "peppy"


# Path: constants/serverPackets.py
from common.constants import privileges
from common.ripple import userUtils
from constants import dataTypes
from constants import packetIDs
from constants import userRanks
from helpers import packetHelper
from objects import glob


""" Login packets """
def userID(uid):
	return packetHelper.buildPacket(packetIDs.server_userID, [[uid, dataTypes.SINT32]])

def silenceEndTime(seconds):
	return packetHelper.buildPacket(packetIDs.server_silenceEnd, [[seconds, dataTypes.UINT32]])

def protocolVersion(version = 19):
	return packetHelper.buildPacket(packetIDs.server_protocolVersion, [[version, dataTypes.UINT32]])

def mainMenuIcon(icon):
	return packetHelper.buildPacket(packetIDs.server_mainMenuIcon, [[icon, dataTypes.STRING]])

def userSupporterGMT(supporter, GMT, tournamentStaff):
	result = 1
	if supporter:
		result |= userRanks.SUPPORTER
	if GMT:
		result |= userRanks.BAT
	if tournamentStaff:
		result |= userRanks.TOURNAMENT_STAFF
	return packetHelper.buildPacket(packetIDs.server_supporterGMT, [[result, dataTypes.UINT32]])

def friendList(userID):
	friends = userUtils.getFriendList(userID)
	return packetHelper.buildPacket(packetIDs.server_friendsList, [[friends, dataTypes.INT_LIST]])

def onlineUsers():
	userIDs = []

	users = glob.tokens.tokens