GithubHelp home page GithubHelp logo

Comments (7)

ChiriVulpes avatar ChiriVulpes commented on June 4, 2024 1

For 3, I believe you're looking for Scry.Card.construct(raw)

from scryfall-sdk.

ChiriVulpes avatar ChiriVulpes commented on June 4, 2024

Hmm I don't quite remember, but looking at the code I think it's to allow using the same code no matter the type of card? I think in this case it allows being like "okay so no matter how many faces this card has, grab the first one, then do operations on the data in that face". The card face it adds won't have info printed with console logging, for reference, but I believe you can still access it bcuz its prototype is the card itself? I don't actually know if that works tbh. I'll mess with it when I get to PC

from scryfall-sdk.

furgin avatar furgin commented on June 4, 2024

Cards that come back from the API with no faces array end up with a faces array with a single element that just has:

[ { "object": "card_face" } ]

I think this is a bug and should just be undefined to match the source API

from scryfall-sdk.

ChiriVulpes avatar ChiriVulpes commented on June 4, 2024

I'm at PC now. Like I said, the face uses the card itself as its prototype, which results in the following:
image

You can access any data from the base card from the face, provided the face doesn't override it with different information. Since the data is not duplicated, and instead provided via the card face's prototype, it can't be logged. That's why in this screenshot, it looks like it just has "object": "card_face" rather than having everything. It does have everything, it just can't be logged.

If card faces matter to what you're working on, just get the data from the first face in favour of doing some kind of check to determine whether to use the face or the card itself.

from scryfall-sdk.

ChiriVulpes avatar ChiriVulpes commented on June 4, 2024

If you don't think this will work, it might be helpful for me to know what exactly you're trying to do? Maybe we can work something out

from scryfall-sdk.

furgin avatar furgin commented on June 4, 2024

I was hoping for a more consistent approach to processing data from a bulk stream (which is a raw JSON object) and the Scry.Card type that is collected through the API. They behave differently in this case where the raw object has no faces array but the object does, in most cases you can safely treat them as the same thing.

I was thinking of options how this could work,

  1. that they should behave close, ie have no array on the Scry.Card object like the json response (this is what I was trying to do)
  2. provide a way to get the raw json from the Card object (then write the logic based on this)
  3. provide a way to wrap up a raw json object in to a Scry.Card object so I can process a bulk stream as an object

from scryfall-sdk.

ChiriVulpes avatar ChiriVulpes commented on June 4, 2024

I'm going to close this for now, feel free to reopen if you have more questions on the topic or still can't get something to work with the current way this stuff functions!

from scryfall-sdk.

Related Issues (20)

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.