diff --git a/constants/fokabotCommands.py b/constants/fokabotCommands.py index e8d4064..65e97e0 100644 --- a/constants/fokabotCommands.py +++ b/constants/fokabotCommands.py @@ -9,7 +9,7 @@ from common import generalUtils from common.constants import mods from common.log import logUtils as log from common.ripple import userUtils -from constants import exceptions +from constants import exceptions, slotStatuses from common.constants import gameModes from common.constants import privileges from constants import serverPackets @@ -777,7 +777,7 @@ def multiplayer(fro, chan, message): def mpJoin(): if len(message) < 2 or not message[1].isdigit(): - return exceptions.invalidArgumentsException("Wrong syntax: !mp join ") + raise exceptions.invalidArgumentsException("Wrong syntax: !mp join ") matchID = int(message[1]) userToken = glob.tokens.getTokenFromUsername(fro, ignoreIRC=True) userToken.joinMatch(matchID) @@ -800,13 +800,27 @@ def multiplayer(fro, chan, message): glob.matches.matches[matchID].isLocked = False return "This match has been unlocked" + def mpSize(): + if len(message) < 2 or not message[1].isdigit() or int(message[1]) < 1 or int(message[1]) > 16: + raise exceptions.invalidArgumentsException("Wrong syntax: !mp size ") + matchSize = int(message[1]) + _match = glob.matches.matches[getMatchIDFromChannel(chan)] + for i in range(0, matchSize): + if _match.slots[i].status == slotStatuses.LOCKED: + _match.toggleSlotLocked(i) + for i in range(matchSize, 16): + if _match.slots[i].status != slotStatuses.LOCKED: + _match.toggleSlotLocked(i) + return "Match size changed to {}".format(matchSize) + try: subcommands = { "make": mpMake, "clear": mpClose, "join": mpJoin, "lock": mpLock, - "unlock": mpUnlock + "unlock": mpUnlock, + "size": mpSize, } requestedSubcommand = message[0].lower().strip() if requestedSubcommand not in subcommands: diff --git a/events/matchLockEvent.py b/events/matchLockEvent.py index 5959e35..553db86 100644 --- a/events/matchLockEvent.py +++ b/events/matchLockEvent.py @@ -24,4 +24,4 @@ def handle(userToken, packetData): return # Lock/Unlock slot - match.toggleSlotLock(packetData["slotID"]) + match.toggleSlotLocked(packetData["slotID"]) diff --git a/objects/match.py b/objects/match.py index 73285d3..5fe4647 100644 --- a/objects/match.py +++ b/objects/match.py @@ -215,7 +215,7 @@ class match: self.sendUpdates() log.info("MPROOM{}: Slot{} changed ready status to {}".format(self.matchID, slotID, self.slots[slotID].status)) - def toggleSlotLock(self, slotID): + def toggleSlotLocked(self, slotID): """ Lock a slot Same as calling setSlot and then sendUpdate