Add !mp start force, start game even for non-ready players, check if everyone is ready in !mp start

This commit is contained in:
Giuseppe Guerra 2017-08-11 00:57:58 +02:00
parent 466004f239
commit 612e808702
2 changed files with 11 additions and 2 deletions

View File

@ -840,6 +840,7 @@ def multiplayer(fro, chan, message):
def mpClearHost():
matchID = getMatchIDFromChannel(chan)
glob.matches.matches[matchID].removeHost()
return "Host has been removed from this match"
def mpStart():
def _start():
@ -865,12 +866,20 @@ def multiplayer(fro, chan, message):
else:
startTime = int(message[1])
force = False if len(message) < 3 else message[2].lower() == "force"
_match = glob.matches.matches[getMatchIDFromChannel(chan)]
# Force everyone to ready
someoneNotReady = False
for i, slot in enumerate(_match.slots):
if slot.status != slotStatuses.READY and slot.user is not None:
_match.toggleSlotReady(i)
someoneNotReady = True
if force:
_match.toggleSlotReady(i)
if someoneNotReady and not force:
return "Some users aren't ready yet. Use '!mp start force' if you want to start the match, " \
"even with non-ready players."
if startTime == 0:
_start()

View File

@ -739,7 +739,7 @@ class match:
# Set playing to ready players and set load, skip and complete to False
# Make clients join playing stream
for i in range(0, 16):
if (self.slots[i].status & slotStatuses.READY) > 0 and self.slots[i].user in glob.tokens.tokens:
if self.slots[i].user in glob.tokens.tokens:
self.slots[i].status = slotStatuses.PLAYING
self.slots[i].loaded = False
self.slots[i].skip = False