def get_deck(self, decks_source): print('Processing "%s" deck' % decks_source['name']) payload = {"slug": decks_source['slug']} res = requests.post('https://tempostorm.com/deck', data=json.dumps(payload), headers={ 'Accept': 'application/json, text/plain, */*', 'Content-Type': 'application/json;charset=utf-8', }) deck_object = Deck() deck = res.json()['deck'] player_class = deck['playerClass'] cards = {} for card in deck['cards']: cards[my_collection.get_closest_name(card['card']['name'])] = card['qty'] deck_object.cards = cards deck_object.player_class = player_class deck_object.is_valid() return deck_object
def get_deck(self, decks_source): print('Processing "%s" deck' % decks_source['name']) payload = {"slug": decks_source['slug']} res = requests.post('https://tempostorm.com/deck', data=json.dumps(payload), headers={ 'Accept': 'application/json, text/plain, */*', 'Content-Type': 'application/json;charset=utf-8', }) deck_object = Deck() deck = res.json()['deck'] player_class = deck['playerClass'] cards = {} for card in deck['cards']: cards[my_collection.get_closest_name( card['card']['name'])] = card['qty'] deck_object.cards = cards deck_object.player_class = player_class deck_object.is_valid() return deck_object
from dataobjects import constants my_col_object = Collection() my_col_object.cards = my_col # m = Mask() # m.forbid_all() # m.allow_rarity('Free') # m.allow_rarity('Common') # my_col_object.apply_mask(m) player_class = raw_input('Input your class: ') start_card = my_col_object.get_closest_name(raw_input('First card in deck? ')) is_arena_deck = raw_input('Type y if it is arena deck') == 'y' deck = Deck(my_col=my_col_object.cards) deck.add_card(start_card) deck.player_class = player_class if is_arena_deck: deck.type = constants.ARENA_DECK while sum(deck.cards.values()) < 30: next_card, card_syn_value, better_cards = deck.get_advice() print 'Adding %s : %f (skipped missing cards: %s)' % ( next_card, card_syn_value, str(better_cards)) deck.add_card(next_card) if raw_input("Refine? (y/n)") == 'y': deck.refine_deck() print('Final deck:')
from dataobjects import constants my_col_object = Collection() my_col_object.cards = my_col # m = Mask() # m.forbid_all() # m.allow_rarity('Free') # m.allow_rarity('Common') # my_col_object.apply_mask(m) player_class = raw_input('Input your class: ') start_card = my_col_object.get_closest_name(raw_input('First card in deck? ')) is_arena_deck = raw_input('Type y if it is arena deck') == 'y' deck = Deck(my_col=my_col_object.cards) deck.add_card(start_card) deck.player_class = player_class if is_arena_deck: deck.type = constants.ARENA_DECK while sum(deck.cards.values()) < 30: next_card, card_syn_value, better_cards = deck.get_advice() print 'Adding %s : %f (skipped missing cards: %s)' % (next_card, card_syn_value, str(better_cards)) deck.add_card(next_card) if raw_input("Refine? (y/n)") == 'y': deck.refine_deck() print('Final deck:') for card in deck.cards: