def process_deck (deck): old_deck = Deck.from_database(deck_find_by_id(deck.id)) if old_deck is not None and deck.time_update == old_deck.time_update: deck.dust_cost = old_deck.dust_cost deck.cards = old_deck.cards status = 'Pass' else: parse_deck(deck) status = 'Update' if old_deck is not None else 'New' if not deck.is_valid(): status += ', Invalid' return status
def show_deck (deck, cost_total, card_hand, card_forge, card_soul): print '%s (by %s)' % (deck.name, deck.author) print 'Rating: %d, Type: %s, Updated: %s' % (deck.rating, deck.type, time.strftime('%Y-%m-%d %H:%M:%S', deck.time_update)) if card_hand: print 'Cards already in your collection:' print '\n'.join([' %s x %d' % (card.colored_name(), count) for (card, count) in card_hand]) if card_forge: print 'Cards can be forged:' print '\n'.join([' %s x %d' % (card.colored_name(), count) for (card, count) in card_forge]) print ' Total Arcane Dust: %d' % cost_total if card_soul: print 'Cards can not be forged (Soulbound):' print '\n'.join([' %s x %d' % (card.colored_name(), count) for (card, count) in card_soul]) print if __name__ == '__main__': (database_name, collection_name, hero_class, dust_amount) = parse_arg((str, str, str, int), 3) if dust_amount is None: dust_amount = 0 load_card_collection(collection_name) database_connect(database_name) for row in deck_select_by_class(hero_class): deck = Deck.from_database(row) if deck.is_valid(): (card_hand, card_forge, card_soul, cost_total) = split_card(deck) if not card_soul and cost_total <= dust_amount or dust_amount == -1: show_deck(deck, cost_total, card_hand, card_forge, card_soul) if raw_input('Press Enter to continue. Input (X) and enter to exit.\n').upper() == 'X': break database_close()