Add !mp make and !mp join

This commit is contained in:
Giuseppe Guerra
2017-08-02 00:22:57 +02:00
parent 3373bc9581
commit af554c94d5
4 changed files with 20 additions and 9 deletions

View File

@@ -25,7 +25,7 @@ class slot:
self.score = 0
class match:
def __init__(self, matchID, matchName, matchPassword, beatmapID, beatmapName, beatmapMD5, gameMode, hostUserID):
def __init__(self, matchID, matchName, matchPassword, beatmapID, beatmapName, beatmapMD5, gameMode, hostUserID, isTourney=False):
"""
Create a new match object
@@ -55,6 +55,7 @@ class match:
self.matchModMode = matchModModes.NORMAL # default value
self.seed = 0
self.matchDataCache = bytes()
self.isTourney = isTourney
# Create all slots and reset them
self.slots = []
@@ -67,6 +68,7 @@ class match:
# Create #multiplayer channel
glob.channels.addTempChannel("#multi_{}".format(self.matchID))
log.info("MPROOM{}: {} match created!".format(self.matchID, "Tourney" if self.isTourney else "Normal"))
def getMatchData(self, censored = False):
"""
@@ -457,7 +459,7 @@ class match:
self.setSlot(slotID, slotStatuses.FREE, 0, None, 0)
# Check if everyone left
if self.countUsers() == 0 and disposeMatch:
if self.countUsers() == 0 and disposeMatch and not self.isTourney:
# Dispose match
glob.matches.disposeMatch(self.matchID)
log.info("MPROOM{}: Room disposed because all users left".format(self.matchID))

View File

@@ -9,7 +9,7 @@ class matchList:
self.matches = {}
self.lastID = 1
def createMatch(self, matchName, matchPassword, beatmapID, beatmapName, beatmapMD5, gameMode, hostUserID):
def createMatch(self, matchName, matchPassword, beatmapID, beatmapName, beatmapMD5, gameMode, hostUserID, isTourney=False):
"""
Add a new match to matches list
@@ -25,7 +25,7 @@ class matchList:
# Add a new match to matches list and create its stream
matchID = self.lastID
self.lastID+=1
self.matches[matchID] = match.match(matchID, matchName, matchPassword, beatmapID, beatmapName, beatmapMD5, gameMode, hostUserID)
self.matches[matchID] = match.match(matchID, matchName, matchPassword, beatmapID, beatmapName, beatmapMD5, gameMode, hostUserID, isTourney)
return matchID
def disposeMatch(self, matchID):