diff --git a/constants/fokabotCommands.py b/constants/fokabotCommands.py index 2e2f360..b9a52c5 100644 --- a/constants/fokabotCommands.py +++ b/constants/fokabotCommands.py @@ -10,7 +10,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, slotStatuses, matchModModes +from constants import exceptions, slotStatuses, matchModModes, matchTeams from common.constants import gameModes from common.constants import privileges from constants import serverPackets @@ -994,6 +994,22 @@ def multiplayer(fro, chan, message): _match.matchModMode = matchModModes.FREE_MOD if freeMod else matchModModes.NORMAL _match.changeMods(newMods) + return "Match mods have been updated!" + + def mpTeam(): + if len(message) < 3: + raise exceptions.invalidArgumentsException("Wrong syntax: !mp team ") + username = message[1] + colour = message[2].lower().strip() + if colour not in ["red", "blue"]: + raise exceptions.invalidArgumentsException("Team colour must be red or blue") + userID = userUtils.getIDSafe(username) + if userID is None: + raise exceptions.userNotFoundException("No such user") + _match = glob.matches.matches[getMatchIDFromChannel(chan)] + _match.changeTeam(userID, matchTeams.BLUE if colour == "blue" else matchTeams.RED) + return "{} is now in {} team".format(username, colour) + try: subcommands = { @@ -1015,6 +1031,7 @@ def multiplayer(fro, chan, message): "password": mpPassword, "randompassword": mpRandomPassword, "mods": mpMods, + "team": mpTeam, } requestedSubcommand = message[0].lower().strip() if requestedSubcommand not in subcommands: diff --git a/objects/match.py b/objects/match.py index 1b98c9a..de0027c 100644 --- a/objects/match.py +++ b/objects/match.py @@ -652,13 +652,17 @@ class match: c+=1 return c - def changeTeam(self, userID): + def changeTeam(self, userID, newTeam=None): """ Change userID's team :param userID: id of user :return: """ + # Make sure this match's mode has teams + if self.matchTeamType != matchTeamTypes.TEAM_VS or self.matchTeamType != matchTeamTypes.TAG_TEAM_VS: + return + # Make sure the match is not locked if self.isLocked or self.isStarting: return @@ -669,7 +673,8 @@ class match: return # Update slot and send update - newTeam = matchTeams.BLUE if self.slots[slotID].team == matchTeams.RED else matchTeams.RED + if newTeam is None: + newTeam = matchTeams.BLUE if self.slots[slotID].team == matchTeams.RED else matchTeams.RED self.setSlot(slotID, None, newTeam) self.sendUpdates()