From 2ed9467f6ad9d7c0d3720958c58e5d4800605727 Mon Sep 17 00:00:00 2001 From: Florian Baumann Date: Thu, 20 Apr 2023 12:05:14 +0200 Subject: [PATCH] Add price lists capability for foils --- src/serra/card.go | 2 +- src/serra/helpers.go | 16 ++++++++++++---- src/serra/set.go | 2 +- src/serra/stats.go | 6 ++++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/serra/card.go b/src/serra/card.go index d179f8c..690c8ea 100644 --- a/src/serra/card.go +++ b/src/serra/card.go @@ -152,7 +152,7 @@ func show_card_details(card *Card) error { } fmt.Printf("\n%sHistory%s\n", Green, Reset) - print_price_history(card.SerraPrices, "* ") + print_price_history(card.SerraPrices, "* ", false) fmt.Println() return nil } diff --git a/src/serra/helpers.go b/src/serra/helpers.go index ba427cb..9c7b477 100644 --- a/src/serra/helpers.go +++ b/src/serra/helpers.go @@ -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 for _, e := range prices { - value := e.Usd - if getCurrency() == "EUR" { - value = e.Eur + var value float64 + if total { + 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 { diff --git a/src/serra/set.go b/src/serra/set.go index 50e889b..3ad032b 100644 --- a/src/serra/set.go +++ b/src/serra/set.go @@ -162,7 +162,7 @@ func ShowSet(setname string) error { LogMessage(fmt.Sprintf("Uncommons: %.0f", ri.Uncommons), "normal") LogMessage(fmt.Sprintf("Commons: %.0f", ri.Commons), "normal") 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) diff --git a/src/serra/stats.go b/src/serra/stats.go index 116e6e2..61e0581 100644 --- a/src/serra/stats.go +++ b/src/serra/stats.go @@ -120,11 +120,13 @@ var statsCmd = &cobra.Command{ foil_value = 0 } 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() fmt.Printf("History: \n") - print_price_history(total.Value, "* ") + print_price_history(total.Value, "* ", true) return nil }, }