Comments (7)
For 3, I believe you're looking for Scry.Card.construct(raw)
from scryfall-sdk.
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.
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.
I'm at PC now. Like I said, the face uses the card itself as its prototype, which results in the following:
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.
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.
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,
- 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)
- provide a way to get the raw json from the Card object (then write the logic based on this)
- 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.
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)
- Moved price fields in Scryfall API
- Use a different network library so the sdk is usable in browser HOT 1
- TsLint assumes system file structure
- `frame_effect` removal, `frame_effects` and `preview` additions HOT 3
- Update README (out of date)
- Update type Card
- Runtime error with interfaces exported from Scry module: Cannot read property 'collection' of undefined HOT 2
- All Cards api route deprecated HOT 1
- `gulp build` step emits declaration files with errors. HOT 3
- Failed Fuzzy search returns a strange format HOT 1
- Card Imagery HOT 1
- Search for a set HOT 1
- `.cancelAfterPage().waitForAll()` never resolves HOT 5
- svg_uri missing from CardSymbol HOT 2
- Test failures after Scryfall API changes
- Cards.bySet does not allow for string collectorNumber
- Installing on vite HOT 8
- Tagger api support HOT 2
- add penny_rank to Card definition
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scryfall-sdk.