Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from mtgsdk import Set
- from mtgsdk import Card
- from mtgsdk import Supertype
- def main():
- # change parameters to refine serach - leave '' to filter by all
- name = ''
- colors = 'Green' # pipe is or
- card_type = 'Creature' # enchantment, sorcery, creature, etc.
- super_types = ''
- sub_types = 'Worm'
- #cmc = '1.0,2.0,3.0'
- text = '' # contains this keyword?
- # if you want to output query to a file - change file name when you run a new query
- file_path = 'G:\Documents\MTG\API Queries\_testRedCreatures.txt'
- # query for the
- cards = Card.where(name=name).where(colors=colors).where(type=card_type).where(superTypes=super_types).where(subtypes=sub_types).all()
- results = 1
- # write the parameters used at the top of the file
- # edit when you run a new query
- # JANKY AF BUT I CAN'T THINK OF ANOTHER WAY
- with open(file_path, "a") as myfile:
- myfile.write("-----Parameters used-----")
- myfile.write("\n")
- myfile.write("name: ")
- myfile.write(name)
- myfile.write("\n")
- myfile.write("colors: ")
- myfile.write(colors)
- myfile.write("\n")
- myfile.write("card_type: ")
- myfile.write(card_type)
- myfile.write("\n")
- myfile.write("super_types: ")
- myfile.write(super_types)
- myfile.write("\n")
- myfile.write("sub_types: ")
- myfile.write(sub_types)
- myfile.write("\n")
- myfile.write("-----End Parameters-----")
- myfile.write("\n")
- myfile.write("\n")
- # loop through the cards and print out details
- for card in cards:
- print("Result #: ", results)
- card_info = ("Name: {}\n"
- "Layout: {}\n"
- "Converted Mana Cost: {}\n"
- "Colors: {}\n"
- "Types: {}\n"
- "SuperType: {}\n"
- "SubType: {}\n"
- "Rarity: {}\n"
- "Power: {}\n"
- "Toughness: {}\n"
- "Card Text: {}\n"
- ).format(card.name,
- card.layout,
- card.cmc,
- card.colors,
- card.type,
- card.supertypes,
- card.subtypes,
- card.rarity,
- card.power,
- card.toughness,
- card.text)
- print(card_info, "\n")
- # write query results out to a txt file
- with open(file_path, "a") as myfile:
- myfile.write("Result #: ")
- myfile.write(str(results)) # cast int as string
- myfile.write("\n")
- myfile.write(card_info)
- myfile.write("\n")
- results = results + 1
- myfile.close()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement