Add !mp abort, fix match not being set as in progress when starting it

This commit is contained in:
Giuseppe Guerra
2017-08-07 21:38:18 +02:00
parent 3653447761
commit 5adc7f4261
4 changed files with 35 additions and 9 deletions

View File

@@ -396,13 +396,7 @@ class match:
self.inProgress = False
# Reset slots
for i in range(0,16):
if self.slots[i].user is not None and self.slots[i].status == slotStatuses.PLAYING:
self.slots[i].status = slotStatuses.NOT_READY
self.slots[i].loaded = False
self.slots[i].skip = False
self.slots[i].complete = False
self.slots[i].score = 0
self.resetSlotsReady()
# Send match update
self.sendUpdates()
@@ -417,6 +411,15 @@ class match:
# Console output
log.info("MPROOM{}: Match completed".format(self.matchID))
def resetSlotsReady(self):
for i in range(0,16):
if self.slots[i].user is not None and self.slots[i].status == slotStatuses.PLAYING:
self.slots[i].status = slotStatuses.NOT_READY
self.slots[i].loaded = False
self.slots[i].skip = False
self.slots[i].complete = False
self.slots[i].score = 0
def getUserSlotID(self, userID):
"""
Get slot ID occupied by userID
@@ -726,7 +729,7 @@ class match:
glob.streams.add(self.playingStreamName)
# Change inProgress value
match.inProgress = True
self.inProgress = True
# Set playing to ready players and set load, skip and complete to False
# Make clients join playing stream
@@ -752,3 +755,16 @@ class match:
for i in range(matchSize, 16):
if self.slots[i].status != slotStatuses.LOCKED:
self.toggleSlotLocked(i)
def abort(self):
if not self.inProgress:
log.warning("MPROOM{}: Match is not in progress!".format(self.matchID))
return
self.inProgress = False
self.isStarting = False
self.resetSlotsReady()
self.sendUpdates()
glob.streams.broadcast(self.playingStreamName, serverPackets.matchAbort())
glob.streams.dispose(self.playingStreamName)
glob.streams.remove(self.playingStreamName)
log.info("MPROOM{}: Match aborted".format(self.matchID))