Giter VIP home page Giter VIP logo

mtg-sdk-python's People

Contributors

0x326 avatar adback03 avatar aveheuzed avatar lmccartney avatar mrgreentea avatar mrtyton avatar rafa-acioly avatar reid-e avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mtg-sdk-python's Issues

What are the advantages of using `__new__` instead of `__init__`?

I noticed in #15 that we changed from __init__ to __new__ in classes like Card and Set. I was wondering what the advantage of this is? It seems like __init__ offers more utility over __new__, since IDEs can suggest class members and, with Python 3.6 type annotations, could even infer their type (see below)

class Card:
    def __init__(self, response_dict=None):
        if response_dict is None:
            response_dict = {}
        self.name: str = response_dict.get('name')
        self.cmc: int = response_dict.get('cmc')
        # ...

Card orderBy is throwing a 500 error

I haven't tested this with other models, but the Card model at least is throwing a 500 when using orderBy.

This is my query:
Card.where(name=card_name).where(orderBy='name').all()

And this is the response I'm getting:

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/mtgsdk/restclient.py", line 35, in get
    response = json.loads(urlopen(req).read().decode("utf-8"))
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.8/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 500: Internal Server Error

Pull request checks will fail due to out-of-date tests

My comment on this failed pull request details a single example, but it seems that server-side changes have resulted in tests failing.

The following tests produce the following failures (This information is also in my comment on the pull request):

test_find_returns_set (tests.test_set.TestSet) seems to fail because 'border' seems to have been removed from API responses

test_find_returns_card (tests.test_card.TestCard) seems to fail because of formatting changes, in the case of the pull request above, the addition of newlines before quote attributions in flavor text.

test_all_returns_changelogs (tests.test_changelog.TestChangelog) seems to fail because the server returns an empty changelog

test_generate_booster_returns_cards (tests.test_set.TestSet) seems to fail because the server does not consistently return 15-item boosters. In the pull request above it returned 13-item boosters. In the in-browser calls I made reviewing the test I was getting 14-item boosters.

test_where_filters_on_name (tests.test_set.TestSet) seems to fail because of the addition of the "promos" set (in this case PKTK) increasing the length of the returned list of sets.

test_all_returns_supertypes (tests.test_supertype.TestSupertype) seems to fail because 'Host' was added to the Types test instead of the Supertypes test.

test_all_returns_types (tests.test_type.TestType) seems to fail because 'Host' was added to the test instead of 'Hero', and B.F.M. has added 'Summon' and 'You'll'

Query with Exlusion

As of this comment, there is no way to put a "not" statement in a query, which is a part of gatherer and honestly is an essential logical function.

Some of the Card properties don't work

I tried to filter a search based on the Card property reserved and I am seeing AttributeError: 'Card' object has no attribute 'reserved. Other properties like cmc, name and rarity work without any issues.

sorting by legality

ive written a few programs handling the information generated by the apk, mostly just adding it all to a database for querying, how would one go about sorting by legality? the fields are available but the best way i can find is simply creating databases hard coded by set, is there a better way to do this?

more a personal problem

does anyone have ideas on parsing card text for synergies ive used the sdk to create a database in hopes i can find a player bot ai to train with all these cards but basically im looking for anything anyone has done with this apk in the way of development, the project i hope to one day complete is fairly feature heavy and i could use all the help i can get, tysm for this library its been incredibly helpful

generate_booster returns booster pack lists which cannot exist

Generating an Eldritch Moon booster with generate_booster occasionally results in a booster that contains one of the "Meld" cards; "Brisela, Voice of Nightmares", "Hanweir, the Writhing Township" and "Chittering Host" (I have only confirmed this with Brisela). These cards are entities created by the use of the Meld ability to combine two other cards; hence they do not physically exist as cards and the game rules prevent them from existing in virtual formats in any other context than gameplay.

It would be nice if the command were prevented (or able to be prevented) from including in generated boosters from more recent expansions cards that are considered by Gatherer to be part of that expansion but do not exist in the box/booster paradigm (such as Buy-A-Box promotional cards and cards included only in the introductory Planeswalker Decks) but boosters that include cards that do not exist at all at least is incorrect behaviour.

can't filter on multiverse_id or id

I can't filter a card on multiverse_id or id and filtering in combination with other traits like color and subtype. Am I misreading something or is this not implemented?

https://api.magicthegathering.io/v1/cards/mutliverse_id or id works,but when i do https://api.magicthegathering.io/v1/cards?id=id or ?multiverse_id= multiverse_id it just gives all cards as result.

python:
query.where(multiverse_id=mid) and query.where(id=id) is also ignored.

I need this because i want to link my own database to yours by storing which user owns which card and letting your database doing the rest.

Color Identity as filter not working

It appears the query ignores color identity filters. For example:

Card.where(power = 15).where(color_identity = 'G').all()

Returns four cards, only one of which has green (the other three are None). This happens even when the other cards are an actual color and not just colorless. When mixing and matching queries, the color identity is always ignored.

Issue with Character Encoding in Card Text

