mtgmatcher

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2025 License: MIT Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const LongestCardEver = "" /* 141-byte string literal not displayed */
View Source
const NightmareCard = "The Ultimate Nightmare of Wizards of the Coast® Customer Service"

Variables

View Source
var ARNGuilds = []string{"Azorius", "Gruul", "Orzhov", "Rakdos", "Simic"}

Guilds found in ARN

View Source
var BuyABoxInExpansionSetsDate = time.Date(2018, time.April, 1, 0, 0, 0, 0, time.UTC)

Date since BuyABox cards are found in the expansion set instead of Promos

View Source
var BuyABoxNotUniqueDate = time.Date(2020, time.September, 1, 0, 0, 0, 0, time.UTC)

Date since BuyABox cards are not unique any more

View Source
var EditionTable = map[string]string{}/* 477 elements not displayed */
View Source
var ErrAliasing = NewAliasingError()
View Source
var ErrCardDoesNotExist = errors.New("unknown card name")
View Source
var ErrCardMissingVariant = errors.New("missing necessary variant")
View Source
var ErrCardNotInEdition = errors.New("unknown edition")
View Source
var ErrCardUnknownId = errors.New("unknown id")
View Source
var ErrCardWrongVariant = errors.New("unknown variant")
View Source
var ErrDatastoreEmpty = errors.New("datastore is empty")
View Source
var ErrUnsupported = errors.New("unsupported")
View Source
var GRNGuilds = []string{"Boros", "Dimir", "Golgari", "Izzet", "Selesnya"}

Guilds found in GRN

View Source
var NewPrereleaseDate = time.Date(2014, time.September, 1, 0, 0, 0, 0, time.UTC)

Date since any card could be Prerelease Promo

View Source
var PromosForEverybodyYay = time.Date(2019, time.October, 1, 0, 0, 0, 0, time.UTC)

Date in which random promos can be in the expansion set

View Source
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

View Source
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

func AllNames(variant string, sealed bool) []string

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 BoosterGen(setCode, boosterType string) ([]string, error)

func BuildSealedProductMap added in v0.4.27

func BuildSealedProductMap(idName string) map[int][]string

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 Contains

func Contains(str1, str2 string) bool

Check if str1 contains str2 after both are Normalize-d.

func Cut

func Cut(in, tag string) []string

Cut splits the input string in two segments, stripping any whitespace before or after the cut, if present.

func Equals

func Equals(str1, str2 string) bool

Compare strings after both are Normalize-d.

func ExtractNumber

func ExtractNumber(str string) string

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

func ExtractNumericalValue(str string) string

Obtain the numerical value of the input so that it can be used for strconv.Atoi()

func ExtractYear

func ExtractYear(str string) string

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 GCD added in v0.4.10

func GCD(a, b int) int

Greatest common divisor (GCD) via Euclidean algorithm

func GetAllSets added in v0.4.23

func GetAllSets() []string

func GetDecklist added in v0.4.8

func GetDecklist(setCode, sealedUUID string) ([]string, error)

func GetPicksForDeck added in v0.3.25

func GetPicksForDeck(setCode, deckName string) ([]string, error)

func GetPicksForSealed added in v0.3.25

func GetPicksForSealed(setCode, sealedUUID string) ([]string, error)

func GetSealedUUIDs added in v0.4.25

func GetSealedUUIDs() []string

func GetUUIDs

func GetUUIDs() []string

func HasBorderlessPrinting

func HasBorderlessPrinting(name string, editions ...string) bool

func HasEtchedPrinting

func HasEtchedPrinting(name string, editions ...string) bool

func HasExtendedArtPrinting

func HasExtendedArtPrinting(name string, editions ...string) bool

func HasFoilPrinting

func HasFoilPrinting(name string, editions ...string) bool

func HasNonfoilPrinting

func HasNonfoilPrinting(name string, editions ...string) bool

func HasPrefix

func HasPrefix(str1, str2 string) bool

Check if str2 is the prefix of str1 after both are Normalize-d.

func HasPrereleasePrinting

func HasPrereleasePrinting(name string, editions ...string) bool

func HasPromoPackPrinting

func HasPromoPackPrinting(name string, editions ...string) bool

func HasReskinPrinting

func HasReskinPrinting(name string, editions ...string) bool

func HasRetroFramePrinting

func HasRetroFramePrinting(name string, editions ...string) bool

func HasSerializedPrinting added in v0.4.3

func HasSerializedPrinting(name string, editions ...string) bool

func HasShowcasePrinting

func HasShowcasePrinting(name string, editions ...string) bool

func HasSuffix

func HasSuffix(str1, str2 string) bool

Check if str2 is the suffix of str1 after both are Normalize-d.

func IsBasicLand

func IsBasicLand(name string) bool

Returns whether the input string may represent a basic land

func IsToken

func IsToken(name string) bool

Returns whether the input string may represent a token

func LCM added in v0.4.10

func LCM(a, b int) int

Find Least Common Multiple (LCM) via GCD

func LoadDatastore

func LoadDatastore(reader io.Reader) error

