Can't search for cards by mana cost
Closed this issue · 4 comments
Searching for cards by mana cost doesn't actually filter by the mana cost.
const MTG = require('mtgsdk')
/* ... */
var properties = {manaCost:'{X}{2}{U}'}
/* ... */
MTG.card.where(properties).then(cards => { /* ... */ }
When running this search, cards.length
is 100, but there is actually only one card with the specified mana cost (Stroke of Genius).
I'm using the API in a Discord bot and parsing the desired properties
from user messages, but I have tried hardcoding the properties given above and I'm still getting 100 cards, so it's not the parse function that is causing problems here.
I have also tried printing cards to console to check that the capitalization is correct, but for completeness I found that using manacost
(all lowercase) yields the same results.
I should also mention that searching for name, type, power/toughness, and set all work fine.
Am I missing something here?
I've tried running a query outside of the Discord bot:
const mtg = require('mtgsdk')
mtg.card.where({type:'instant', manaCost:'{X}{2}{U}'}).then(cards => {
console.log(cards.length + " cards found")
console.log(cards[0])
})
And I get this output
100 cards found
{ name: 'AWOL',
manaCost: '{2}{W}',
cmc: 3,
colors: [ 'White' ],
colorIdentity: [ 'W' ],
type: 'Instant',
types: [ 'Instant' ],
rarity: 'Common',
set: 'UNH',
setName: 'Unhinged',
text: 'Remove target attacking creature from the game. Then remove it from the removed-from-game zone and put it into the absolutely-removed-from-the-freaking-game-forever zone.',
artist: 'Stephen Tappin',
number: '2',
layout: 'normal',
multiverseid: 74231,
imageUrl: 'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=74231&type=card',
foreignNames:
[ { name: 'Absent sans permission',
imageUrl: 'http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=97277&type=card',
language: 'French',
multiverseid: 97277 } ],
printings: [ 'UNH' ],
originalText: 'Remove target attacking creature from the game. Then remove it from the removed-from-game zone and put it into the absolutely-removed-from-the-freaking-game-forever zone.',
originalType: 'Instant',
legalities: [ { format: 'Un-Sets', legality: 'Legal' } ],
id: 'b693bb185ff34b833442bfd1822192e9fc53d306' }
OK I just went back to the API site. This is an API issue, not an SDK issue (i.e. the API itself doesn't allow searching for mana cost, it's not a problem with this project).
This quote from the above link:
The fields below are also part of the response (if not null), but cannot currently be used as query parameters
The fields that cannot be used in queries include manaCost
. Not sure how you want to handle this, so I'll leave the issue open for now. Feel free to close it if you wish.
Aha! Thanks for figuring this out. If the API doesn't support it, this library won't be able to support it. I would suggest putting in a ticket with magicthegathering.io for this as a requested feature!