Colored price history in card and set view

This commit is contained in:
Florian Baumann 2022-01-11 09:03:23 +01:00
parent 438d348483
commit 406a252d01
2 changed files with 19 additions and 2 deletions

View File

@ -73,9 +73,17 @@ func show_card_details(card *Card) error {
fmt.Printf(" Scryfall: %s\n", strings.Replace(card.ScryfallURI, "?utm_source=api", "", 1)) fmt.Printf(" Scryfall: %s\n", strings.Replace(card.ScryfallURI, "?utm_source=api", "", 1))
fmt.Printf(" Current Value: %s%.2f EUR%s\n", Yellow, card.Prices.Eur, Reset) fmt.Printf(" Current Value: %s%.2f EUR%s\n", Yellow, card.Prices.Eur, Reset)
fmt.Printf(" History:\n") fmt.Printf(" History:\n")
var before float64
for _, e := range card.SerraPrices { for _, e := range card.SerraPrices {
if e.Value > before {
fmt.Printf(" * %s %s%.2f EUR%s\n", stringToTime(e.Date), Green, e.Value, Reset)
} else if e.Value < before {
fmt.Printf(" * %s %s%.2f EUR%s\n", stringToTime(e.Date), Red, e.Value, Reset)
} else {
fmt.Printf(" * %s %.2f EUR\n", stringToTime(e.Date), e.Value) fmt.Printf(" * %s %.2f EUR\n", stringToTime(e.Date), e.Value)
} }
before = e.Value
}
fmt.Println() fmt.Println()
return nil return nil
} }

View File

@ -289,8 +289,17 @@ func ShowSet(setname string) error {
LogMessage(fmt.Sprintf("Uncommons: %.0f", uncommons), "normal") LogMessage(fmt.Sprintf("Uncommons: %.0f", uncommons), "normal")
LogMessage(fmt.Sprintf("Commons: %.0f", commons), "normal") LogMessage(fmt.Sprintf("Commons: %.0f", commons), "normal")
fmt.Printf("\n%sPrice History:%s\n", Pink, Reset) fmt.Printf("\n%sPrice History:%s\n", Pink, Reset)
var before float64
for _, e := range sets[0].SerraPrices { for _, e := range sets[0].SerraPrices {
fmt.Printf("* %s %.2f EUR\n", stringToTime(e.Date), e.Value) if e.Value > before {
fmt.Printf("* %s %s%.2f EUR%s\n", stringToTime(e.Date), Green, e.Value, Reset)
} else if e.Value < before {
fmt.Printf("* %s %s%.2f EUR%s\n", stringToTime(e.Date), Red, e.Value, Reset)
} else {
fmt.Printf("* %s %.2f EUR%s\n", stringToTime(e.Date), e.Value)
}
before = e.Value
} }
fmt.Printf("\n%sMost valuable cards%s\n", Pink, Reset) fmt.Printf("\n%sMost valuable cards%s\n", Pink, Reset)