Documentation
¶
Index ¶
Constants ¶
const ( FieldScryfallId = "scryfall_id" FieldOracleId = "oracle_id" FieldName = "name" FieldImageUri = "image_uri" FieldManaCost = "mana_cost" FieldCmc = "cmc" FieldTypeLine = "type_line" FieldOracleText = "oracle_text" FieldColors = "colors" FieldColorIdentity = "color_identity" FieldRarity = "rarity" FieldSetCode = "set_code" FieldSetName = "set_name" FieldLang = "lang" FieldArtist = "artist" FieldReleasedAt = "released_at" TableCards = "cards" TableCardFaces = "card_faces" )
Variables ¶
var SqlCardSelectFields = []string{ FieldScryfallId, FieldOracleId, FieldName, FieldImageUri, FieldManaCost, FieldCmc, FieldTypeLine, FieldOracleText, FieldColors, FieldColorIdentity, FieldRarity, FieldSetCode, FieldSetName, FieldLang, FieldArtist, FieldReleasedAt, }
Fields for a SELECT statement used for unmarshalling into Card struct
Functions ¶
func CardColorArr2Str ¶
func CardColorStr2Arr ¶
helper to convert colors of db into an array
Types ¶
type Card ¶
type Card struct {
ScryfallId string `json:"scryfall_id"`
OracleId string `json:"oracle_id"`
Name string `json:"name"`
ImageUri string `json:"image_uri"`
ManaCost string `json:"mana_cost"` // {2}{B}{W}
Cmc float64 `json:"cmc"`
TypeLine string `json:"type_line"`
OracleText string `json:"oracle_text"`
Colors []string `json:"colors"`
ColorIdentity []string `json:"color_identity"`
Rarity string `json:"rarity"`
SetCode string `json:"set_code"`
SetName string `json:"set_name"`
Lang string `json:"lang"`
Artist string `json:"artist"`
ReleasedAt string `json:"released_at"`
// When a card has multiple faces
CardFaces []*CardFace `json:"card_faces"`
}
Card represents a single card
type CardCollection ¶
type CardCollection struct {
// contains filtered or unexported fields
}
CardCollection is a list of card pointers
func (*CardCollection) Add ¶
func (cc *CardCollection) Add(c *Card)
func (*CardCollection) List ¶
func (cc *CardCollection) List() []*Card
func (*CardCollection) Size ¶
func (cc *CardCollection) Size() int
type CardDb ¶
type CardDb struct {
// contains filtered or unexported fields
}
func NewCardDb ¶
NewCardDb opens the sqlite3 file and updates the flag if fields are already filled.
func (*CardDb) CreateQuery ¶
func (cdb *CardDb) CreateQuery(opt QueryOptions) *CardQuery
CreateQuery creates a database query with options.
func (*CardDb) Image ¶
Image returns the first image for a card. Downloads it when not in resources. For multiface cards return first image.
type CardFace ¶
type CardFace struct {
Colors []string `json:"colors"`
ImageUri string `json:"image_uri"`
ManaCost string `json:"mana_cost"`
Name string `json:"name"`
TypeLine string `json:"type_line"`
OracleText string `json:"oracle_text"`
Artist string `json:"artist"`
}
CardFace represents a face of a multiface card
type CardQuery ¶
type CardQuery struct {
// contains filtered or unexported fields
}
CardQuery holds some query attributes for a simpler card query
func (*CardQuery) Exec ¶
func (q *CardQuery) Exec(args ...interface{}) (*CardCollection, error)
Exec builds the SQL query and executes it with args. Attributes of CardQuery should not contain user input values. These should be done with "?" and args.
func (*CardQuery) ExecSingle ¶
ExecSingle executes the query and returns only the first card