# 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/matchModModes.py
# NORMAL = 0
# FREE_MOD = 1
# 
# Path: constants/matchScoringTypes.py
# SCORE = 0
# ACCURACY = 1
# COMBO = 2
# SCORE_V2 = 3
# 
# Path: constants/matchTeamTypes.py
# HEAD_TO_HEAD = 0
# TAG_COOP = 1
# TEAM_VS = 2
# TAG_TEAM_VS = 3
# 
# Path: constants/matchTeams.py
# NO_TEAM = 0
# BLUE = 1
# RED = 2
# 
# Path: constants/serverPackets.py
# def loginFailed():
# def forceUpdate():
# def loginBanned():
# def loginLocked():
# def loginError():
# def needSupporter():
# def needVerification():
# def userID(uid):
# def silenceEndTime(seconds):
# def protocolVersion(version = 19):
# def mainMenuIcon(icon):
# def userSupporterGMT(supporter, GMT, tournamentStaff):
# def friendList(userID):
# def onlineUsers():
# def userLogout(userID):
# def userPanel(userID, force = False):
# def userStats(userID, force = False):
# def sendMessage(fro, to, message):
# def channelJoinSuccess(userID, chan):
# def channelInfo(chan):
# def channelInfoEnd():
# def channelKicked(chan):
# def userSilenced(userID):
# def addSpectator(userID):
# def removeSpectator(userID):
# def spectatorFrames(data):
# def noSongSpectator(userID):
# def fellowSpectatorJoined(userID):
# def fellowSpectatorLeft(userID):
# def createMatch(matchID):
# def updateMatch(matchID, censored = False):
# def matchStart(matchID):
# def disposeMatch(matchID):
# def matchJoinSuccess(matchID):
# def matchJoinFail():
# def changeMatchPassword(newPassword):
# def allPlayersLoaded():
# def playerSkipped(userID):
# def allPlayersSkipped():
# def matchFrames(slotID, data):
# def matchComplete():
# def playerFailed(slotID):
# def matchTransferHost():
# def matchAbort():
# def switchServer(address):
# def notification(message):
# def banchoRestart(msUntilReconnection):
# def rtx(message):
# 
# Path: constants/slotStatuses.py
# FREE = 1
# LOCKED = 2
# NOT_READY = 4
# READY = 8
# NO_MAP = 16
# PLAYING = 32
# OCCUPIED = 124
# PLAYING_QUIT = 128
# 
# Path: helpers/chatHelper.py
# def joinChannel(userID = 0, channel = "", token = None, toIRC = True, force=False):
# def partChannel(userID = 0, channel = "", token = None, toIRC = True, kick = False, force=False):
# def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
# def fixUsernameForBancho(username):
# def fixUsernameForIRC(username):
# def IRCConnect(username):
# def IRCDisconnect(username):
# def IRCJoinChannel(username, channel):
# def IRCPartChannel(username, channel):
# def IRCAway(username, message):
# 
# Path: objects/glob.py
# 		VERSION = f.read().strip()
# 	VERSION = "Unknown"
# DATADOG_PREFIX = "peppy"


import copy
import json
import threading
import time
from common.log import logUtils as log
from constants import dataTypes
from constants import matchModModes
from constants import matchScoringTypes
from constants import matchTeamTypes
from constants import matchTeams
from constants import serverPackets
from constants import slotStatuses
from helpers import chatHelper as chat
from objects import glob
		self.score = 0
		self.failed = False
		self.passed = True

class match:
	def __init__(self, matchID, matchName, matchPassword, beatmapID, beatmapName, beatmapMD5, gameMode, hostUserID, isTourney=False):
		"""
		Create a new match object

		:param matchID: match progressive identifier
		:param matchName: match name, string
		:param matchPassword: match md5 password. Leave empty for no password
		:param beatmapID: beatmap ID
		:param beatmapName: beatmap name, string
		:param beatmapMD5: beatmap md5 hash, string
		:param gameMode: game mode ID. See gameModes.py
		:param hostUserID: user id of the host
		"""
		self.matchID = matchID
		self.streamName = "multi/{}".format(self.matchID)
		self.playingStreamName = "{}/playing".format(self.streamName)
		self.inProgress = False
		self.mods = 0
		self.matchName = matchName
		self.matchPassword = matchPassword
		self.beatmapID = beatmapID
		self.beatmapName = beatmapName
		self.beatmapMD5 = beatmapMD5
		self.hostUserID = hostUserID
		self.gameMode = gameMode

