bmbowdish / swiftfall Goto Github PK
View Code? Open in Web Editor NEWWrapper for Scryfall API written in Swift
License: MIT License
Wrapper for Scryfall API written in Swift
License: MIT License
Cards are entirely immutable as is, and with like 13,000+ of them potentially in use, it doesn't really make sense to copy them around as much as they're currently forced to be. Consider making Card
a class.
Swift 4.1 introduces a new property on JSONDecoder
called keyEncodingStrategy
. This will allow the JSON encoder/decoder to convert property names spelled in camel case like let manaCost: Int?
into mana_cost
when reading from or writing to JSON. This way you get nice Swifty property names that don't use snake_case
, and the decoder automatically reads the snake case versions from the JSON.
https://www.hackingwithswift.com/articles/52/swift-4-1-improves-codable-with-keydecodingstrategy
Scryfall has recently changed the way prices are fetched.
It is no longer:
public let usd: String?
It is now prices[usd]
How could we write that in swift? I tried many things but with no solution.
"First and foremost: On June 10, 2020 Scryfall will remove access to the “all cards” /cards API endpoint. This endpoint is now deprecated." (https://scryfall.com/blog/updates-to-bulk-data-and-cards-deprecation-notice-217)
Swiftfall/Sources/Swiftfall/Swiftfall.swift
Line 733 in 6ba0779
and
Swiftfall/Sources/Swiftfall/Swiftfall.swift
Line 750 in 6ba0779
should be marked as deprecated or should be removed.
I think a boolean for "is double sides" would be helpful. Otherwise it is very hard to know if a card is double sides or not.
In Swift, you only need to mark a property as public
in order to expose its getter. Swift automatically synthesizes getter/setter methods for properties, unlike languages like Java.
The explicit getters such as this:
let name: String?
public func getName() -> String? {
return self.name
}
...can be replaced with:
public let name: String?
...and used by just referencing card.name
.
Swiftfall/Sources/Swiftfall/Swiftfall.swift
Line 804 in 6ba0779
The String passed to autocomplete(_ string: String)
is not encoded with .addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
Currently autocomplete("Omnath, Locus")
crashes because of the whitespace
I really don't understand how to set up a Cocoa Pod.
If anyone sees this and wants to help me out I would appreciate it.
Thanks.
I use optionals because they are the safest way to handle this many things out of my control. However, CardList, RulingList, SetList are made up of optionals which mean they they are an optional that contains an array of optionals.
This is probably a little overly pedantic and I'm sure there are places I could use less Optionals.
JSON is mostly strings, but having dates and urls makes more sense.
Creatures with non-integer mana cost break things.
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.