Skip to content

Commit

Permalink
add cmc card search feature
Browse files Browse the repository at this point in the history
  • Loading branch information
noqqe committed Jan 30, 2024
1 parent c674e23 commit f2a2b4e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/serra/card.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func init() {
cardCmd.Flags().StringVarP(&set, "set", "e", "", "Filter by set code (usg/mmq/vow)")
cardCmd.Flags().StringVarP(&sortby, "sort", "s", "name", "How to sort cards (value/number/name/added)")
cardCmd.Flags().StringVarP(&name, "name", "n", "", "Name of the card (regex compatible)")
cardCmd.Flags().Int64VarP(&cmc, "cmc", "m", -1, "Cumulative mana cost of card")
cardCmd.Flags().StringVarP(&color, "color", "i", "", "Color identity of card (w,u,b,r,g)")
cardCmd.Flags().StringVarP(&oracle, "oracle", "o", "", "Contains string in card text")
cardCmd.Flags().StringVarP(&cardType, "type", "t", "", "Contains string in card type line")
Expand Down Expand Up @@ -105,6 +106,10 @@ func Cards(rarity, set, sortby, name, oracle, cardType string, reserved, foil bo
filter = append(filter, bson.E{"name", bson.D{{"$regex", ".*" + name + ".*"}, {"$options", "i"}}})
}

if cmc > -1 {
filter = append(filter, bson.E{"cmc", cmc})
}

if len(oracle) > 0 {
filter = append(filter, bson.E{"oracletext", bson.D{{"$regex", ".*" + oracle + ".*"}, {"$options", "i"}}})
}
Expand Down
1 change: 1 addition & 0 deletions src/serra/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var (
address string
cardType string
color string
cmc int64
count int64
detail bool
foil bool
Expand Down

0 comments on commit f2a2b4e

Please sign in to comment.