I have been using the MTGSDK to fetch card data, particularly card text. However, I have encountered an issue with character encoding when fetching the card text using the MTGSDK. Specifically, certain characters like apostrophes (') are not being properly decoded in the fetched card text. This issue is consistently present across different sets and cards.

Steps to Reproduce:

  1. Use the MTGSDK to fetch card data, including card text.
  2. Inspect the fetched card text for characters like apostrophes (').

Expected Behavior:
The fetched card text should properly decode characters like apostrophes (') and display them correctly.

Actual Behavior:
The fetched card text displays characters like apostrophes (') in a different encoding, leading to incorrect display.

Additional Information:

  • I have tested different approaches to decode the characters, including using Python's html.unescape() and direct replacement of Unicode characters, but the issue persists.
  • The problem is not related to the specific language setting (French, in my case), as I have tested without specifying a language.
  • I suspect that the issue might be related to how the MTGSDK handles character encoding when fetching card data.

Example with Kayla's Command :
Kayla's Command,Rare,['W'],Sorcery,,"Choose two —
• Create a 2/2 colorless Construct artifact creature token.
• Put a +1/+1 counter on a creature you control. It gains double strike until end of turn.
• Search your library for a basic Plains card, reveal it, put it into your hand, then shuffle.
• You gain 2 life and scry 2.",,,BRO,The Brothers' War,"[{""date"": ""2022-10-14"", ""text"": ""None of the modes have any targets. Notably, this means that you don\u2019t have to choose a creature for the second mode until the spell resolves.""}]",Legal

You can show the problem at this line : Notably, this means that you don\u2019t have to choose a creature for the second mode until the spell resolves.

"don't" appear as "don\u2019t" and it is similar for so many special characters ( \u201c, \u201d, \u2014, etc...)

Thank you for the help.

Environment:

  • Python version: [3.11.4]
  • MTGSDK version: [1.3.1]
  • Operating System: [Windows 10 Professionnal x64]

Brothers War

Using this to get the cards from brothers war -

cards = Card.where(set='BRO').all()

but coming back

cards = [ ]

Tried lowercase found BRO from your Set.name

Any help appreciated

Query for language

I'm trying to use
Card.where(language='portuguese').all()

and i'm always geting empty list, i'v try as well:

Card.where(language='russian').where(name=3).all()

that are the same of

https://api.magicthegathering.io/v1/cards?language=russian&name=3

and i'm getting empty list too.

How to access the info of a compilation of cards.

Hello, Im new to coding and I'm trying to experience with Magic SDK. Im doing this:

`from mtgsdk import Card

card = Card.find(386616)`
and if i print card, i get <mtgsdk.card.Card object at 0x7f63e6c42320>
how do i access tho that info?
I know it can be basic, i just need some help and i cant find any tutorials on this...
Thanks:)

finding a card by multiverse_id returns a strange string

Just installed the sdk and have run into an issue seaching using the multiverse_id
the code

card = Card.find(420830)
print(card)

returns the following string instead of information about the card

<mtgsdk.card.Card object at 0x0000023A3E5190A0>

Other commands like getting sets, types, etc. seem to work fine.
using python 3.9

Query for language

Only english cards are filtered.
Even Card.where(language='Portuguese (Brazil)').where(set="RIX").all() just brings up english text as states in a closed issue.

cards = Card.where(language="German").where(set="RIX").all()
for card in cards:
	print(card.name)
	print(card.mana_cost)
	print(card.supertypes)
	print(card.subtypes)
	print(card.types)
	print(card.rarity)
	print(card.text)
	print(card.power)
	print(card.toughness)
	print(card.loyalty)
	print(card.multiverse_id)
	print(card.image_url)
	print(card.set)
	print(card.set_name)
	print(card.rulings)

Example Output:

Angrath's Fury
{3}{B}{R}
None
None
['Sorcery']
Rare
Destroy target creature. Angrath's Fury deals 3 damage to target player. You may search your library and/or graveyard for a card named Angrath, Minotaur Pirate, reveal it, and put it into your hand. If you search your library this way, shuffle it.
None
None
None
441898
http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=441898&type=card
RIX
Rivals of Ixalan
[{'date': '2018-01-19', 'text': "You can't cast Angrath's Fury unless you choose both a target creature and a target player."}, {'date': '2018-01-19', 'text': "If either target becomes illegal after you cast Angrath's Fury but before it resolves, the other is still affected as appropriate and you'll search for Angrath. However, if both targets become illegal, the spell is countered and you won't search."}]

Add Color Identity

The API returns a colorIdentity field which is not present in this SDK.

HTTP 500 Error on Every Card Method

Whatever backend server this SDK is calling is returning HTTP 500 errors. Even the simple examples in the README fail.
Example:

from mtgsdk import Card
card = Card.find(386616)

throws:

  File "/home/user/env/lib/python3.8/site-packages/mtgsdk/restclient.py", line 35, in get
    response = json.loads(urlopen(req).read().decode("utf-8"))
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.8/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 500: Internal Server Error

This SDK is unusable if its dependencies are unreliable.

Newer Cards Do Not Have Images

I just started using mtgsdk and I think it's great. I have two questions/concerns:

Some of the cards from the most recent set Kamigawa Neon Dynasty do not include image_url's. Example: "The Wandering Emperor"

  • Will these images become available in the future?
  • Will mtgsdk support cards from future sets after they are released? I imagine an API is made to a database in the backend, so ideally I won't have to update mtgsdk each time a new set releases.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.