mlp-server-tools/tools/buildmap/cardmap.go

39 lines
742 B
Go

package main
import (
"log"
"strings"
)
// GUID to Card ID map (or viceversa)
type cardMap map[string]string
func buildMap(sets []xmlSet, reverse, tolc bool) cardMap {
cdb := make(cardMap)
for _, set := range sets {
log.Printf("Generating card map for \"%s\"...\n", set.Name)
for _, card := range set.Cards {
// Find card number
number := ""
for _, prop := range card.Properties {
if prop.Name == "Number" {
number = prop.Value
break
}
}
if number == "" {
continue
}
if tolc {
number = strings.ToLower(number)
}
if reverse {
cdb[number] = card.ID
} else {
cdb[card.ID] = number
}
}
}
log.Printf("Generated card map (%d cards total)\n", len(cdb))
return cdb
}