magicthegathering / mtg-sdk-javascript Goto Github PK
View Code? Open in Web Editor NEWMagic: The Gathering SDK - Javascript
License: MIT License
Magic: The Gathering SDK - Javascript
License: MIT License
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?
If you do something like:
mtg.cards.where({ name: 'Island' }).then((cards) => {
console.log(`${cards.length} cards returned...`); // will always be 100
});
Where there is obviously more than 100 cards, it only ever returns 100. Is there a way to page the results that I'm not seeing?
When I try to load and compile my reactjs app, some errors appears:
ERROR in ./node_modules/request/lib/har.js
Module not found: Error: Can't resolve 'fs' in '...\magic.io\web\node_modules\request\lib'
@ ./node_modules/request/lib/har.js 3:9-22
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/request-promise/lib/rp.js
@ ./node_modules/mtgsdk/lib/querybuilder.js
@ ./node_modules/mtgsdk/lib/index.js
@ ./app/component/Card.js
@ ./app/component/App.js
@ ./app/index.js
@ multi (webpack)-dev-server/client?http://localhost:8080 ./app/index.js
ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'net' in '...\magic.io\web\node_modules\forever-agent'
@ ./node_modules/forever-agent/index.js 10:10-24
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/request-promise/lib/rp.js
@ ./node_modules/mtgsdk/lib/querybuilder.js
@ ./node_modules/mtgsdk/lib/index.js
@ ./app/component/Card.js
@ ./app/component/App.js
@ ./app/index.js
@ multi (webpack)-dev-server/client?http://localhost:8080 ./app/index.js
ERROR in ./node_modules/tough-cookie/lib/cookie.js
Module not found: Error: Can't resolve 'net' in '...\magic.io\web\node_modules\tough-cookie\lib'
@ ./node_modules/tough-cookie/lib/cookie.js 35:10-24
@ ./node_modules/request-promise/lib/rp.js
@ ./node_modules/mtgsdk/lib/querybuilder.js
@ ./node_modules/mtgsdk/lib/index.js
@ ./app/component/Card.js
@ ./app/component/App.js
@ ./app/index.js
@ multi (webpack)-dev-server/client?http://localhost:8080 ./app/index.js
ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'net' in '...\magic.io\web\node_modules\tunnel-agent'
@ ./node_modules/tunnel-agent/index.js 5:10-24
@ ./node_modules/request/lib/tunnel.js
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/request-promise/lib/rp.js
@ ./node_modules/mtgsdk/lib/querybuilder.js
@ ./node_modules/mtgsdk/lib/index.js
@ ./app/component/Card.js
@ ./app/component/App.js
@ ./app/index.js
@ multi (webpack)-dev-server/client?http://localhost:8080 ./app/index.js
ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'tls' in '...\magic.io\web\node_modules\forever-agent'
@ ./node_modules/forever-agent/index.js 11:10-24
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/request-promise/lib/rp.js
@ ./node_modules/mtgsdk/lib/querybuilder.js
@ ./node_modules/mtgsdk/lib/index.js
@ ./app/component/Card.js
@ ./app/component/App.js
@ ./app/index.js
@ multi (webpack)-dev-server/client?http://localhost:8080 ./app/index.js
ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'tls' in '...\magic.io\web\node_modules\tunnel-agent'
@ ./node_modules/tunnel-agent/index.js 6:10-24
@ ./node_modules/request/lib/tunnel.js
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/request-promise/lib/rp.js
@ ./node_modules/mtgsdk/lib/querybuilder.js
@ ./node_modules/mtgsdk/lib/index.js
@ ./app/component/Card.js
@ ./app/component/App.js
@ ./app/index.js
@ multi (webpack)-dev-server/client?http://localhost:8080 ./app/index.js
Seems that some libraries doesn't install properly.
passing a page property to mtg.card.where results in a page=0 call to the API.
i suggest replacing line 10 in querybuilder.js with
page: args.page||page
in order to fix this issue
Hey, I'm a junior developer looking to contribute to this project. I'm wondering where I should start looking as far as maybe checking out the other SDKs (I'm familiar with Ruby, too) in seeing what needs to be done on the JS side. Thanks!
It could get more involvement from the community if you were to provide ability to import & export the public api in es6/.mjs in an easy fashion in the browser & node environments. This API is pretty rich in data and I'd love to see it flourish more.
How do I fetch cards filtering by multiple cmc? If I do this:
mtg.card.where({set: 'VOW', cmc: '2|3'})
I get a Bad Request error, even though the MTG.io API supports OR operations.
I can do an OR search on colors just fine (red|black), but cmc seems to fail.
I've been having a discussion over in mtgjson/mtgjson#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.
I get the following error when trying to use your project in my react-native application.
TransformError: /myproject/node_modules/mtgsdk/lib/index.js: Couldn't find preset "es2015" relative to directory /myproject/node_modules_mtgsdk
I'm not sure whether this problem has to do with the SDK or if it a problem on my side with integrating your package into my application.
Thanks for creating and maintaining this project. It looks nice!
card.where({name: $var}).then(cards => {
//my code
})
When using this code with $var being any string containing "aether", the cards variable comes in as an empty array. As soon as you use "ether" instead, it works for all cards.
"aetherflux reservoir" results in nothing.
"etherflux reservoir" works.
Hello! I was very excited to find this tool and am trying to use it in a small Angular app, but seem to be running into issues trying to import it.
I've added a map entry to my system.config.js so Angular can find the mtgsdk module:
(function (global) {
System.config({
paths: {
'npm:': 'node_modules/'
},
map: {
app: 'app',
// ...
'mtg': 'npm:mtgsdk/lib/index.js',
},
});
})(this);
I've made a class, CardService, to wrap the mtgsdk module, which I am attempting to import by its alias:
import { Injectable } from '@angular/core';
import { OnInit } from '@angular/core';
import 'mtg';
import { Card } from './card';
// etc.
However, none of the mtgsdk dependencies are loaded properly. I see the following in my console:
I found that all three 404'ed files are required by lib/querybuilder.js. On investigation, I found that I can add maps for those three dependencies, but then their own dependencies error out and obviously this isn't an actual solution. The real issue seems to be that these dependencies are being loaded from the wrong base path.
I'm new to both Angular and Babel so I could be trying to fit a square peg in a round hole here, but I figure others trying to use this module in an Angular app may run into the same issue. Any help would be appreciated!
Hi, I'm getting this error when trying to run my react-native app with the mtgsdk:
bundling failed: UnableToResolveError: Unable to resolve module os
from /Users/emil/Documents/React/MTG-API/node_modules/request-promise/lib/rp.js
: Module does not exist in the module map
Here's a picture of my simulator too:
running npm test
from fresh start doesn't work.
10 passing (37s)
1 failing
1) card
find
returns card:
AssertionError: expected { Object (name, manaCost, ...) } to have nested property 'colors[0]' of 'Black', but got 'B'
+ expected - actual
-B
+Black
at Context.<anonymous> (src/test/test-card.js:16:38)
result.card.should.have.property('type', 'Sorcery โ Arcane')
- result.card.should.have.nested.property('colors[0]', 'Black')
+ result.card.should.have.nested.property('colors[0]', 'B')
result.card.should.have.nested.property('types[0]', 'Sorcery')
Hello everyone!
Since tomorrow morning I tried to implement the types.all() function, as I need for a personal project.
I worked on it today and I ended creating this functionality for types, subtypes and supertypes as I thought the code footprint would be minimal (as I think it actually is).
It's ok for you if I go for a pull request, or maybe it could be better better if I write some addictional tests before?
FYI here is the repository: https://github.com/SilvioPilato/mtg-sdk-javascript/tree/feature/unqueryable
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.