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(): def mpClearHost():
matchID = getMatchIDFromChannel(chan) matchID = getMatchIDFromChannel(chan)
glob.matches.matches[matchID].removeHost() glob.matches.matches[matchID].removeHost()
return "Host has been removed from this match"
def mpStart(): def mpStart():
def _start(): def _start():
@ -865,13 +866,21 @@ def multiplayer(fro, chan, message):
else: else:
startTime = int(message[1]) startTime = int(message[1])
force = False if len(message) < 3 else message[2].lower() == "force"
_match = glob.matches.matches[getMatchIDFromChannel(chan)] _match = glob.matches.matches[getMatchIDFromChannel(chan)]
# Force everyone to ready # Force everyone to ready
someoneNotReady = False
for i, slot in enumerate(_match.slots): for i, slot in enumerate(_match.slots):
if slot.status != slotStatuses.READY and slot.user is not None: if slot.status != slotStatuses.READY and slot.user is not None:
someoneNotReady = True
if force:
_match.toggleSlotReady(i) _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: if startTime == 0:
_start() _start()
return "Starting match" return "Starting match"

View File

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