Update convertset to add boosted manes
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Hamcha 2019-08-27 11:59:07 +02:00
parent 643a86a604
commit a3db545be3
2 changed files with 155 additions and 142 deletions

View file

@ -28,6 +28,7 @@ type jsonCard struct {
ProblemBonus *int `json:",omitempty"` ProblemBonus *int `json:",omitempty"`
ProblemOpponentPower int `json:",omitempty"` ProblemOpponentPower int `json:",omitempty"`
ProblemRequirement jsonPowerRequirement `json:",omitempty"` ProblemRequirement jsonPowerRequirement `json:",omitempty"`
Boosted *jsonCard `json:",omitempty"`
} }
type jsonPowerRequirement map[string]int type jsonPowerRequirement map[string]int
@ -35,6 +36,19 @@ type jsonPowerRequirement map[string]int
func convert(xmlset xmlSet) (s jsonSet) { func convert(xmlset xmlSet) (s jsonSet) {
s.Name = xmlset.Name s.Name = xmlset.Name
for _, xmlcard := range xmlset.Cards { for _, xmlcard := range xmlset.Cards {
jsoncard := decodeCard(xmlcard)
if jsoncard.Type == "Mane Character" && xmlcard.Alternate != nil {
boosted := decodeCard(*xmlcard.Alternate)
jsoncard.Boosted = &boosted
}
s.Cards = append(s.Cards, jsoncard)
}
return
}
func decodeCard(xmlcard xmlCard) jsonCard {
jsoncard := jsonCard{ jsoncard := jsonCard{
Name: xmlcard.Name, Name: xmlcard.Name,
Keywords: []string{}, Keywords: []string{},
@ -180,7 +194,5 @@ func convert(xmlset xmlSet) (s jsonSet) {
} }
} }
s.Cards = append(s.Cards, jsoncard) return jsoncard
}
return
} }

View file

@ -16,6 +16,7 @@ type xmlCard struct {
ID string `xml:"id,attr"` ID string `xml:"id,attr"`
Name string `xml:"name,attr"` Name string `xml:"name,attr"`
Properties []xmlProperty `xml:"property"` Properties []xmlProperty `xml:"property"`
Alternate *xmlCard `xml:"alternate"`
} }
type xmlProperty struct { type xmlProperty struct {