Documentation ¶
Overview ¶
Package carddb provides functions to interact with a Magic The Gathering Arena cards. To use this library, you need a mtg arena installation, or at least the card assets that are typically stored in the MTGA_Data\Downloads\Data folder inside the MTGA installation directory.
Index ¶
Constants ¶
const ( // MythicRarity is the rarity constant for Mythic cards MythicRarity = 5 // RareRarity is the rarity constant for Rare cards RareRarity = 4 // UncommonRarity is the rarity constant for Uncommon cards UncommonRarity = 3 // CommonRarity is the rarity constant for Common cards CommonRarity = 2 // BasicLandRarity is the rarity constant for Basic Lands BasicLandRarity = 1 // TokenRarity is the rarity constant for for Token cards TokenRarity = 0 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Card ¶
Card represents an Magic The Gathering: Arena card. It comes with the name and with the JSON representation of the card.
type CardDB ¶
type CardDB interface { // Returns all the cards with the given name. GetCard(name string) []*Card // Returns the card with the given ID, nil if it doesn't exist. GetCardByID(id uint64) *Card // ForEach runs f over each card in the database ForEach(f func(Card)) // Returns all the cards that match the given predicate Filter(predicate func(Card) bool) []Card }
CardDB lets you interact with a Magic The Gathering: Arena card database.
func CreateLibrary ¶
CreateLibrary is a helper function for NewLibrary, it takes the Data path inside the MTG installation directory, and tries to find the required resource files for creating the database.
func NewLibrary ¶
NewLibrary creates a new database of magic cards. It needs to use the files that are used by MTG Arena that describes the cards in JSON format. They are commonly named data_cards_<hash> and data_loc_<hash> The language is the iso-code for the language on the card names that you would like (probably "en-US").
type CardJSON ¶
type CardJSON struct { ID uint64 `json:"grpid"` TitleID uint64 `json:"titleId"` CollectorNumber string `json:"CollectorNumber"` Set string `json:"set"` Rarity uint64 `json:"rarity"` ColorIdentity []uint64 `json:"colorIdentity"` CastingCost string `json:"castingcost"` Types []uint64 `json:"types"` Subtypes []uint64 `json:"subtypes"` Supertypes []uint64 `json:"supertypes"` CardTypeTextID uint64 `json:"cardTypeTextId"` SubtypeTextID uint64 `json:"subtypeTextId"` }
CardJSON is the JSON representation of a card, as it appears in the MTGA Resource files.