Scrython/scrython/cards/cards_object.py

451 lines
15 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import sys
sys.path.append('..')
from scrython.foundation import FoundationObject
import aiohttp
import asyncio
import urllib.parse
from threading import Thread
class CardsObject(FoundationObject):
"""
Master class that all card objects inherit from.
Positional arguments:
No positional arguments are required.
Optional arguments:
format : str ... Returns data in the specified method. Defaults to JSON.
face : str ... If you're using the `image` format, this will specify if
you want the front or back face.
version : str ... If you're using the `image` format, this will specify if
you want the small, normal, large, etc version of the image.
pretty : str ... Returns a prettier version of the json object. Note that
this may break functionality with Scrython.
Attributes:
type_line : str ....................... The full type line of the card.
oracle_text : str ................. The official oracle text of a card.
mana_cost : str .... The full mana cost using shorthanded mana symbols.
colors : list ... An array of strings with all colors found in the mana cost.
color_identity : list ... An array of strings with all colors found on the card itself.
legalities : dict ..... A dictionary of all formats and their legality.
reserved : bool ..... Returns True if the card is on the reserved list.
reprint : bool .... Returns True if the card has been reprinted before.
set_code : str ............. The 3 letter code for the set of the card.
set_name : str ................. The full name for the set of the card.
set_uri : str .......... The API uri for the full set list of the card.
set_search_uri : str .......................... Same output as set_uri.
scryfall_set_uri : str .......... The full link to the set on Scryfall.
rulings_uri : str ............ The API uri for the rulings of the card.
prints_search_uri : str ... A link to where you can begin paginating all re/prints for this card on Scryfalls API.
collector_number : str .............. The collector number of the card.
digital : bool ....... Returns True if the card is the digital version.
rarity : str .................................. The rarity of the card.
illuStringation_id : str .............. The related id of the card art.
artist : str .................................. The artist of the card.
frame : str ............................... The year of the card frame.
full_art : bool ...... Returns True if the card is considered full art.
border_color : str ...................... The color of the card border.
timeshifted : bool ........... Returns True if the card is timeshifted.
colorshifted : bool ......... Returns True if the card is colorshifted.
futureshifted : bool ....... Returns True if the card is futureshifted.
edhrec_rank : int .................. The rank of the card on edhrec.com
currency("<mode>")` : str ... Returns currency from modes `usd`, `eur`, and `tix`.
related_uris : dict ... A dictionary of related websites for this card.
purchase_uris : dict ...... A dictionary of links to purchase the card.
life_modifier : str ... This is the cards life modifier value, assuming it's a Vanguard card.
hand_modifier : str ... This cards hand modifier value, assuming it's a Vanguard card.
color_indicator : list ... An array of all colors found in this card's color indicator.
all_parts : list ... This this card is closely related to other cards, this property will be an array with it.
card_faces : list ... If it exists, all parts found on a card's face will be found as an object from this array.
watermark : str ......... The associated watermark of the card, if any.
story_spotlight : bool .... True if this card is featured in the story.
power : str ................. The power of the creature, if applicable.
toughness : str ......... The toughness of the creature, if applicable.
flavor_text : str ................ The flavor text of the card, if any.
arena_id : int ...................... The Arena ID of the card, if any.
lang : str ... The language of the card.
printed_name : str .. If the card is in a non-English language, this will be the name as it appears on the card.
printed_type_line : str .. If the card is in a non-English language, this will be the type line as it appears on the card.
printed_text : str ... If the card is in a non-English language, this will be the rules text as it appears on the card.
oracle_id : str .............. A unique ID for this card's oracle text.
foil : bool ........... True if this printing exists in a foil version.
loyalty : str .... This card's loyalty. Some loyalties may be X rather than a number.
non_foil : bool ......... True if this printing does not exist in foil.
oversized : bool .......... True if this printing is an oversized card.
"""
def object(self):
"""Returns the type of object it is
(card, error, etc)
Returns:
string: The type of object
"""
super(CardsObject, self)._checkForKey('object')
return self.scryfallJson['object']
def id(self):
"""A unique ID for the returned card object
Returns:
string: The scryfall id of the card
"""
super(CardsObject, self)._checkForKey('id')
return self.scryfallJson['id']
def multiverse_ids(self):
"""The official Gatherer multiverse ids of the card
Returns:
list: The associated multiverse ids of the card
"""
super(CardsObject, self)._checkForKey('multiverse_ids')
return self.scryfallJson['multiverse_ids']
def mtgo_id(self):
"""The official MTGO id of the of the card
Returns:
integer: The Magic Online id of the card
"""
super(CardsObject, self)._checkForKey('mtgo_id')
return self.scryfallJson['mtgo_id']
def mtgo_foil_id(self):
"""The corresponding MTGO foil ID of the card
Returns:
integer: The Magic Online foil id of the card
"""
super(CardsObject, self)._checkForKey('mtgo_foil_id')
return self.scryfallJson['mtgo_foil_id']
def name(self):
"""The oracle name of the card
Returns:
string: The card name
"""
super(CardsObject, self)._checkForKey('name')
return self.scryfallJson['name']
def uri(self):
"""The Scryfall API uri for the card
Returns:
string: An API uri for the card
"""
super(CardsObject, self)._checkForKey('uri')
return self.scryfallJson['uri']
def scryfall_uri(self):
"""The full Scryfall page of the card
As if it was a URL from the site.
Returns:
string: The Scryfall URL for the card
"""
super(CardsObject, self)._checkForKey('scryfall_uri')
return self.scryfallJson['scryfall_uri']
def layout(self):
"""The image layout of the card. (normal, transform, etc)
Returns:
string: The card layout
"""
super(CardsObject, self)._checkForKey('layout')
return self.scryfallJson['layout']
def highres_image(self):
"""Determine if a card has a highres scan available
Returns:
boolean: True if card has a highres image available
"""
super(CardsObject, self)._checkForKey('highres_image')
return self.scryfallJson['highres_image']
def image_uris(self):
"""All image uris of the card in various qualities
Returns:
dict: The dictionary of image uris
"""
super(CardsObject, self)._checkForKey('image_uris')
return self.scryfallJson['image_uris']
def cmc(self):
"""A float of the converted mana cost of the card
Returns:
float: The cmc of the card
"""
super(CardsObject, self)._checkForKey('cmc')
return self.scryfallJson['cmc']
def type_line(self):
super(CardsObject, self)._checkForKey('type_line')
return self.scryfallJson['type_line']
def oracle_text(self):
super(CardsObject, self)._checkForKey('oracle_text')
return self.scryfallJson['oracle_text']
def mana_cost(self):
super(CardsObject, self)._checkForKey('mana_cost')
return self.scryfallJson['mana_cost']
def colors(self):
super(CardsObject, self)._checkForKey('colors')
return self.scryfallJson['colors']
def color_identity(self):
super(CardsObject, self)._checkForKey('color_identity')
return self.scryfallJson['color_identity']
def legalities(self):
super(CardsObject, self)._checkForKey('legalities')
return self.scryfallJson['legalities']
def reserved(self):
super(CardsObject, self)._checkForKey('reserved')
return self.scryfallJson['reserved']
def reprint(self):
super(CardsObject, self)._checkForKey('reprint')
return self.scryfallJson['reprint']
def set_code(self):
super(CardsObject, self)._checkForKey('set')
return self.scryfallJson['set']
def set_name(self):
super(CardsObject, self)._checkForKey('set_name')
return self.scryfallJson['set_name']
def set_uri(self):
super(CardsObject, self)._checkForKey('set_uri')
return self.scryfallJson['set_uri']
def set_search_uri(self):
super(CardsObject, self)._checkForKey('set_search_uri')
return self.scryfallJson['set_search_uri']
def scryfall_set_uri(self):
super(CardsObject, self)._checkForKey('scryfall_set_uri')
return self.scryfallJson['scryfall_set_uri']
def rulings_uri(self):
super(CardsObject, self)._checkForKey('rulings_uri')
return self.scryfallJson['rulings_uri']
def prints_search_uri(self):
super(CardsObject, self)._checkForKey('prints_search_uri')
return self.scryfallJson['prints_search_uri']
def collector_number(self):
super(CardsObject, self)._checkForKey('collector_number')
return self.scryfallJson['collector_number']
def digital(self):
super(CardsObject, self)._checkForKey('digital')
return self.scryfallJson['digital']
def rarity(self):
super(CardsObject, self)._checkForKey('rarity')
return self.scryfallJson['rarity']
def illustration_id(self):
super(CardsObject, self)._checkForKey('illustration_id')
return self.scryfallJson['illustration_id']
def artist(self):
super(CardsObject, self)._checkForKey('artist')
return self.scryfallJson['artist']
def frame(self):
super(CardsObject, self)._checkForKey('frame')
return self.scryfallJson['frame']
def full_art(self):
super(CardsObject, self)._checkForKey('full_art')
return self.scryfallJson['full_art']
def border_color(self):
super(CardsObject, self)._checkForKey('border_color')
return self.scryfallJson['border_color']
def timeshifted(self):
super(CardsObject, self)._checkForKey('timeshifted')
return self.scryfallJson['timeshifted']
def colorshifted(self):
super(CardsObject, self)._checkForKey('colorshifted')
return self.scryfallJson['colorshifted']
def futureshifted(self):
super(CardsObject, self)._checkForKey('futureshifted')
return self.scryfallJson['futureshifted']
def edhrec_rank(self):
super(CardsObject, self)._checkForKey('edhrec_rank')
return self.scryfallJson['edhrec_rank']
def currency(self, mode):
modes = ['usd', 'eur', 'tix']
if mode not in modes:
raise KeyError("{} is not a key.".format(mode))
super(CardsObject, self)._checkForKey(mode)
return self.scryfallJson[mode]
def related_uris(self):
super(CardsObject, self)._checkForKey('related_uris')
return self.scryfallJson['related_uris']
def purchase_uris(self):
super(CardsObject, self)._checkForKey('purchase_uris')
return self.scryfallJson['purchase_uris']
def life_modifier(self):
super(CardsObject, self)._checkForKey('life_modifier')
return self.scryfallJson['life_modifier']
def hand_modifier(self):
super(CardsObject, self)._checkForKey('hand_modifier')
return self.scryfallJson['hand_modifier']
def color_indicator(self, num):
self._checkForTupleKey('card_faces', num, 'color_indicator')
return self.scryfallJson['card_faces'][num]['color_indicator']
def all_parts(self):
super(CardsObject, self)._checkForKey('all_parts')
return self.scryfallJson['all_parts']
def card_faces(self):
super(CardsObject, self)._checkForKey('card_faces')
return self.scryfallJson['card_faces']
def watermark(self):
super(CardsObject, self)._checkForKey('watermark')
return self.scryfallJson['watermark']
def story_spotlight(self):
super(CardsObject, self)._checkForKey('story_spotlight')
return self.scryfallJson['story_spotlight']
def power(self):
super(CardsObject, self)._checkForKey('power')
return self.scryfallJson['power']
def toughness(self):
super(CardsObject, self)._checkForKey('toughness')
return self.scryfallJson['toughness']
def loyalty(self):
super(CardsObject, self)._checkForKey('loyalty')
return self.scryfallJson['loyalty']
def flavor_text(self):
super(CardsObject, self)._checkForKey('flavor_text')
return self.scryfallJson['flavor_text']
def arena_id(self):
super(CardsObject, self)._checkForKey('arena_id')
return self.scryfallJson['arena_id']
def lang(self):
super(CardsObject, self)._checkForKey('lang')
return self.scryfallJson['lang']
def printed_name(self):
super(CardsObject, self)._checkForKey('printed_name')
return self.scryfallJson['printed_name']
def printed_type_line(self):
super(CardsObject, self)._checkForKey('printed_type_line')
return self.scryfallJson['printed_type_line']
def printed_text(self):
super(CardsObject, self)._checkForKey('printed_text')
return self.scryfallJson['printed_text']
def oracle_id(self):
super(CardsObject, self)._checkForKey('oracle_id')
return self.scryfallJson['oracle_id']
def foil(self):
super(CardsObject, self)._checkForKey('foil')
return self.scryfallJson['foil']
def nonfoil(self):
super(CardsObject, self)._checkForKey('nonfoil')
return self.scryfallJson['nonfoil']
def oversized(self):
super(CardsObject, self)._checkForKey('oversized')
return self.scryfallJson['oversized']