mtgmatcher

package
v0.0.0-...-1e91090 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 18 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{}/* 455 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 ErrEditionNoBoosterSheet = errors.New("edition has no booster sheet information")
View Source
var ErrEditionNoSealed = errors.New("edition has no sealed information")
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 AllPromoTypes

func AllPromoTypes() []string

func BoosterGen

func BoosterGen(setCode, boosterType string) ([]string, error)

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

func GCD(a, b int) int

Greatest common divisor (GCD) via Euclidean algorithm

func GetAllSets

func GetAllSets() []string

func GetDecklist

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

func GetPicksForDeck

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

func GetPicksForSealed

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

func GetSet

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

func GetSetByName

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

func GetSetUUID

func GetSetUUID(uuid string) (*mtgjson.Set, error)

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

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

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 *Card) (cardId string, err error)

func MatchId

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

func MatchInSet

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

Return an array of mtgjson.Card containing all the cards with the exact same name as the input name in the Set identified by setCode.

func MatchInSetNumber

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

Return an array of mtgjson.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

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

Return an array of mtgjson.Card containing all the cards with the exact set code and collector number, using the name as hint (can be empty)

func NewDatastore

func NewDatastore(ap mtgjson.AllPrintings)

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 SealedContains

func SealedContains(str1, str2 string) bool

func SealedEquals

func SealedEquals(str1, str2 string) bool

func SealedHasDecklist

func SealedHasDecklist(setCode, sealedUUID string) bool

func SealedIsRandom

func SealedIsRandom(setCode, sealedUUID string) bool

func SealedNormalize

func SealedNormalize(str string) string

func SealedWithinSealed

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 SetGlobalLogger

func SetGlobalLogger(userLogger *log.Logger)

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 {
	// contains filtered or unexported fields
}

func (*AliasingError) Error

func (err *AliasingError) Error() string

func (*AliasingError) Probe

func (err *AliasingError) Probe() []string

type Card

type Card 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 (*Card) Contains

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

func (*Card) Equals

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

func (*Card) IsBasicLand

func (c *Card) IsBasicLand() bool

Returns whether the card is a basic land

func (*Card) String

func (c *Card) String() string

Card implements the Stringer interface

type CardObject

type CardObject struct {
	mtgjson.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 ProductProbabilities

type ProductProbabilities struct {
	UUID        string
	Probability float64
}

func GetProbabilitiesForSealed

func GetProbabilitiesForSealed(setCode, sealedUUID string) ([]ProductProbabilities, error)

func SealedBoosterProbabilities

func SealedBoosterProbabilities(setCode, boosterType string) ([]ProductProbabilities, error)

func SealedSheetProbabilities

func SealedSheetProbabilities(setCode, boosterType, sheetName string) ([]ProductProbabilities, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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