func LoadDatastoreFile

func LoadDatastoreFile(filename string) error

func Match

func Match(inCard *InputCard) (cardId string, err error)

func MatchId

func MatchId(inputId string, finishes ...bool) (string, error)

func Normalize

func Normalize(str string) string

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 ParseCommanderEdition(edition, variant string) string

func ParsePrice

func ParsePrice(priceStr string) (float64, error)

Strip input string of dollar sign and commas, convert it to a normal float

func Printings4Card

func Printings4Card(name string) ([]string, error)

func Scryfall2UUID

func Scryfall2UUID(id string) string

func SealedCardUnit added in v0.4.61

func SealedCardUnit(setCode, sealedUUID string) int

func SealedHasDecklist added in v0.3.42

func SealedHasDecklist(setCode, sealedUUID string) bool

func SealedIsRandom added in v0.3.33

func SealedIsRandom(setCode, sealedUUID string) bool

func SealedWithinSealed added in v0.3.29

func SealedWithinSealed(setCode, sealedUUID string) []string

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 SearchContains(name string) ([]string, error)

func SearchEquals

func SearchEquals(name string) ([]string, error)

func SearchHasPrefix

func SearchHasPrefix(name string) ([]string, error)

func SearchRegexp

func SearchRegexp(name string) ([]string, error)

func SearchSealedContains

func SearchSealedContains(name string) ([]string, error)

func SearchSealedEquals

func SearchSealedEquals(name string) ([]string, error)

func SetGlobalDatastore added in v0.4.41

func SetGlobalDatastore(datastore cardBackend)

func SetGlobalLogger

func SetGlobalLogger(userLogger *log.Logger)

func SimpleSearch added in v0.4.43

func SimpleSearch(cardName, number string, foil bool) (string, error)

func SplitVariants

func SplitVariants(str string) []string

SplitVariants returns an array of strings from the parentheses-defined fields commonly used to distinguish some cards across editions.

func Tcg2UUID

func Tcg2UUID(id string) string

func Title

func Title(str string) string

Wrapper for the deprecated strings.Title abc -> Abc ABC -> Abc

Types

type AliasingError

type AliasingError struct {
	Message string
	Dupes   []string
}

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 Booster added in v0.4.41

type Booster struct {
	Boosters []struct {
		Contents map[string]int `json:"contents"`
		Weight   int            `json:"weight"`
	} `json:"boosters"`
	BoostersTotalWeight int              `json:"boostersTotalWeight"`
	Sheets              map[string]Sheet `json:"sheets"`
	Name                string           `json:"name"`
}

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

func MatchInSet(cardName string, setCode string) (outCards []Card)

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

func MatchInSetNumber(cardName, setCode, number string) (outCards []Card)

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

func MatchWithNumber(cardName, setCode, number string) (outCards []Card)

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) HasFinish added in v0.4.41

func (c *Card) HasFinish(fi string) bool

func (*Card) HasFrameEffect added in v0.4.41

func (c *Card) HasFrameEffect(fe string) bool

func (*Card) HasPromoType added in v0.4.41

func (c *Card) HasPromoType(pt string) bool

func (*Card) IsDFCSameName added in v0.4.41

func (c *Card) IsDFCSameName() bool

Check if a dual-faced card has the same for both faces

func (Card) String

func (c Card) String() string

Card implements the Stringer interface

type CardObject

type CardObject struct {
	Card
	Edition string
	Foil    bool
	Etched  bool
	Sealed  bool
}

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 DataStore added in v0.4.41

type DataStore interface {
	Load() cardBackend
}

func LoadAllPrintings added in v0.4.41

func LoadAllPrintings(r io.Reader) (DataStore, error)

func LoadLorcana added in v0.4.41

func LoadLorcana(r io.Reader) (DataStore, error)

type DeckCard added in v0.4.41

type DeckCard struct {
	Count  int    `json:"count"`
	IsFoil bool   `json:"isFoil"`
	UUID   string `json:"uuid"`
}

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) Contains added in v0.4.41

func (c *InputCard) Contains(prop string) bool

func (*InputCard) Equals added in v0.4.41

func (c *InputCard) Equals(prop string) bool

func (*InputCard) IsBasicLand added in v0.4.41

func (c *InputCard) IsBasicLand() bool

Returns whether the card is a basic land

func (*InputCard) String added in v0.4.41

func (c *InputCard) String() string

Card implements the Stringer interface

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

type ProductProbabilities struct {
	UUID        string
	Probability float64
}

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"`
}

func GetSet

func GetSet(code string) (*Set, error)

func GetSetByName

func GetSetByName(edition string, flags ...bool) (*Set, error)

type Sheet added in v0.4.41

type Sheet struct {
	AllowDuplicates bool           `json:"allowDuplicates"`
	BalanceColors   bool           `json:"balanceColors"`
	Cards           map[string]int `json:"cards"`
	Fixed           bool           `json:"fixed"`
	Foil            bool           `json:"foil"`
	TotalWeight     int            `json:"totalWeight"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL