Open dkniffin opened 7 years ago
Nice!
I can imagine this being useful in two places:
Regarding the implementation of (2), I can imagine this functionality being provided through an instance method on the card object (card.abilities()
) or a static function on the root mtg object (mtg.abilities(card)
). An instance method will be most convenient and familiar for the average object-oriented developer. The downside is that it changes the nature of the card object from static data (JSON object) to a hybrid object with both data and a function. This could be problematic for the serialization of card objects, for example.
I would like to hear your input on the above assessment, then I welcome your contribution!
For my app, I'm downloading all the data before runtime, and just loading in a giant json blob, rather than hitting the API every time. So, in my case, I think it'd be more helpful to have this be a static method.
Okay, doesn't hurt to add it as a static method :)
I've been having a discussion over in https://github.com/mtgjson/mtgjson/issues/285 about the best way to get a list of static abilities for a given card. Some examples: Rotting Rats would return
['Unearth']
, Anax and Cymede would return['First Strike', 'Vigilance']
I just finished up a helper function for doing this, and posted it in the issue I mentioned above. I think that would ideally go in this library. If you're interested, I can make a PR for it.