Beispiel #1
0
    def updateAsInventory(self, context):
        self.cards = []

        if context.update:
            json = self.api.updateAndGetInitFile(context)
        else:
            json = self.api.getInit(context)

        card_map = json['user_units']
        self.name = json['user_data']['name'] + "_inventory"

        # print('[Deck] inventory for ', self.name)

        for card in card_map:
            card_to_add = Card()
            card_to_add.id = int(card_map[card]['unit_id'])
            card_to_add.level = int(card_map[card]['level'])
            print('[Deck] Adding card - id: {0}, level: {1}'.format(
                card_to_add.id, card_to_add.level))
            self.cards.append(card_to_add)

        self.updateDeckFromXML()

        print('[Deck] update as inventory - returning')
        return self.cards
Beispiel #2
0
    def getDeckFromCardMap(self, cardMap, lower, upper):
        self.cards = []
        order = []

        # Get index values of array
        for card in cardMap:
            card_index = int(card)
            if lower <= card_index <= upper:
                order.append(card_index)

        order.sort()

        for index in range(len(order)):
            for card in cardMap:
                if int(card) == order[index]:
                    card_to_add = Card()
                    card_to_add.id = int(cardMap[card]['unit_id'])
                    card_to_add.level = int(cardMap[card]['level'])
                    self.cards.append(card_to_add)