Exemplo n.º 1
0
	def sendUpdate(self):
		# Send to users in room
		for i in range(0,16):
			if self.slots[i]["userID"] > -1:
				token = glob.tokens.getTokenFromUserID(self.slots[i]["userID"])
				if token != None:
					token.enqueue(serverPackets.updateMatch(self.matchID))

		# Send to users in lobby
		for i in glob.matches.usersInLobby:
			token = glob.tokens.getTokenFromUserID(i)
			if token != None:
				token.enqueue(serverPackets.updateMatch(self.matchID))
Exemplo n.º 2
0
    def sendUpdate(self):
        # Send to users in room
        for i in range(0, 16):
            if self.slots[i]["userID"] > -1:
                token = glob.tokens.getTokenFromUserID(self.slots[i]["userID"])
                if token != None:
                    token.enqueue(serverPackets.updateMatch(self.matchID))

        # Send to users in lobby
        for i in glob.matches.usersInLobby:
            token = glob.tokens.getTokenFromUserID(i)
            if token != None:
                token.enqueue(serverPackets.updateMatch(self.matchID))
Exemplo n.º 3
0
	def toggleSlotLock(self, slotID):
		"""
		Lock a slot
		Same as calling setSlot and then sendUpdate

		slotID -- slot number
		"""
		# Get token of user in that slot (if there's someone)
		if self.slots[slotID]["userID"] > -1:
			token = glob.tokens.getTokenFromUserID(self.slots[slotID]["userID"])
		else:
			token = None

		# Check if slot is already locked
		if self.slots[slotID]["status"] == slotStatuses.locked:
			newStatus = slotStatuses.free
		else:
			newStatus = slotStatuses.locked

		# Set new slot status
		self.setSlot(slotID, newStatus, 0, -1, 0)
		if token != None:
			# Send updated settings to kicked user, so he returns to lobby
			token.enqueue(serverPackets.updateMatch(self.matchID))

		# Send updates to everyone else
		self.sendUpdate()
		consoleHelper.printColored("> MPROOM{}: Slot{} {}".format(self.matchID, slotID, "locked" if newStatus == slotStatuses.locked else "unlocked"), bcolors.BLUE)
Exemplo n.º 4
0
    def toggleSlotLock(self, slotID):
        """
		Lock a slot
		Same as calling setSlot and then sendUpdate

		slotID -- slot number
		"""
        # Get token of user in that slot (if there's someone)
        if self.slots[slotID]["userID"] > -1:
            token = glob.tokens.getTokenFromUserID(
                self.slots[slotID]["userID"])
        else:
            token = None

        # Check if slot is already locked
        if self.slots[slotID]["status"] == slotStatuses.locked:
            newStatus = slotStatuses.free
        else:
            newStatus = slotStatuses.locked

        # Set new slot status
        self.setSlot(slotID, newStatus, 0, -1, 0)
        if token != None:
            # Send updated settings to kicked user, so he returns to lobby
            token.enqueue(serverPackets.updateMatch(self.matchID))

        # Send updates to everyone else
        self.sendUpdate()
        consoleHelper.printColored(
            "> MPROOM{}: Slot{} {}".format(
                self.matchID, slotID,
                "locked" if newStatus == slotStatuses.locked else "unlocked"),
            bcolors.BLUE)