Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
def getPlayerFromQueue(player: str) -> Union[BallChaser, None]:
    return currQueue.get(doc_id=int(player))
Ejemplo n.º 5
0
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"])