prevent errors on unknown events - generator - fixes #13
This commit is contained in:
parent
bd631ebff9
commit
5120a19a28
|
@ -1,2 +1,5 @@
|
||||||
gen:
|
gen:
|
||||||
go run analyze.go -g=true
|
go run analyze.go -g=true
|
||||||
|
|
||||||
|
analyze:
|
||||||
|
go run analyze.go -l -a /workspaces/LegendsBrowser2/inputs4
|
|
@ -4281,6 +4281,7 @@
|
||||||
"Base": true,
|
"Base": true,
|
||||||
"Plus": false,
|
"Plus": false,
|
||||||
"Values": {
|
"Values": {
|
||||||
|
"as a symbol of everlasting peace": true,
|
||||||
"part of trade negotiation": true
|
"part of trade negotiation": true
|
||||||
},
|
},
|
||||||
"Enum": true
|
"Enum": true
|
||||||
|
@ -12296,7 +12297,8 @@
|
||||||
"Values": {
|
"Values": {
|
||||||
"Autumn": true,
|
"Autumn": true,
|
||||||
"Spring": true,
|
"Spring": true,
|
||||||
"Summer": true
|
"Summer": true,
|
||||||
|
"Winter": true
|
||||||
},
|
},
|
||||||
"Enum": true
|
"Enum": true
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,9 +21,14 @@ func enumValue(s string) string {
|
||||||
}
|
}
|
||||||
func enumString(s string) string { return strcase.ToDelimited(s, ' ') }
|
func enumString(s string) string { return strcase.ToDelimited(s, ' ') }
|
||||||
|
|
||||||
|
func startswith(str, prefix string) bool {
|
||||||
|
return strings.HasPrefix(str, prefix)
|
||||||
|
}
|
||||||
|
|
||||||
var backendTemplate = template.Must(template.New("").Funcs(template.FuncMap{
|
var backendTemplate = template.Must(template.New("").Funcs(template.FuncMap{
|
||||||
"enum": enumValue,
|
"enum": enumValue,
|
||||||
"enumString": enumString,
|
"enumString": enumString,
|
||||||
|
"startswith": startswith,
|
||||||
}).Parse(`// Code generated by legendsbrowser; DO NOT EDIT.
|
}).Parse(`// Code generated by legendsbrowser; DO NOT EDIT.
|
||||||
package model
|
package model
|
||||||
|
|
||||||
|
@ -234,7 +239,9 @@ func parse{{ $obj.Name }}{{ if $plus }}Plus{{ end }}(p *util.XMLParser{{ if $plu
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
default:
|
default:
|
||||||
|
{{- if not (startswith $obj.Name "HistoricalEventCollection") }}
|
||||||
obj.Details = NewHistoricalEventUnknown(string(data))
|
obj.Details = NewHistoricalEventUnknown(string(data))
|
||||||
|
{{- end }}
|
||||||
p.Skip()
|
p.Skip()
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -4431,11 +4431,14 @@ type HistoricalEventArtifactGivenReason int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
HistoricalEventArtifactGivenReason_Unknown HistoricalEventArtifactGivenReason = iota
|
HistoricalEventArtifactGivenReason_Unknown HistoricalEventArtifactGivenReason = iota
|
||||||
|
HistoricalEventArtifactGivenReason_AsASymbolOfEverlastingPeace
|
||||||
HistoricalEventArtifactGivenReason_PartOfTradeNegotiation
|
HistoricalEventArtifactGivenReason_PartOfTradeNegotiation
|
||||||
)
|
)
|
||||||
|
|
||||||
func parseHistoricalEventArtifactGivenReason(s string) HistoricalEventArtifactGivenReason {
|
func parseHistoricalEventArtifactGivenReason(s string) HistoricalEventArtifactGivenReason {
|
||||||
switch s {
|
switch s {
|
||||||
|
case "as a symbol of everlasting peace":
|
||||||
|
return HistoricalEventArtifactGivenReason_AsASymbolOfEverlastingPeace
|
||||||
case "part of trade negotiation":
|
case "part of trade negotiation":
|
||||||
return HistoricalEventArtifactGivenReason_PartOfTradeNegotiation
|
return HistoricalEventArtifactGivenReason_PartOfTradeNegotiation
|
||||||
}
|
}
|
||||||
|
@ -4444,6 +4447,8 @@ func parseHistoricalEventArtifactGivenReason(s string) HistoricalEventArtifactGi
|
||||||
|
|
||||||
func (s HistoricalEventArtifactGivenReason) String() string {
|
func (s HistoricalEventArtifactGivenReason) String() string {
|
||||||
switch s {
|
switch s {
|
||||||
|
case HistoricalEventArtifactGivenReason_AsASymbolOfEverlastingPeace:
|
||||||
|
return "as a symbol of everlasting peace"
|
||||||
case HistoricalEventArtifactGivenReason_PartOfTradeNegotiation:
|
case HistoricalEventArtifactGivenReason_PartOfTradeNegotiation:
|
||||||
return "part of trade negotiation"
|
return "part of trade negotiation"
|
||||||
}
|
}
|
||||||
|
@ -18617,6 +18622,7 @@ const (
|
||||||
HistoricalEventSiteTributeForcedSeason_Autumn
|
HistoricalEventSiteTributeForcedSeason_Autumn
|
||||||
HistoricalEventSiteTributeForcedSeason_Spring
|
HistoricalEventSiteTributeForcedSeason_Spring
|
||||||
HistoricalEventSiteTributeForcedSeason_Summer
|
HistoricalEventSiteTributeForcedSeason_Summer
|
||||||
|
HistoricalEventSiteTributeForcedSeason_Winter
|
||||||
)
|
)
|
||||||
|
|
||||||
func parseHistoricalEventSiteTributeForcedSeason(s string) HistoricalEventSiteTributeForcedSeason {
|
func parseHistoricalEventSiteTributeForcedSeason(s string) HistoricalEventSiteTributeForcedSeason {
|
||||||
|
@ -18627,6 +18633,8 @@ func parseHistoricalEventSiteTributeForcedSeason(s string) HistoricalEventSiteTr
|
||||||
return HistoricalEventSiteTributeForcedSeason_Spring
|
return HistoricalEventSiteTributeForcedSeason_Spring
|
||||||
case "Summer":
|
case "Summer":
|
||||||
return HistoricalEventSiteTributeForcedSeason_Summer
|
return HistoricalEventSiteTributeForcedSeason_Summer
|
||||||
|
case "Winter":
|
||||||
|
return HistoricalEventSiteTributeForcedSeason_Winter
|
||||||
}
|
}
|
||||||
return HistoricalEventSiteTributeForcedSeason_Unknown
|
return HistoricalEventSiteTributeForcedSeason_Unknown
|
||||||
}
|
}
|
||||||
|
@ -18639,6 +18647,8 @@ func (s HistoricalEventSiteTributeForcedSeason) String() string {
|
||||||
return "spring"
|
return "spring"
|
||||||
case HistoricalEventSiteTributeForcedSeason_Summer:
|
case HistoricalEventSiteTributeForcedSeason_Summer:
|
||||||
return "summer"
|
return "summer"
|
||||||
|
case HistoricalEventSiteTributeForcedSeason_Winter:
|
||||||
|
return "winter"
|
||||||
}
|
}
|
||||||
return "unknown"
|
return "unknown"
|
||||||
}
|
}
|
||||||
|
@ -25187,7 +25197,6 @@ func parseHistoricalEvent(p *util.XMLParser) (*HistoricalEvent, error) {
|
||||||
case "written content composed":
|
case "written content composed":
|
||||||
obj.Details, err = parseHistoricalEventWrittenContentComposed(p)
|
obj.Details, err = parseHistoricalEventWrittenContentComposed(p)
|
||||||
default:
|
default:
|
||||||
|
|
||||||
obj.Details = NewHistoricalEventUnknown(string(data))
|
obj.Details = NewHistoricalEventUnknown(string(data))
|
||||||
p.Skip()
|
p.Skip()
|
||||||
}
|
}
|
||||||
|
@ -25332,6 +25341,7 @@ func parseHistoricalEventPlus(p *util.XMLParser, obj *HistoricalEvent) (*Histori
|
||||||
case "war_peace_rejected":
|
case "war_peace_rejected":
|
||||||
obj.Details, err = parseHistoricalEventPeaceRejectedPlus(p, obj.Details.(*HistoricalEventPeaceRejected))
|
obj.Details, err = parseHistoricalEventPeaceRejectedPlus(p, obj.Details.(*HistoricalEventPeaceRejected))
|
||||||
default:
|
default:
|
||||||
|
obj.Details = NewHistoricalEventUnknown(string(data))
|
||||||
p.Skip()
|
p.Skip()
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue