Exemplo n.º 1
0
    def findCombos(self, chars, threshold, search="ITEMS"):
        if search == "ITEMS":
            card1, card2, check, against = 'card1', 'card2', "items", "characters"
        else:  # search characters based on items
            card1, card2, check, against = 'card2', 'card1', "characters", "items"

        combos = self.api.getCombos()
        cards = self.api.getCards()

        mix_tot = 0
        items = []

        # use first character to create list of items
        for combo in combos.findall('combo'):
            the_card = combo.find('cards')
            if the_card.get(card2) == "" or the_card.get(card1) == "":
                continue
            item = int(the_card.get(card2))
            if int(the_card.get(card1)) == chars[0].id:
                items.append(the_card.get(card2))

        # print("Items to test")
        # print(items)

        # check if list of items is compatible with other characters, if no, delete
        for i in range(1, len(chars)):
            # print('Looking for {0} that mix with your {1}... {2}%'.format(check, against, float(
            #     int(float(i) / float(len(chars)) * 10000)) / 100))
            j = 0
            while j < len(items):
                success = 0

                for combo in combos.findall('combo'):
                    the_card = combo.find('cards')
                    if the_card.get(card2) == "" or the_card.get(card1) == "":
                        continue

                    if int(
                            the_card.get(card1)
                    ) == chars[i].id and the_card.get(card2) == items[j]:
                        success = 1
                        break

                if not success:
                    del items[j]
                else:
                    j += 1

        if len(items):
            item_deck = Deck()
            item_deck.addListOfIds(items)
            item_deck.updateDeckFromXML()
        else:
            item_deck = None

        return item_deck
Exemplo n.º 2
0
    def createImageFromList(self, name="default", card_ids=[], width=5):
        full_list = []

        for i in range(len(card_ids)):
            full_list.extend(card_ids[i])

        deck = Deck(name=name)
        deck.addListOfIds(full_list)
        deck.updateDeckFromXML()
        filepath = deck.createLargeDeckImage(name, width=width)

        return deck, filepath