Update convertset to add boosted manes
continuous-integration/drone/push Build is failing Details

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"`
ProblemOpponentPower int `json:",omitempty"`
ProblemRequirement jsonPowerRequirement `json:",omitempty"`
Boosted *jsonCard `json:",omitempty"`
}
type jsonPowerRequirement map[string]int
@ -35,6 +36,19 @@ type jsonPowerRequirement map[string]int
func convert(xmlset xmlSet) (s jsonSet) {
s.Name = xmlset.Name
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{
Name: xmlcard.Name,
Keywords: []string{},
@ -180,7 +194,5 @@ func convert(xmlset xmlSet) (s jsonSet) {
}
}
s.Cards = append(s.Cards, jsoncard)
}
return
return jsoncard
}

View File

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