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 validateBluePick(player: Member) -> bool: player = currQueue.get(doc_id=player.id) if (player is not None): return (currQueue.count(where(BallChaserKey.TEAM) == Team.BLUE) == 1 and player[BallChaserKey.IS_CAP] and player[BallChaserKey.TEAM] == Team.BLUE)
def getPlayerFromQueue(player: str) -> Union[BallChaser, None]: return currQueue.get(doc_id=int(player))
def isPlayerInQueue(player: Union[Member, str]) -> bool: if (isinstance(player, Member)): return currQueue.contains(where(BallChaserKey.ID) == player.id) elif (isinstance(player, str)): return currQueue.contains( where(BallChaserKey.ID) == currQueue.get(doc_id=int(player))["id"])