Documentation ¶
Index ¶
- Constants
- Variables
- func AllNames(variant string, sealed bool) []string
- func AllPromoTypes() []string
- func BoosterGen(setCode, boosterType string) ([]string, error)
- func BuildSealedProductMap(idName string) map[int][]string
- func Contains(str1, str2 string) bool
- func Cut(in, tag string) []string
- func Equals(str1, str2 string) bool
- func ExtractNumber(str string) string
- func ExtractNumericalValue(str string) string
- func ExtractYear(str string) string
- func GCD(a, b int) int
- func GetAllSets() []string
- func GetDecklist(setCode, sealedUUID string) ([]string, error)
- func GetPicksForDeck(setCode, deckName string) ([]string, error)
- func GetPicksForSealed(setCode, sealedUUID string) ([]string, error)
- func GetSealedUUIDs() []string
- func GetUUIDs() []string
- func HasBorderlessPrinting(name string, editions ...string) bool
- func HasEtchedPrinting(name string, editions ...string) bool
- func HasExtendedArtPrinting(name string, editions ...string) bool
- func HasFoilPrinting(name string, editions ...string) bool
- func HasNonfoilPrinting(name string, editions ...string) bool
- func HasPrefix(str1, str2 string) bool
- func HasPrereleasePrinting(name string, editions ...string) bool
- func HasPromoPackPrinting(name string, editions ...string) bool
- func HasReskinPrinting(name string, editions ...string) bool
- func HasRetroFramePrinting(name string, editions ...string) bool
- func HasSerializedPrinting(name string, editions ...string) bool
- func HasShowcasePrinting(name string, editions ...string) bool
- func HasSuffix(str1, str2 string) bool
- func IsBasicLand(name string) bool
- func IsToken(name string) bool
- func LCM(a, b int) int
- func LoadDatastore(reader io.Reader) error
- func LoadDatastoreFile(filename string) error
- func Match(inCard *InputCard) (cardId string, err error)
- func MatchId(inputId string, finishes ...bool) (string, error)
- func Normalize(str string) string
- func ParseCommanderEdition(edition, variant string) string
- func ParsePrice(priceStr string) (float64, error)
- func Printings4Card(name string) ([]string, error)
- func Scryfall2UUID(id string) string
- func SealedCardUnit(setCode, sealedUUID string) int
- func SealedHasDecklist(setCode, sealedUUID string) bool
- func SealedIsRandom(setCode, sealedUUID string) bool
- func SealedWithinSealed(setCode, sealedUUID string) []string
- func SearchContains(name string) ([]string, error)
- func SearchEquals(name string) ([]string, error)
- func SearchHasPrefix(name string) ([]string, error)
- func SearchRegexp(name string) ([]string, error)
- func SearchSealedContains(name string) ([]string, error)
- func SearchSealedEquals(name string) ([]string, error)
- func SetGlobalDatastore(datastore cardBackend)
- func SetGlobalLogger(userLogger *log.Logger)
- func SimpleSearch(cardName, number string, foil bool) (string, error)
- func SplitVariants(str string) []string
- func Tcg2UUID(id string) string
- func Title(str string) string
- type AliasingError
- type AllPrintings
- type Booster
- type Card
- type CardObject
- type DataStore
- type DeckCard
- type InputCard
- type LorcanaJSON
- type ProductProbabilities
- type SealedContent
- type Set
- type Sheet
Constants ¶
const LongestCardEver = "" /* 141-byte string literal not displayed */
const NightmareCard = "The Ultimate Nightmare of Wizards of the Coast® Customer Service"
Variables ¶
var ARNGuilds = []string{"Azorius", "Gruul", "Orzhov", "Rakdos", "Simic"}
Guilds found in ARN
Date since BuyABox cards are found in the expansion set instead of Promos
Date since BuyABox cards are not unique any more
var EditionTable = map[string]string{}/* 477 elements not displayed */
var ErrAliasing = NewAliasingError()
var ErrCardDoesNotExist = errors.New("unknown card name")
var ErrCardMissingVariant = errors.New("missing necessary variant")
var ErrCardNotInEdition = errors.New("unknown edition")
var ErrCardUnknownId = errors.New("unknown id")
var ErrCardWrongVariant = errors.New("unknown variant")
var ErrDatastoreEmpty = errors.New("datastore is empty")
var ErrUnsupported = errors.New("unsupported")
var GRNGuilds = []string{"Boros", "Dimir", "Golgari", "Izzet", "Selesnya"}
Guilds found in GRN
Date since any card could be Prerelease Promo
Date in which random promos can be in the expansion set
var SeparateFinishCollectorNumberDate = time.Date(2022, time.February, 1, 0, 0, 0, 0, time.UTC)
Date since different finishes (etched, gilded, thick) get separate collector numbers
var VariantsTable = map[string]map[string]map[string]string{
"Alliances": allVariants,
"Alternate Fourth Edition": ed4Variants,
"Anthologies": athVariants,
"Antiquities": atqVariants,
"Arena League 2001": pal01Variants,
"Asia Pacific Land Program": palpVariants,
"Battle Royale Box Set": brbVariants,
"Champions of Kamigawa": chkVariants,
"Chronicles Foreign Black Border": chrVariants,
"Chronicles": chrVariants,
"Collectors' Edition": oldLandVariants,
"Commander Anthology Volume II": cm2Variants,
"Conspiracy: Take the Crown": cn2Variants,
"Deckmasters": dkmVariants,
"Dominaria United": douVariants,
"Double Masters": xm2Variants,
"European Land Program": pelpVariants,
"Fallen Empires": femVariants,
"Fifth Edition": ed5Variants,
"Foreign Black Border": ed3Variants,
"Fourth Edition Foreign Black Border": ed4Variants,
"Fourth Edition": ed4Variants,
"GRN Ravnica Weekend": prwkVariants,
"Homelands": hmlVariants,
"Ice Age": iceVariants,
"Intl. Collectors' Edition": oldLandVariants,
"Introductory Two-Player Set": itpVariants,
"Kaldheim": khmVariants,
"Kamigawa: Neon Dynasty": neoVariants,
"League Tokens 2013": l13Variants,
"Limited Edition Alpha": leaVariants,
"Limited Edition Beta": oldLandVariants,
"Magic Premiere Shop 2005": pmpsVariants,
"Mirage": mirVariants,
"Murders at Karlov Manor": mkmVariants,
"Oath of the Gatewatch": ogwVariants,
"Portal Second Age": po2Variants,
"Portal": porVariants,
"Pro Tour Collector Set": ptcVariants,
"RNA Ravnica Weekend": prw2Variants,
"Revised Edition": ed3Variants,
"Rinascimento": rinVariants,
"Secret Lair Drop": sldVariants,
"Shadows over Innistrad Promos": psoiVariants,
"Shadows over Innistrad": soiVariants,
"Special Guests": spgVariants,
"Summer Magic / Edgar": ed3Variants,
"Tales of Middle-earth Commander": ltcVariants,
"Tempest": tmpVariants,
"The List": plstVariants,
"The List (Unfinity Foil Edition)": ulstVariants,
"The Lost Caverns of Ixalan": lciVariants,
"Unglued": ulgVariants,
"Unlimited Edition": oldLandVariants,
"Unstable": ustVariants,
"World Championship Decks 1997": wc97Variants,
"World Championship Decks 1998": wc98Variants,
"World Championship Decks 1999": wc99Variants,
"World Championship Decks 2001": wc01Variants,
"World Championship Decks 2002": wc02Variants,
}
Functions ¶
func AllNames ¶ added in v0.4.40
Return a slice of all names loaded up, in three different fashion normalized, lowercase, or canonical
func AllPromoTypes ¶ added in v0.4.3
func AllPromoTypes() []string
func BoosterGen ¶ added in v0.3.15
func BuildSealedProductMap ¶ added in v0.4.27
Provide a map of ids with a slice of uuids For most cases the slice will be of size one, but some ids may hold a second uuid representing the foil version of the product
func Cut ¶
Cut splits the input string in two segments, stripping any whitespace before or after the cut, if present.
func ExtractNumber ¶
ExtractNumber returns as lower case string with the _first_ collector number below 1993 found in a given string, or an empty string if none could be found. The input string may have a single character as prefix or up to two characters as suffix (one letter and one special character), but not both. Any extra letters will be ignored while determining the number portion, but preserved in the ouput, and returned as lowercase. Any leading # characters, zeroes or parenthesis are stripped away. Numbers starting with M are ignored because they could be confused with core set names. If a month name is detected anywhere as a single word in the input string, an empty string is returned, to prevent confusing a number with a date or day. If a rational number is provided, only the numerator part is considered.
func ExtractNumericalValue ¶ added in v0.4.55
Obtain the numerical value of the input so that it can be used for strconv.Atoi()
func ExtractYear ¶
ExtractYear returns as string with _first_ year after 1993 found in a given string, or an empty string if nothing is found. It takes care of some special characters like parenthesis (ignored) and abbreviations (so '06 becomes 2006).
func GetAllSets ¶ added in v0.4.23
func GetAllSets() []string
func GetDecklist ¶ added in v0.4.8
func GetPicksForDeck ¶ added in v0.3.25
func GetPicksForSealed ¶ added in v0.3.25
func GetSealedUUIDs ¶ added in v0.4.25
func GetSealedUUIDs() []string
func HasBorderlessPrinting ¶
func HasEtchedPrinting ¶
func HasExtendedArtPrinting ¶
func HasFoilPrinting ¶
func HasNonfoilPrinting ¶
func HasPrereleasePrinting ¶
func HasPromoPackPrinting ¶
func HasReskinPrinting ¶
func HasRetroFramePrinting ¶
func HasSerializedPrinting ¶ added in v0.4.3
func HasShowcasePrinting ¶
func IsBasicLand ¶
Returns whether the input string may represent a basic land
func LoadDatastore ¶
func LoadDatastoreFile ¶
func Normalize ¶
Normalize uses the rules defined in Replacer to replace uncommon elements of card names, dropping all the spaces and producing a lowercase string.
func ParseCommanderEdition ¶
func ParsePrice ¶
Strip input string of dollar sign and commas, convert it to a normal float
func Printings4Card ¶
func Scryfall2UUID ¶
func SealedCardUnit ¶ added in v0.4.61
func SealedHasDecklist ¶ added in v0.3.42
func SealedIsRandom ¶ added in v0.3.33
func SealedWithinSealed ¶ added in v0.3.29
Return a list of sealed products contained by the input product Decks and Packs and Card cannot contain other sealed product, so they are ignored here
func SearchContains ¶
func SearchEquals ¶
func SearchHasPrefix ¶
func SearchRegexp ¶
func SearchSealedContains ¶
func SearchSealedEquals ¶
func SetGlobalDatastore ¶ added in v0.4.41
func SetGlobalDatastore(datastore cardBackend)
func SetGlobalLogger ¶
func SimpleSearch ¶ added in v0.4.43
func SplitVariants ¶
SplitVariants returns an array of strings from the parentheses-defined fields commonly used to distinguish some cards across editions.
Types ¶
type AliasingError ¶
func NewAliasingError ¶ added in v0.4.57
func NewAliasingError(duplicates ...string) *AliasingError
func (*AliasingError) Error ¶
func (err *AliasingError) Error() string
func (*AliasingError) Probe ¶
func (err *AliasingError) Probe() []string
type AllPrintings ¶ added in v0.4.41
type AllPrintings struct { Data map[string]*Set `json:"data"` Meta struct { Date string `json:"date"` Version string `json:"version"` } `json:"meta"` }
func (AllPrintings) Load ¶ added in v0.4.41
func (ap AllPrintings) Load() cardBackend
type Card ¶
type Card struct { Artist string `json:"artist"` AttractionLights []int `json:"attractionLights"` BorderColor string `json:"borderColor"` Colors []string `json:"colors"` ColorIdentity []string `json:"colorIdentity"` FaceName string `json:"faceName"` FaceFlavorName string `json:"faceFlavorName"` Finishes []string `json:"finishes"` FlavorName string `json:"flavorName"` FlavorText string `json:"flavorText"` FrameEffects []string `json:"frameEffects"` FrameVersion string `json:"frameVersion"` Identifiers map[string]string `json:"identifiers"` IsAlternative bool `json:"isAlternative"` IsFullArt bool `json:"isFullArt"` IsFunny bool `json:"isFunny"` IsOnlineOnly bool `json:"isOnlineOnly"` IsOversized bool `json:"isOversized"` IsPromo bool `json:"isPromo"` IsReserved bool `json:"isReserved"` Language string `json:"language"` Layout string `json:"layout"` Name string `json:"name"` Number string `json:"number"` OriginalReleaseDate string `json:"originalReleaseDate"` Printings []string `json:"printings"` PromoTypes []string `json:"promoTypes"` Rarity string `json:"rarity"` SetCode string `json:"setCode"` SourceProducts map[string][]string `json:"sourceProducts"` Side string `json:"side"` Subsets []string `json:"subsets"` Types []string `json:"types"` Subtypes []string `json:"subtypes"` Supertypes []string `json:"supertypes"` UUID string `json:"uuid"` Variations []string `json:"variations"` Watermark string `json:"watermark"` // A list of URLs containing the image of the card // At a minimum "full" and "thumbnail" versions should be provided Images map[string]string }
func MatchInSet ¶
Return an array of Card containing all the cards with the exact same name as the input name in the Set identified by setCode.
func MatchInSetNumber ¶ added in v0.4.2
Return an array of Card containing all the cards with the exact same name as the input name in the Set identified by setCode with the specified collector number.
func MatchWithNumber ¶ added in v0.4.15
Return an array of Card containing all the cards with the exact set code and collector number, using the name as hint (can be empty)
func (*Card) HasFrameEffect ¶ added in v0.4.41
func (*Card) HasPromoType ¶ added in v0.4.41
func (*Card) IsDFCSameName ¶ added in v0.4.41
Check if a dual-faced card has the same for both faces
type CardObject ¶
CardObject is an extension of mtgjson.Card, containing fields that cannot be easily represented in the original object.
func GetUUID ¶
func GetUUID(uuid string) (*CardObject, error)
func (CardObject) String ¶
func (co CardObject) String() string
Card implements the Stringer interface
type InputCard ¶ added in v0.4.41
type InputCard struct { // The mtgjson unique identifier of the card // When used as input it can host mtgjson or scryfall id Id string `json:"id,omitempty"` // The canonical name of the card Name string `json:"name,omitempty"` // The hint or commonly know variation Variation string `json:"variant,omitempty"` // The set the card comes from, or a portion of it Edition string `json:"edition,omitempty"` // Whether the card is foil or not Foil bool `json:"foil,omitempty"` // The language as parsed Language string `json:"language,omitempty"` // contains filtered or unexported fields }
Card is a generic card representation using fields defined by the MTGJSON project.
func (*InputCard) IsBasicLand ¶ added in v0.4.41
Returns whether the card is a basic land
type LorcanaJSON ¶ added in v0.4.41
type LorcanaJSON struct { Metadata struct { FormatVersion string `json:"formatVersion"` GeneratedOn string `json:"generatedOn"` Language string `json:"language"` } `json:"metadata"` Sets map[string]struct { PrereleaseDate string `json:"prereleaseDate"` ReleaseDate string `json:"releaseDate"` HasAllCards bool `json:"hasAllCards"` Type string `json:"type"` Number int `json:"number"` Name string `json:"name"` } `json:"sets"` Cards []struct { Abilities []struct { Effect string `json:"effect"` FullText string `json:"fullText"` Name string `json:"name"` Type string `json:"type"` } `json:"abilities,omitempty"` Artists []string `json:"artists"` ArtistsText string `json:"artistsText"` Code string `json:"code"` Color string `json:"color"` Cost int `json:"cost"` FlavorText string `json:"flavorText,omitempty"` FoilTypes []string `json:"foilTypes,omitempty"` FullIdentifier string `json:"fullIdentifier"` FullName string `json:"fullName"` FullText string `json:"fullText"` FullTextSections []string `json:"fullTextSections"` ID int `json:"id"` Images map[string]string `json:"images,omitempty"` Inkwell bool `json:"inkwell"` Lore int `json:"lore,omitempty"` Name string `json:"name"` Number int `json:"number"` Rarity string `json:"rarity"` SetCode string `json:"setCode"` SimpleName string `json:"simpleName"` Story string `json:"story"` Strength int `json:"strength,omitempty"` Subtypes []string `json:"subtypes,omitempty"` Type string `json:"type"` Version string `json:"version,omitempty"` Willpower int `json:"willpower,omitempty"` KeywordAbilities []string `json:"keywordAbilities,omitempty"` PromoIds []int `json:"promoIds,omitempty"` Errata []string `json:"errata,omitempty"` Clarifications []string `json:"clarifications,omitempty"` Effects []string `json:"effects,omitempty"` Variant string `json:"variant,omitempty"` VariantIds []int `json:"variantIds,omitempty"` MoveCost int `json:"moveCost,omitempty"` NonPromoID int `json:"nonPromoId,omitempty"` IsExternalReveal bool `json:"isExternalReveal,omitempty"` } `json:"cards"` }
func (LorcanaJSON) Load ¶ added in v0.4.41
func (lj LorcanaJSON) Load() cardBackend
type ProductProbabilities ¶ added in v0.4.4
func GetProbabilitiesForSealed ¶ added in v0.4.4
func GetProbabilitiesForSealed(setCode, sealedUUID string) ([]ProductProbabilities, error)
func SealedBoosterProbabilities ¶ added in v0.4.4
func SealedBoosterProbabilities(setCode, boosterType string) ([]ProductProbabilities, error)
func SealedSheetProbabilities ¶ added in v0.4.4
func SealedSheetProbabilities(setCode, boosterType, sheetName string) ([]ProductProbabilities, error)
type SealedContent ¶ added in v0.4.41
type SealedContent struct { Code string `json:"code"` Count int `json:"count"` Foil bool `json:"foil"` Name string `json:"name"` Set string `json:"set"` UUID string `json:"uuid"` // For variable_config Chance int `json:"chance"` Weight int `json:"weight"` // This recursive definition is used for "variable" mode in which one // possible configuration is chosen at random Configs []map[string][]SealedContent `json:"configs"` }
type Set ¶ added in v0.4.41
type Set struct { BaseSetSize int `json:"baseSetSize"` Code string `json:"code"` Cards []Card `json:"cards"` IsFoilOnly bool `json:"isFoilOnly"` IsNonFoilOnly bool `json:"isNonFoilOnly"` IsOnlineOnly bool `json:"isOnlineOnly"` KeyruneCode string `json:"keyruneCode"` Name string `json:"name"` ParentCode string `json:"parentCode"` ReleaseDate string `json:"releaseDate"` Tokens []Card `json:"tokens"` Type string `json:"type"` // List of rarities present in the set Rarities []string // List of card colors present in the set Colors []string Booster map[string]Booster `json:"booster"` SealedProduct []struct { Category string `json:"category"` Contents map[string][]SealedContent `json:"contents"` Identifiers map[string]string `json:"identifiers"` Name string `json:"name"` CardCount int `json:"cardCount"` Subtype string `json:"subtype"` UUID string `json:"uuid"` } `json:"sealedProduct"` Decks []struct { Code string `json:"code"` Bonus []DeckCard `json:"bonus"` Commander []DeckCard `json:"commander"` MainBoard []DeckCard `json:"mainBoard"` SideBoard []DeckCard `json:"sideBoard"` Name string `json:"name"` SealedProductUUIDs []string `json:"sealedProductUuids"` } `json:"decks"` }