Exemplo n.º 1
0
def getCommander(driver, commander, threshold):
    print(commander)
    commanderHtml = getCommanderHtml(driver, commander)
    soup = BeautifulSoup(commanderHtml, 'html.parser')

    cardsDivs = soup.findAll("div", attrs={"class": "cardlist"})
    cardContainers = []
    for cardsDiv in cardsDivs:
        divs = cardsDiv.findAll("div", attrs={"class": "card__container"})
        for cardContainer in divs:
            cardContainers.append(cardContainer)

    cards = []
    for cardContainer in cardContainers:
        cardNameDiv = cardContainer.find("div", attrs={"class": "card__name"})
        cardName = cardNameDiv.text
        cardLabelDiv = cardContainer.find("div",
                                          attrs={"class": "card__label"})
        cardLabel = cardLabelDiv.text
        (percent, synergy) = re.findall(r"([-]?\d+)%", cardLabel)

        if (int(percent) > threshold):
            cardName = CardUtil.standardizeCardName(cardName)
            card = Card(cardName, int(percent), int(synergy))
            cards.append(card)

    return cards
Exemplo n.º 2
0
def getCardData(filePath):
    file = open(filePath, "r")
    cards = json.load(file)
    file.close()

    data = cards["data"]
    allCardNames = set(data.keys())
    for cardName in allCardNames:
        standardCardName = CardUtil.standardizeCardName(cardName)
        if (cardName != standardCardName):
            data[standardCardName] = data[cardName]
            del data[cardName]

    return data
Exemplo n.º 3
0
def getColorIdentity(cardName):
    cardName = CardUtil.standardizeCardName(cardName)
    cards = cardData[cardName]
    atomicCard = cards[0]
    colorIdentity = atomicCard["colorIdentity"]
    types = atomicCard["types"]
    if "Land" in types:
        return "Land"
    elif (len(colorIdentity) == 0):
        return "Colorless"
    elif (len(colorIdentity) == 1):
        return colorIdentity[0]
    else:
        return "Multi"