Skip to content

Commit

Permalink
Make sure to set buylist quantity only for NM unless specified
Browse files Browse the repository at this point in the history
  • Loading branch information
kodawah committed May 1, 2024
1 parent c280630 commit 51a6ee7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
7 changes: 6 additions & 1 deletion cardkingdom/cardkingdom.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,16 @@ func (ck *Cardkingdom) scrape() error {
priceRatio = price / sellPrice * 100
}

var quantity int
if grade == "NM" {
quantity = card.BuyQuantity
}

out := &mtgban.BuylistEntry{
Conditions: grade,
BuyPrice: price * factor,
TradePrice: price * factor * 1.3,
Quantity: card.BuyQuantity,
Quantity: quantity,
PriceRatio: priceRatio,
URL: u.String(),
}
Expand Down
7 changes: 6 additions & 1 deletion cardkingdom/hotbuylist.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,17 @@ func (ck *CardkingdomHotBuylist) processPage(channel chan<- respChan) error {
priceRatio = price / sellPrice * 100
}

var quantity int
if grade == "NM" {
quantity = card.BuyQuantity
}

out := respChan{
cardId: cardId,
buyEntry: &mtgban.BuylistEntry{
BuyPrice: price * factor,
TradePrice: price * factor * 1.3,
Quantity: card.BuyQuantity,
Quantity: quantity,
PriceRatio: priceRatio,
},
}
Expand Down
7 changes: 6 additions & 1 deletion magiccorner/magiccorner.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,15 @@ func (mc *Magiccorner) parseBL(channel chan<- resultChan, edition MCExpansion) e
continue
}

var quantity int
if grade == "NM" {
quantity = qty
}

channel <- resultChan{
cardId: cardId,
buyEntry: &mtgban.BuylistEntry{
Quantity: qty,
Quantity: quantity,
Conditions: grade,
BuyPrice: price * mc.exchangeRate * factor,
TradePrice: credit * mc.exchangeRate * factor,
Expand Down
7 changes: 6 additions & 1 deletion mtgseattle/mtgseattle.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ func (ms *MTGSeattle) processProduct(channel chan<- responseChan, product, mode

gradeMap := grading(cardId, price)
for _, grade := range mtgban.DefaultGradeTags {
var quantity int
if grade == "NM" {
quantity = qty
}

factor := gradeMap[grade]
out := responseChan{
cardId: cardId,
Expand All @@ -257,7 +262,7 @@ func (ms *MTGSeattle) processProduct(channel chan<- responseChan, product, mode
BuyPrice: price * factor,
TradePrice: credit * factor,
PriceRatio: priceRatio,
Quantity: qty,
Quantity: quantity,
URL: "https://www.mtgseattle.com" + link,
},
}
Expand Down
7 changes: 6 additions & 1 deletion toamagic/toamagic.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,19 @@ func (toa *TOAMagic) processProduct(channel chan<- responseChan, productPath, mo

deductions := []float64{1, 1, 0.5, 0.3}
for i, deduction := range deductions {
var quantity int
if i == 0 {
quantity = qty
}

out := responseChan{
cardId: cardId,
buyEntry: &mtgban.BuylistEntry{
Conditions: mtgban.DefaultGradeTags[i],
BuyPrice: price * deduction,
TradePrice: credit * deduction,
PriceRatio: priceRatio,
Quantity: qty,
Quantity: quantity,
URL: "https://www.toamagic.com" + link,
},
}
Expand Down

0 comments on commit 51a6ee7

Please sign in to comment.