Giter VIP home page Giter VIP logo

mtg-sdk-javascript's People

Contributors

adback03 avatar beauregardhenry avatar bemacized avatar christian4423 avatar dependabot[bot] avatar igogo5yo avatar raineorshine avatar silviopilato 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

mtg-sdk-javascript's Issues

Can't search for cards by mana cost

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?

Return more than 100 results?

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?

Error on load mtgsdk

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.

How to Contribute?

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!

Add ES6 module support

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.

Question: Can I query multiple CMCs?

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.

TransformError: Couldn't find preset "es2015"

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!

Search query for card names with "Aether" always return an empty result.

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.

Babel doesn't seem to play well with Angular

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:

screen shot 2017-02-14 at 1 36 10 pm

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!

Issue in react-native app

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:

simulator screen shot - iphone 7 - 2018-01-02 at 20 08 01

broken test on master branch: card > find > returns card

desc

running npm test from fresh start doesn't work.

steps

  1. git clone โœ…
  2. npm i && npm test โœ…
  3. broken test ๐Ÿ”ด

npm test output:

 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)

quick fix

      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')

Add support for supertypes, subtypes and types

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!

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.