def captainsPop() -> Tuple[BallChaser, BallChaser]: if (not queueAlreadyPopped()): sorted_MMRList = sorted(currQueue.all(), key=lambda x: (x[BallChaserKey.MMR]), reverse=True) top2 = sorted_MMRList[0:2] random.shuffle(top2) orangeCapDoc = top2[0] orangeCap = BallChaser.fromDocument(orangeCapDoc) currQueue.update( { BallChaserKey.IS_CAP: True, BallChaserKey.TEAM: Team.ORANGE }, doc_ids=[orangeCapDoc.doc_id]) blueCapDoc = top2[1] blueCap = BallChaser.fromDocument(blueCapDoc) currQueue.update( { BallChaserKey.IS_CAP: True, BallChaserKey.TEAM: Team.BLUE }, doc_ids=[blueCapDoc.doc_id]) else: orangeCap = BallChaser.fromDocument( currQueue.get((where(BallChaserKey.TEAM) == Team.ORANGE) & (where(BallChaserKey.IS_CAP) == True))) blueCap = BallChaser.fromDocument( currQueue.get((where(BallChaserKey.TEAM) == Team.BLUE) & (where(BallChaserKey.IS_CAP) == True))) return blueCap, orangeCap
def getCaptains() -> Union[Tuple[BallChaser, BallChaser], Tuple[None, None]]: if (queueAlreadyPopped()): orangeCap = BallChaser.fromDocument( currQueue.get((where(BallChaserKey.TEAM) == Team.ORANGE) & (where(BallChaserKey.IS_CAP) == True))) blueCap = BallChaser.fromDocument( currQueue.get((where(BallChaserKey.TEAM) == Team.BLUE) & (where(BallChaserKey.IS_CAP) == True))) return blueCap, orangeCap else: return None, None
def getQueueList(mentionPlayers: bool = False, includeTimes: bool = True, separator: str = "\n", includeLetters=False) -> str: # noqa playerList = [] letters = [ "1️⃣", "2️⃣", "3️⃣", "4️⃣", ] i = 0 for player in currQueue.search(where(BallChaserKey.TEAM) == None): player = BallChaser.fromDocument(player) if (mentionPlayers): playerList.append(player.mention) else: player_name = player.name.split("#")[0] if (includeTimes): minutes_diff = getQueueTimeRemaining(player) player_name += " (" + str(minutes_diff) + " mins)" if (includeLetters): player_name = letters[i] + " (" + str( Leaderboard.getPlayerMMR(player)) + ") " + player_name playerList.append(player_name) i += 1 return separator.join(playerList)
def checkQueueTimes() -> Tuple[List[BallChaser], List[BallChaser]]: warn_players = [] remove_players = [] for player in currQueue.all(): player = BallChaser.fromDocument(player) minutes_diff = getQueueTimeRemaining(player) if (minutes_diff == 5): # 5 minute warning warn_players.append(player) elif (minutes_diff > 60): # There is no negative time, it just overflows to like 1430 removeFromQueue(player) remove_players.append(player) return warn_players, remove_players
def randomPop() -> Tuple[List[BallChaser], List[BallChaser]]: players = [BallChaser.fromDocument(p) for p in currQueue.all()] orangeTeam = random.sample(players, 3) for player in orangeTeam: player.team = Team.ORANGE players.remove(player) blueTeam = players[:] currQueue.truncate() for player in blueTeam: player.team = Team.BLUE return blueTeam, orangeTeam
def getTeamList() -> Tuple[List[BallChaser], List[BallChaser]]: orangeTeam = currQueue.search(where(BallChaserKey.TEAM) == Team.ORANGE) blueTeam = currQueue.search(where(BallChaserKey.TEAM) == Team.BLUE) return [BallChaser.fromDocument(p) for p in blueTeam ], [BallChaser.fromDocument(p) for p in orangeTeam]
def getAvailablePicks() -> List[BallChaser]: availablePicks = [] for player in currQueue.search(where(BallChaserKey.TEAM) == None): availablePicks.append(BallChaser.fromDocument(player)) return availablePicks