Skip to content
22 changes: 22 additions & 0 deletions Sources/ScryfallKit/Extensions/Card+helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@ extension Card {
return legalities.penny ?? .notLegal
case .commander:
return legalities.commander ?? .notLegal
case .future:
return legalities.future ?? .notLegal
case .timeless:
return legalities.timeless ?? .notLegal
case .gladiator:
return legalities.gladiator ?? .notLegal
case .oathbreaker:
return legalities.oathbreaker ?? .notLegal
case .standardbrawl:
return legalities.standardbrawl ?? .notLegal
case .alchemy:
return legalities.alchemy ?? .notLegal
case .paupercommander:
return legalities.paupercommander ?? .notLegal
case .duel:
return legalities.duel ?? .notLegal
case .oldschool:
return legalities.oldschool ?? .notLegal
case .premodern:
return legalities.premodern ?? .notLegal
case .predh:
return legalities.predh ?? .notLegal
}
}

Expand Down
4 changes: 4 additions & 0 deletions Sources/ScryfallKit/Models/Card/Card+Face.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ extension Card {
public var colorIndicator: [Card.Color]?
/// An array of the colors in this card's mana cost
public var colors: [Card.Color]?
/// This face's defense, if any
public var defense: String?
/// This card's flavor text if any
public var flavorText: String?
/// An ID for this card face's art that remains consistent across reprints
Expand Down Expand Up @@ -61,6 +63,7 @@ extension Card {
artist: String? = nil,
colorIndicator: [Card.Color]? = nil,
colors: [Card.Color]? = nil,
defense: String? = nil,
flavorText: String? = nil,
illustrationId: UUID? = nil,
imageUris: ImageUris? = nil,
Expand All @@ -79,6 +82,7 @@ extension Card {
self.artist = artist
self.colorIndicator = colorIndicator
self.colors = colors
self.defense = defense
self.flavorText = flavorText
self.illustrationId = illustrationId
self.imageUris = imageUris
Expand Down
35 changes: 34 additions & 1 deletion Sources/ScryfallKit/Models/Card/Card+Legalities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ extension Card {
public let penny: Legality?
public let commander: Legality?
public let brawl: Legality?
public let future: Legality?
public let timeless: Legality?
public let gladiator: Legality?
public let oathbreaker: Legality?
public let standardbrawl: Legality?
public let alchemy: Legality?
public let paupercommander: Legality?
public let duel: Legality?
public let oldschool: Legality?
public let premodern: Legality?
public let predh: Legality?

public init(
standard: Legality?,
Expand All @@ -28,7 +39,18 @@ extension Card {
vintage: Legality?,
penny: Legality?,
commander: Legality?,
brawl: Legality?
brawl: Legality?,
future: Legality?,
timeless: Legality?,
gladiator: Legality?,
oathbreaker: Legality?,
standardbrawl: Legality?,
alchemy: Legality?,
paupercommander: Legality?,
duel: Legality?,
oldschool: Legality?,
premodern: Legality?,
predh: Legality?,
) {
self.standard = standard
self.historic = historic
Expand All @@ -40,6 +62,17 @@ extension Card {
self.penny = penny
self.commander = commander
self.brawl = brawl
self.future = future
self.timeless = timeless
self.gladiator = gladiator
self.oathbreaker = oathbreaker
self.standardbrawl = standardbrawl
self.alchemy = alchemy
self.paupercommander = paupercommander
self.duel = duel
self.oldschool = oldschool
self.premodern = premodern
self.predh = predh
}
}
}
9 changes: 9 additions & 0 deletions Sources/ScryfallKit/Models/Card/Card+Symbol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ extension Card {
public var funny: Bool
/// The colors that make up this symbol
public var colors: [Color]
/// True if the symbol is a hybrid mana symbol. Note that monocolor Phyrexian symbols aren’t considered hybrid.
public var hybrid: Bool
/// True if the symbol is a Phyrexian mana symbol, i.e. it can be paid with 2 life.
public var phyrexian: Bool
/// Alternate notations for this symbol that used on Wizards of the Coast's [Gatherer](https://gatherer.wizards.com/Pages/Default.aspx)
public var gathererAlternates: [String]?
/// A link to an SVG of this symbol
public var svgUri: String?


/// A computed ID for this symbol which is just the `symbol` property
public var id: String { symbol }
Expand All @@ -47,6 +52,8 @@ extension Card {
appearsInManaCosts: Bool,
funny: Bool,
colors: [Color],
hybrid: Bool,
phyrexian: Bool,
gathererAlternates: [String]? = nil,
svgUri: String? = nil
) {
Expand All @@ -59,6 +66,8 @@ extension Card {
self.appearsInManaCosts = appearsInManaCosts
self.funny = funny
self.colors = colors
self.hybrid = hybrid
self.phyrexian = phyrexian
self.gathererAlternates = gathererAlternates
self.svgUri = svgUri
}
Expand Down
8 changes: 8 additions & 0 deletions Sources/ScryfallKit/Models/Card/Card.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ public struct Card: Codable, Identifiable, Hashable, Sendable {
public var colorIndicator: [Color]?
/// An array of the colors in this card's mana cost
public var colors: [Color]?
/// This card's defense, if any
public var defense: String?
/// This card’s overall rank/popularity on EDHREC. Not all cards are ranked.
public var edhrecRank: Int?
/// True if this card is on the [Commander Game Changer list](https://mtg.wiki/page/Game_Changers).
public var gameChanger: Bool?
/// This card’s hand modifier, if it is Vanguard card. This value will contain a delta, such as -1.
public var handModifier: String?
/// An array of the keywords on this card (deathouch, first strike, etc)
Expand Down Expand Up @@ -206,7 +210,9 @@ public struct Card: Codable, Identifiable, Hashable, Sendable {
colorIdentity: [Color],
colorIndicator: [Color]? = nil,
colors: [Color]? = nil,
defense: String? = nil,
edhrecRank: Int? = nil,
gameChanger: Bool? = nil,
handModifier: String? = nil,
keywords: [String],
layout: Layout,
Expand Down Expand Up @@ -284,7 +290,9 @@ public struct Card: Codable, Identifiable, Hashable, Sendable {
self.colorIdentity = colorIdentity
self.colorIndicator = colorIndicator
self.colors = colors
self.defense = defense
self.edhrecRank = edhrecRank
self.gameChanger = gameChanger
self.handModifier = handModifier
self.keywords = keywords
self.layout = layout
Expand Down
15 changes: 10 additions & 5 deletions Sources/ScryfallKit/Models/Catalog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,25 @@ import Foundation
/// [Scryfall documentation](https://scryfall.com/docs/api/catalogs)
public struct Catalog: Codable, Sendable {
/// The catalog type. Each of these types represents a different `/catalogs` endpoint
public enum `Type`: String, Codable, CaseIterable {
case powers, toughnesses, loyalties, watermarks
public enum `Type`: String, Codable, CaseIterable, Sendable {
case cardNames = "card-names"
case artistNames = "artist-names"
case wordBank = "word-bank"
case creatureTypes = "creature-types"
case planeswalkerTypes = "planeswalker-types"
case landTypes = "land-types"
case supertypes
case cardTypes = "card-types"
case artifactTypes = "artifact-types"
case battleTypes = "battle-types"
case creatureTypes = "creature-types"
case enchantmentTypes = "enchantment-types"
case landTypes = "land-types"
case planeswalkerTypes = "planeswalker-types"
case spellTypes = "spell-types"
case powers, toughnesses, loyalties
case keywordAbilities = "keyword-abilities"
case keywordActions = "keyword-actions"
case abilityWords = "ability-words"
case flavorWords = "flavor-words"
case watermarks
}

/// The number of items in the `data` array
Expand Down
8 changes: 5 additions & 3 deletions Sources/ScryfallKit/Models/Enums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Foundation

/// Environments to play Magic: The Gathering in
public enum Game: String, Codable, CaseIterable, Sendable {
case paper, mtgo, arena
case paper, mtgo, arena, astral, sega
}

/// Comparison strategies for determining what makes a card "unique"
Expand All @@ -20,7 +20,7 @@ public enum UniqueMode: String, Codable, CaseIterable, Sendable {
///
/// [Scryfall documentation](https://scryfall.com/docs/api/cards/search#sorting-cards)
public enum SortMode: String, Codable, CaseIterable, Sendable {
case name, set, released, rarity, color, usd, tix, eur, cmc, power, toughness, edhrec, artist
case name, set, released, rarity, color, usd, tix, eur, cmc, power, toughness, edhrec, artist, spoiled
}

/// Directions that Scryfall can order cards in
Expand All @@ -32,7 +32,9 @@ public enum SortDirection: String, Codable, CaseIterable, Sendable {

/// Formats for playing Magic: the Gathering
public enum Format: String, CaseIterable, Sendable {
case standard, historic, pioneer, modern, legacy, pauper, vintage, penny, commander, brawl
case standard, future, historic, timeless, gladiator, pioneer, modern, legacy, pauper, vintage,
penny, commander, oathbreaker, standardbrawl, brawl, alchemy, paupercommander, duel, oldschool,
premodern, predh
}

/// Currency types that Scryfall provides prices for
Expand Down
6 changes: 4 additions & 2 deletions Sources/ScryfallKit/Models/MTGSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ public struct MTGSet: Codable, Identifiable, Hashable, Sendable {
// While "masters" is in fact not inclusive, it's also a name that we can't control
// swiftlint:disable:next inclusive_language
case core, expansion, masters, masterpiece, spellbook, commander, planechase, archenemy,
vanguard, funny, starter, box, promo, token, memorabilia, arsenal, alchemy, minigame, fromTheVault, premiumDeck, duelDeck, draftInnovation, treasureChest
vanguard, funny, starter, box, promo, token, memorabilia, arsenal, alchemy, minigame,
eternal, fromTheVault, premiumDeck, duelDeck, draftInnovation, treasureChest
/// A layout that hasn't been added to ScryfallKit yet
case unknown(String)

public static let allCases: [Kind] = [
.core, .expansion, .masters, .masterpiece, .spellbook, .commander, .planechase, .archenemy,
.vanguard, .funny, .starter, .box, .promo, .token, .memorabilia, .arsenal, .alchemy, .minigame, .fromTheVault, .premiumDeck, .duelDeck, .draftInnovation, .treasureChest
.vanguard, .funny, .starter, .box, .promo, .token, .memorabilia, .arsenal, .alchemy, .minigame,
.eternal, .fromTheVault, .premiumDeck, .duelDeck, .draftInnovation, .treasureChest
]

public var rawValue: String {
Expand Down
1 change: 1 addition & 0 deletions Tests/ScryfallKitTests/CaseIterableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ final class CaseIterableTests: XCTestCase {
case .arsenal: MTGSet.Kind.allCases.contains(.arsenal)
case .alchemy: MTGSet.Kind.allCases.contains(.alchemy)
case .minigame: MTGSet.Kind.allCases.contains(.minigame)
case .eternal: MTGSet.Kind.allCases.contains(.eternal)
case .fromTheVault: MTGSet.Kind.allCases.contains(.fromTheVault)
case .premiumDeck: MTGSet.Kind.allCases.contains(.premiumDeck)
case .duelDeck: MTGSet.Kind.allCases.contains(.duelDeck)
Expand Down