Add price lists capability for foils

This commit is contained in:
Florian Baumann 2023-04-20 12:05:14 +02:00
parent e0d90ae12d
commit 2ed9467f6a
4 changed files with 18 additions and 8 deletions

View File

@ -152,7 +152,7 @@ func show_card_details(card *Card) error {
} }
fmt.Printf("\n%sHistory%s\n", Green, Reset) fmt.Printf("\n%sHistory%s\n", Green, Reset)
print_price_history(card.SerraPrices, "* ") print_price_history(card.SerraPrices, "* ", false)
fmt.Println() fmt.Println()
return nil return nil
} }

View File

@ -163,14 +163,22 @@ func convert_rarities(rar []primitive.M) Rarities {
} }
func print_price_history(prices []PriceEntry, prefix string) { func print_price_history(prices []PriceEntry, prefix string, total bool) {
var before float64 var before float64
for _, e := range prices { for _, e := range prices {
value := e.Usd var value float64
if getCurrency() == "EUR" { if total {
value = e.Eur value = e.Usd + e.UsdFoil + e.UsdEtched
if getCurrency() == "EUR" {
value = e.Eur + e.EurFoil
}
} else {
value = e.Usd
if getCurrency() == "EUR" {
value = e.Eur
}
} }
if value > before && before != 0 { if value > before && before != 0 {

View File

@ -162,7 +162,7 @@ func ShowSet(setname string) error {
LogMessage(fmt.Sprintf("Uncommons: %.0f", ri.Uncommons), "normal") LogMessage(fmt.Sprintf("Uncommons: %.0f", ri.Uncommons), "normal")
LogMessage(fmt.Sprintf("Commons: %.0f", ri.Commons), "normal") LogMessage(fmt.Sprintf("Commons: %.0f", ri.Commons), "normal")
fmt.Printf("\n%sPrice History:%s\n", Pink, Reset) fmt.Printf("\n%sPrice History:%s\n", Pink, Reset)
print_price_history(sets[0].SerraPrices, "* ") print_price_history(sets[0].SerraPrices, "* ", true)
fmt.Printf("\n%sMost valuable cards%s\n", Pink, Reset) fmt.Printf("\n%sMost valuable cards%s\n", Pink, Reset)

View File

@ -120,11 +120,13 @@ var statsCmd = &cobra.Command{
foil_value = 0 foil_value = 0
} }
total_value := nf_value + foil_value total_value := nf_value + foil_value
fmt.Printf("Current: %s%.2f %s%s\n", Pink, total_value, getCurrency(), Reset) fmt.Printf("Total: %s%.2f %s%s\n", Pink, total_value, getCurrency(), Reset)
fmt.Printf("Normal: %s%.2f %s%s\n", Pink, nf_value, getCurrency(), Reset)
fmt.Printf("Foils: %s%.2f %s%s\n", Pink, foil_value, getCurrency(), Reset)
total, _ := totalcoll.storage_find_total() total, _ := totalcoll.storage_find_total()
fmt.Printf("History: \n") fmt.Printf("History: \n")
print_price_history(total.Value, "* ") print_price_history(total.Value, "* ", true)
return nil return nil
}, },
} }