color distribution in emojis

This commit is contained in:
Florian Baumann 2022-01-07 15:26:54 +01:00
parent a4acaf3728
commit ff82c718f2
2 changed files with 49 additions and 4 deletions

View File

@ -64,3 +64,28 @@ func show_card_details(card *Card) error {
fmt.Println() fmt.Println()
return nil return nil
} }
func convert_mana_symbols(sym []interface{}) string {
var mana string
if len(sym) == 0 {
mana = mana + "\U0001F6AB" //probibited sign for lands
}
for _, v := range sym {
switch v {
case "B":
mana = mana + "\U000026AB" //black
case "R":
mana = mana + "\U0001F534" //red
case "G":
mana = mana + "\U0001F7E2" //green
case "U":
mana = mana + "\U0001F535" //blue
case "W":
mana = mana + "\U000026AA" //white
}
}
return mana
}

View File

@ -237,15 +237,35 @@ func Stats() {
groupStage := bson.D{ groupStage := bson.D{
{"$group", bson.D{ {"$group", bson.D{
{"_id", "$coloridentity"}, {"_id", "$coloridentity"},
{"count", bson.D{{"$sum", 1}}}, {"count", bson.D{{"$sum", bson.D{{"$multiply", bson.A{1.0, "$serra_count"}}}}}},
}}} }}}
sets, _ := coll.storage_aggregate(mongo.Pipeline{groupStage}) sortStage := bson.D{
{"$sort", bson.D{
{"count", -1},
}}}
sets, _ := coll.storage_aggregate(mongo.Pipeline{groupStage, sortStage})
for _, set := range sets { for _, set := range sets {
// TODO fix primitiveA Problem with loop and reflect x, _ := set["_id"].(primitive.A)
fmt.Printf("* %s %d\n", set["_id"], set["count"]) s := []interface{}(x)
fmt.Printf("* %s %.0f\n", convert_mana_symbols(s), set["count"])
} }
statsGroup := bson.D{
{"$group", bson.D{
{"_id", nil},
{"value", bson.D{{"$sum", bson.D{{"$multiply", bson.A{"$prices.eur", "$serra_count"}}}}}},
{"count", bson.D{{"$sum", bson.D{{"$multiply", bson.A{1.0, "$serra_count"}}}}}},
{"unique", bson.D{{"$sum", 1}}},
}},
}
stats, _ := coll.storage_aggregate(mongo.Pipeline{statsGroup})
fmt.Printf("\n%sOverall %s\n", Green, Reset)
fmt.Printf("Total Cards: %s%.0f%s\n", Yellow, stats[0]["count"], Reset)
fmt.Printf("Unique Cards: %s%d%s\n", Purple, stats[0]["unique"], Reset)
fmt.Printf("Total Value: %s%.2f%s\n", Pink, stats[0]["value"], Reset)
// LogMessage(fmt.Sprintf("Mana costs in Collection"), "green") // LogMessage(fmt.Sprintf("Mana costs in Collection"), "green")
// groupStage = bson.D{ // groupStage = bson.D{
// {"$group", bson.D{ // {"$group", bson.D{