Skip to content

Commit

Permalink
arbit: Add an option to skip product with no decklists
Browse files Browse the repository at this point in the history
  • Loading branch information
kodawah committed Nov 25, 2023
1 parent 2e2b673 commit 75da74f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mtgban/arbit.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ type ArbitOpts struct {

// List of per-edition collector numbers to select
OnlyCollectorNumberRanges map[string][2]int

// Only run for products with static decklists
SealedDecklist bool
}

type ArbitEntry struct {
Expand Down Expand Up @@ -109,6 +112,7 @@ func Arbit(opts *ArbitOpts, vendor Vendor, seller Seller) (result []ArbitEntry,
filterFoil := false
filterOnlyFoil := false
filterRLOnly := false
filterDecksOnly := false
var filterConditions []string
var filterRarities []string
var filterEditions []string
Expand All @@ -135,6 +139,7 @@ func Arbit(opts *ArbitOpts, vendor Vendor, seller Seller) (result []ArbitEntry,
filterFoil = opts.NoFoil
filterOnlyFoil = opts.OnlyFoil
filterRLOnly = opts.OnlyReserveList
filterDecksOnly = opts.SealedDecklist

if len(opts.Conditions) != 0 {
filterConditions = opts.Conditions
Expand Down Expand Up @@ -195,6 +200,9 @@ func Arbit(opts *ArbitOpts, vendor Vendor, seller Seller) (result []ArbitEntry,
if filterRLOnly && !co.IsReserved {
continue
}
if filterDecksOnly && co.Sealed && !mtgmatcher.SealedHasDecklist(co.SetCode, cardId) {
continue
}
if slices.Contains(filterEditions, co.Edition) {
continue
}
Expand Down
17 changes: 17 additions & 0 deletions mtgmatcher/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,3 +562,20 @@ func SealedIsRandom(setCode, sealedUUID string) bool {

return false
}

func SealedHasDecklist(setCode, sealedUUID string) bool {
set, err := GetSet(setCode)
if err != nil {
return false
}

for _, product := range set.SealedProduct {
if sealedUUID != product.UUID {
continue
}
_, found := product.Contents["deck"]
return found
}

return false
}

0 comments on commit 75da74f

Please sign in to comment.