Update convertset to add boosted manes
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
643a86a604
commit
a3db545be3
2 changed files with 155 additions and 142 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue