From 7d87ad21b801d7af9a78f089b0dbb3050368aec9 Mon Sep 17 00:00:00 2001 From: Nanda Scott Date: Tue, 6 Feb 2018 20:36:36 -0500 Subject: [PATCH] Added examples and updated docs. --- docs/Cards.md | 2 +- examples/get_and_format_card.py | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 examples/get_and_format_card.py diff --git a/docs/Cards.md b/docs/Cards.md index 1c7b755..4806dba 100644 --- a/docs/Cards.md +++ b/docs/Cards.md @@ -29,7 +29,7 @@ All attributes are listed assuming the following |`card.legalities()`|Dict | A dictionary of all formats and their legality. |`card.reserved()`|Bool | Returns True if the card is on the reserved list. |`card.reprint()`|Bool | Returns True if the card has been reprinted before. -|`card.set()`|String | The 3 letter code for the set of the card. +|`card.set_code()`|String | The 3 letter code for the set of the card. |`card.set_name()`|String | The full name for the set of the card. |`card.set_uri()`|String | The API uri for the full set list of the card. |`card.set_search_uri()`|String | Same output as set_uri. diff --git a/examples/get_and_format_card.py b/examples/get_and_format_card.py new file mode 100644 index 0000000..dd3ab3c --- /dev/null +++ b/examples/get_and_format_card.py @@ -0,0 +1,34 @@ +import scrython + +getCard = input("What card would you like me to search? ") + +card = scrython.cards.Named(fuzzy=getCard) + +if card.object() == 'error': + print(card.scryfallJson['details']) + +if card.type_line() == 'Creature': + PT = "({}/{})".format(card.power(), card.toughness()) +else: + PT = "" + +if card.cmc() == 0: + mana_cost = "" +else: + mana_cost = card.mana_cost() + +string = """ +{cardname} {mana_cost} +{type_line} {set_code} {rarity} +{oracle_text}{power_toughness} +""".format( + cardname=card.name(), + mana_cost=mana_cost, + type_line=card.type_line(), + set_code=card.set_code().upper(), + rarity=card.rarity(), + oracle_text=card.oracle_text(), + power_toughness=PT + ) + +print(string)