# 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/matchModModes.py
# NORMAL = 0
# FREE_MOD = 1
# 
# Path: constants/matchScoringTypes.py
# SCORE = 0
# ACCURACY = 1
# COMBO = 2
# SCORE_V2 = 3
# 
# Path: constants/matchTeamTypes.py
# HEAD_TO_HEAD = 0
# TAG_COOP = 1
# TEAM_VS = 2
# TAG_TEAM_VS = 3
# 
# Path: constants/matchTeams.py
# NO_TEAM = 0
# BLUE = 1
# RED = 2
# 
# Path: constants/serverPackets.py
# def loginFailed():
# def forceUpdate():
# def loginBanned():
# def loginLocked():
# def loginError():
# def needSupporter():
# def needVerification():
# def userID(uid):
# def silenceEndTime(seconds):
# def protocolVersion(version = 19):
# def mainMenuIcon(icon):
# def userSupporterGMT(supporter, GMT, tournamentStaff):
# def friendList(userID):
# def onlineUsers():
# def userLogout(userID):
# def userPanel(userID, force = False):
# def userStats(userID, force = False):
# def sendMessage(fro, to, message):
# def channelJoinSuccess(userID, chan):
# def channelInfo(chan):
# def channelInfoEnd():
# def channelKicked(chan):
# def userSilenced(userID):
# def addSpectator(userID):
# def removeSpectator(userID):
# def spectatorFrames(data):
# def noSongSpectator(userID):
# def fellowSpectatorJoined(userID):
# def fellowSpectatorLeft(userID):
# def createMatch(matchID):
# def updateMatch(matchID, censored = False):
# def matchStart(matchID):
# def disposeMatch(matchID):
# def matchJoinSuccess(matchID):
# def matchJoinFail():
# def changeMatchPassword(newPassword):
# def allPlayersLoaded():
# def playerSkipped(userID):
# def allPlayersSkipped():
# def matchFrames(slotID, data):
# def matchComplete():
# def playerFailed(slotID):
# def matchTransferHost():
# def matchAbort():
# def switchServer(address):
# def notification(message):
# def banchoRestart(msUntilReconnection):
# def rtx(message):
# 
# Path: constants/slotStatuses.py
# FREE = 1
# LOCKED = 2
# NOT_READY = 4
# READY = 8
# NO_MAP = 16
# PLAYING = 32
# OCCUPIED = 124
# PLAYING_QUIT = 128
# 
# Path: helpers/chatHelper.py
# def joinChannel(userID = 0, channel = "", token = None, toIRC = True, force=False):
# def partChannel(userID = 0, channel = "", token = None, toIRC = True, kick = False, force=False):
# def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
# def fixUsernameForBancho(username):
# def fixUsernameForIRC(username):
# def IRCConnect(username):
# def IRCDisconnect(username):
# def IRCJoinChannel(username, channel):
# def IRCPartChannel(username, channel):
# def IRCAway(username, message):
# 
# Path: objects/glob.py
# 		VERSION = f.read().strip()
# 	VERSION = "Unknown"
# DATADOG_PREFIX = "peppy"


# Path: objects/match.py
import copy
import json
import threading
import time
from common.log import logUtils as log
from constants import dataTypes
from constants import matchModModes
from constants import matchScoringTypes
from constants import matchTeamTypes
from constants import matchTeams
from constants import serverPackets
from constants import slotStatuses
from helpers import chatHelper as chat
from objects import glob

		self.score = 0
		self.failed = False
		self.passed = True

class match:
	def __init__(self, matchID, matchName, matchPassword, beatmapID, beatmapName, beatmapMD5, gameMode, hostUserID, isTourney=False):
		"""
		Create a new match object

		:param matchID: match progressive identifier
		:param matchName: match name, string
		:param matchPassword: match md5 password. Leave empty for no password
		:param beatmapID: beatmap ID
		:param beatmapName: beatmap name, string
		:param beatmapMD5: beatmap md5 hash, string
		:param gameMode: game mode ID. See gameModes.py
		:param hostUserID: user id of the host
		"""
		self.matchID = matchID
		self.streamName = "multi/{}".format(self.matchID)
		self.playingStreamName = "{}/playing".format(self.streamName)
		self.inProgress = False
		self.mods = 0
		self.matchName = matchName
		self.matchPassword = matchPassword
		self.beatmapID = beatmapID
		self.beatmapName = beatmapName
		self.beatmapMD5 = beatmapMD5
		self.hostUserID = hostUserID
		self.gameMode = gameMode

		self.matchScoringType = matchScoringTypes.SCORE	# default values