Skip to content

Commit

Permalink
mtgban/base: Set an optional flag to override card finish for sku
Browse files Browse the repository at this point in the history
IE Useful for when you need the SKU of a foil card but you only
have the nonfoil id.
  • Loading branch information
kodawah committed May 1, 2024
1 parent 9ae82e9 commit ec0ecc6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions mtgban/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"golang.org/x/exp/slices"
)

func ComputeSKU(cardId, condition string) (string, error) {
func ComputeSKU(cardId, condition string, flags ...string) (string, error) {
co, err := mtgmatcher.GetUUID(cardId)
if err != nil {
return "", err
Expand All @@ -35,12 +35,18 @@ func ComputeSKU(cardId, condition string) (string, error) {
}

language := strings.ToLower(co.Language)

overrideFinish := ""
if len(flags) > 0 {
overrideFinish = flags[0]
}

printing := "nonfoil"
if co.Etched {
if co.Etched || overrideFinish == "etched" {
printing = "etched"
} else if co.Foil {
} else if co.Foil || overrideFinish == "foil" {
printing = "foil"
} else if co.Sealed {
} else if co.Sealed || overrideFinish == "sealed" {
printing = "sealed"
}

Expand Down

0 comments on commit ec0ecc6

Please sign in to comment.