same fields
This commit is contained in:
parent
cbc9601c33
commit
5f200e7fd5
File diff suppressed because it is too large
Load Diff
|
@ -24,6 +24,10 @@ func Generate() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if err := generateEventsCode(m); err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
|
||||||
if err := generateFrontendCode(m); err != nil {
|
if err := generateFrontendCode(m); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,34 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func InitSameFields() {
|
||||||
|
sameFields = map[string]map[string]map[string]bool{
|
||||||
|
{{- range $name, $obj := $.Objects }}
|
||||||
|
"{{$obj.Name}}": {
|
||||||
|
{{- range $field := ($obj.LegendFields "plus") }}
|
||||||
|
{{- if ne 0 (len ($obj.LegendFields "base")) }}
|
||||||
|
"{{$field.Name}}": {
|
||||||
|
{{- range $field2 := ($obj.LegendFields "base") }}
|
||||||
|
{{- if eq $field.Type $field2.Type }}
|
||||||
|
"{{ $field2.Name }}": true,
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
},
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
},
|
||||||
|
{{- end }}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
{{- range $name, $obj := $.Objects }}
|
{{- range $name, $obj := $.Objects }}
|
||||||
type {{ $obj.Name }} struct {
|
type {{ $obj.Name }} struct {
|
||||||
{{- range $fname, $field := $obj.Fields }}
|
{{- range $fname, $field := $obj.Fields }}
|
||||||
{{- if not (and (eq $fname "type") (not (not $obj.SubTypes))) }}
|
{{- if not (and (eq $fname "type") (not (not $obj.SubTypes))) }}
|
||||||
{{ $field.TypeLine }}
|
{{- if not ($field.SameField $obj) }}
|
||||||
|
{{ $field.TypeLine }} // {{ $fname }}
|
||||||
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if not (not $obj.SubTypes) }}
|
{{- if not (not $obj.SubTypes) }}
|
||||||
|
@ -41,7 +64,29 @@ func (x *{{ $obj.Name }}) Id() int { return x.Id_ }
|
||||||
{{- if $obj.Named }}
|
{{- if $obj.Named }}
|
||||||
func (x *{{ $obj.Name }}) Name() string { return x.Name_ }
|
func (x *{{ $obj.Name }}) Name() string { return x.Name_ }
|
||||||
{{- end }}
|
{{- end }}
|
||||||
func (x *{{ $obj.Name }}) RelatedToHf(id int) bool { return {{ $obj.Related "hfid,hf_id,_hf,hist_figure_id,Hfid,histfig_id,histfig" }} }
|
func (x *{{ $obj.Name }}) RelatedToEntity(id int) bool { return {{ $obj.Related "civId,civ_id,entity_id,entity" }} }
|
||||||
|
func (x *{{ $obj.Name }}) RelatedToHf(id int) bool { return {{ $obj.Related "hfid,hf_id,_hf,hist_figure_id,Hfid,histfig_id,histfig,bodies" }} }
|
||||||
|
|
||||||
|
func (x *{{ $obj.Name }}) CheckFields() {
|
||||||
|
{{- range $field := ($obj.LegendFields "plus") }}
|
||||||
|
{{- if not ($field.SameField $obj) }}
|
||||||
|
{{- range $field2 := ($obj.LegendFields "base") }}
|
||||||
|
{{- if eq $field.Type $field2.Type }}
|
||||||
|
{{- if eq $field.Type "int" }}
|
||||||
|
if x.{{ $field.Name}} != x.{{ $field2.Name}} && x.{{ $field.Name}} != 0 && x.{{ $field2.Name}} != 0 {
|
||||||
|
sameFields["{{$obj.Name}}"]["{{ $field.Name}}"]["{{ $field2.Name}}"] = false
|
||||||
|
}
|
||||||
|
{{- end }}
|
||||||
|
{{- if eq $field.Type "string" }}
|
||||||
|
if x.{{ $field.Name}} != x.{{ $field2.Name}} && x.{{ $field.Name}} != "" && x.{{ $field2.Name}} != "" {
|
||||||
|
sameFields["{{$obj.Name}}"]["{{ $field.Name}}"]["{{ $field2.Name}}"] = false
|
||||||
|
}
|
||||||
|
{{- end }} {{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
}
|
||||||
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
// Parser
|
// Parser
|
||||||
|
@ -94,6 +139,7 @@ func parse{{ $obj.Name }}{{ if $plus }}Plus{{ end }}(d *xml.Decoder, start *xml.
|
||||||
|
|
||||||
case xml.EndElement:
|
case xml.EndElement:
|
||||||
if t.Name.Local == start.Name.Local {
|
if t.Name.Local == start.Name.Local {
|
||||||
|
obj.CheckFields()
|
||||||
return obj, nil
|
return obj, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +179,7 @@ func parse{{ $obj.Name }}{{ if $plus }}Plus{{ end }}(d *xml.Decoder, start *xml.
|
||||||
return obj, nil
|
return obj, nil
|
||||||
|
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{ $field.EndAction }}
|
{{ $field.EndAction $obj }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}{{- end }}
|
{{- end }}{{- end }}
|
||||||
default:
|
default:
|
||||||
|
@ -146,7 +192,23 @@ func parse{{ $obj.Name }}{{ if $plus }}Plus{{ end }}(d *xml.Decoder, start *xml.
|
||||||
{{- end }}
|
{{- end }}
|
||||||
`))
|
`))
|
||||||
|
|
||||||
|
var sameFields map[string]map[string]string
|
||||||
|
|
||||||
|
func LoadSameFields() error {
|
||||||
|
data, err := ioutil.ReadFile("same.json")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
sameFields = make(map[string]map[string]string)
|
||||||
|
json.Unmarshal(data, &sameFields)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func generateBackendCode(objects *Metadata) error {
|
func generateBackendCode(objects *Metadata) error {
|
||||||
|
LoadSameFields()
|
||||||
|
fmt.Println(sameFields["HistoricalEventAddHfEntityLink"])
|
||||||
|
|
||||||
file, _ := json.MarshalIndent(objects, "", " ")
|
file, _ := json.MarshalIndent(objects, "", " ")
|
||||||
_ = ioutil.WriteFile("model.json", file, 0644)
|
_ = ioutil.WriteFile("model.json", file, 0644)
|
||||||
|
|
||||||
|
@ -254,11 +316,13 @@ func (f Field) StartAction(plus bool) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f Field) EndAction() string {
|
func (f Field) EndAction(obj Object) string {
|
||||||
n := f.Name
|
n := f.Name
|
||||||
|
|
||||||
if n == "Id" || n == "Name" {
|
if n == "Id" || n == "Name" {
|
||||||
n = n + "_"
|
n = n + "_"
|
||||||
|
} else {
|
||||||
|
n = f.CorrectedName(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !f.Multiple {
|
if !f.Multiple {
|
||||||
|
@ -284,8 +348,12 @@ func (obj Object) Related(fields string) string {
|
||||||
var list []string
|
var list []string
|
||||||
fs := strings.Split(fields, ",")
|
fs := strings.Split(fields, ",")
|
||||||
for n, f := range obj.Fields {
|
for n, f := range obj.Fields {
|
||||||
if f.Type == "int" && !f.Multiple && util.ContainsAny(n, fs...) {
|
if f.Type == "int" && util.ContainsAny(n, fs...) && !f.SameField(obj) {
|
||||||
list = append(list, fmt.Sprintf("x.%s == id", f.Name))
|
if !f.Multiple {
|
||||||
|
list = append(list, fmt.Sprintf("x.%s == id", f.Name))
|
||||||
|
} else {
|
||||||
|
list = append(list, fmt.Sprintf("containsInt(x.%s, id)", f.Name))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(list) > 0 {
|
if len(list) > 0 {
|
||||||
|
@ -293,3 +361,33 @@ func (obj Object) Related(fields string) string {
|
||||||
}
|
}
|
||||||
return "false"
|
return "false"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (obj Object) LegendFields(t string) []Field {
|
||||||
|
var list []Field
|
||||||
|
for _, f := range obj.Fields {
|
||||||
|
if f.Name != "Name" && f.Name != "Id" && f.Name != "Type" && f.Legend == t && f.Type != "object" && !f.Multiple {
|
||||||
|
list = append(list, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f Field) SameField(obj Object) bool {
|
||||||
|
if f.Legend != "plus" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
_, ok := sameFields[obj.Name][f.Name]
|
||||||
|
// fmt.Println(obj.Name, f.Name, ok)
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f Field) CorrectedName(obj Object) string {
|
||||||
|
if f.Legend != "plus" {
|
||||||
|
return f.Name
|
||||||
|
}
|
||||||
|
n, ok := sameFields[obj.Name][f.Name]
|
||||||
|
if ok {
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
return f.Name
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
package df
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"go/format"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"text/template"
|
||||||
|
)
|
||||||
|
|
||||||
|
var eventsTemplate = template.Must(template.New("").Parse(`// Code generated by legendsbrowser; DO NOT EDIT.
|
||||||
|
package model
|
||||||
|
|
||||||
|
{{- range $name, $obj := $.Objects }}
|
||||||
|
{{- if $obj.IsSubTypeOf "HistoricalEvent" }}
|
||||||
|
func (x *{{ $obj.Name }}) Html() string { return "UNKNWON {{ $obj.Name }}" }
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
`))
|
||||||
|
|
||||||
|
func generateEventsCode(objects *Metadata) error {
|
||||||
|
file, _ := json.MarshalIndent(objects, "", " ")
|
||||||
|
_ = ioutil.WriteFile("model.json", file, 0644)
|
||||||
|
|
||||||
|
f, err := os.Create("../backend/model/events.go")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err = eventsTemplate.Execute(&buf, struct {
|
||||||
|
Objects *Metadata
|
||||||
|
Modes []bool
|
||||||
|
}{
|
||||||
|
Objects: objects,
|
||||||
|
Modes: []bool{false, true},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
p, err := format.Source(buf.Bytes())
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("WARN: could not format source", err)
|
||||||
|
p = buf.Bytes()
|
||||||
|
}
|
||||||
|
_, err = f.Write(p)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o Object) IsSubTypeOf(t string) bool {
|
||||||
|
return o.SubTypeOf != nil && *o.SubTypeOf == t
|
||||||
|
}
|
|
@ -0,0 +1,119 @@
|
||||||
|
{
|
||||||
|
"HistoricalEventAddHfEntityLink": {
|
||||||
|
"Civ": "CivId",
|
||||||
|
"Histfig": "Hfid",
|
||||||
|
"LinkType": "Link"
|
||||||
|
},
|
||||||
|
"HistoricalEventAddHfHfLink": {
|
||||||
|
"Hf": "Hfid",
|
||||||
|
"HfTarget": "HfidTarget"
|
||||||
|
},
|
||||||
|
"HistoricalEventAddHfSiteLink": {
|
||||||
|
"Site": "SiteId"
|
||||||
|
},
|
||||||
|
"HistoricalEventArtifactCreated": {
|
||||||
|
"CreatorHfid": "HistFigureId",
|
||||||
|
"CreatorUnitId": "UnitId",
|
||||||
|
"Site": "SiteId"
|
||||||
|
},
|
||||||
|
"HistoricalEventAssumeIdentity": {
|
||||||
|
"IdentityHistfigId": "TricksterHfid",
|
||||||
|
"IdentityNemesisId": "TricksterHfid",
|
||||||
|
"Target": "TargetEnid",
|
||||||
|
"Trickster": "TricksterHfid"
|
||||||
|
},
|
||||||
|
"HistoricalEventBodyAbused": {
|
||||||
|
"Site": "SiteId"
|
||||||
|
},
|
||||||
|
"HistoricalEventChangeHfJob": {
|
||||||
|
"Site": "SiteId"
|
||||||
|
},
|
||||||
|
"HistoricalEventChangeHfState": {
|
||||||
|
"Site": "SiteId"
|
||||||
|
},
|
||||||
|
"HistoricalEventChangedCreatureType": {
|
||||||
|
"Changee": "ChangeeHfid",
|
||||||
|
"Changer": "ChangerHfid"
|
||||||
|
},
|
||||||
|
"HistoricalEventCreatedStructure": {
|
||||||
|
"BuilderHf": "BuilderHfid",
|
||||||
|
"Civ": "CivId",
|
||||||
|
"Site": "SiteId",
|
||||||
|
"SiteCiv": "SiteCivId"
|
||||||
|
},
|
||||||
|
"HistoricalEventCreatureDevoured": {
|
||||||
|
"Site": "SiteId"
|
||||||
|
},
|
||||||
|
"HistoricalEventEntityPrimaryCriminals": {
|
||||||
|
"Entity": "EntityId",
|
||||||
|
"Site": "SiteId",
|
||||||
|
"Structure": "StructureId"
|
||||||
|
},
|
||||||
|
"HistoricalEventEntityRelocate": {
|
||||||
|
"Entity": "EntityId",
|
||||||
|
"Site": "SiteId",
|
||||||
|
"Structure": "StructureId"
|
||||||
|
},
|
||||||
|
"HistoricalEventHfDied": {
|
||||||
|
"ArtifactId": "SlayerItemId",
|
||||||
|
"Item": "SlayerItemId",
|
||||||
|
"ItemSubtype": "Cause",
|
||||||
|
"Mat": "Cause",
|
||||||
|
"Site": "SiteId",
|
||||||
|
"SlayerHf": "SlayerHfid",
|
||||||
|
"VictimHf": "Hfid"
|
||||||
|
},
|
||||||
|
"HistoricalEventHfDisturbedStructure": {
|
||||||
|
"Histfig": "HistFigId",
|
||||||
|
"Site": "SiteId",
|
||||||
|
"Structure": "StructureId"
|
||||||
|
},
|
||||||
|
"HistoricalEventHfDoesInteraction": {
|
||||||
|
"Doer": "DoerHfid",
|
||||||
|
"Target": "TargetHfid"
|
||||||
|
},
|
||||||
|
"HistoricalEventHfLearnsSecret": {
|
||||||
|
"Artifact": "ArtifactId",
|
||||||
|
"Student": "StudentHfid",
|
||||||
|
"Teacher": "TeacherHfid"
|
||||||
|
},
|
||||||
|
"HistoricalEventHfNewPet": {
|
||||||
|
"Group": "GroupHfid",
|
||||||
|
"Site": "SiteId"
|
||||||
|
},
|
||||||
|
"HistoricalEventHfPrayedInsideStructure": {
|
||||||
|
"Histfig": "HistFigId",
|
||||||
|
"Site": "SiteId",
|
||||||
|
"Structure": "StructureId"
|
||||||
|
},
|
||||||
|
"HistoricalEventHfProfanedStructure": {
|
||||||
|
"Histfig": "HistFigId",
|
||||||
|
"Site": "SiteId",
|
||||||
|
"Structure": "StructureId"
|
||||||
|
},
|
||||||
|
"HistoricalEventHfWounded": {
|
||||||
|
"Site": "SiteId",
|
||||||
|
"Woundee": "WoundeeHfid",
|
||||||
|
"Wounder": "WounderHfid"
|
||||||
|
},
|
||||||
|
"HistoricalEventPeaceAccepted": {
|
||||||
|
"Site": "SiteId"
|
||||||
|
},
|
||||||
|
"HistoricalEventPeaceRejected": {
|
||||||
|
"Site": "SiteId"
|
||||||
|
},
|
||||||
|
"HistoricalEventRemoveHfEntityLink": {
|
||||||
|
"Civ": "CivId",
|
||||||
|
"Histfig": "Hfid",
|
||||||
|
"LinkType": "Link"
|
||||||
|
},
|
||||||
|
"HistoricalEventRemoveHfSiteLink": {
|
||||||
|
"Site": "SiteId"
|
||||||
|
},
|
||||||
|
"Structure": {
|
||||||
|
"Name2": "Subtype"
|
||||||
|
},
|
||||||
|
"WrittenContent": {
|
||||||
|
"Author": "AuthorHfid"
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ import (
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -65,6 +66,12 @@ func main() {
|
||||||
id := obj.Id()
|
id := obj.Id()
|
||||||
var list []*model.HistoricalEvent
|
var list []*model.HistoricalEvent
|
||||||
switch obj.(type) {
|
switch obj.(type) {
|
||||||
|
case *model.Entity:
|
||||||
|
for _, e := range world.HistoricalEvents {
|
||||||
|
if e.Details.RelatedToEntity(id) {
|
||||||
|
list = append(list, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
case *model.HistoricalFigure:
|
case *model.HistoricalFigure:
|
||||||
for _, e := range world.HistoricalEvents {
|
for _, e := range world.HistoricalEvents {
|
||||||
if e.Details.RelatedToHf(id) {
|
if e.Details.RelatedToHf(id) {
|
||||||
|
@ -74,8 +81,33 @@ func main() {
|
||||||
default:
|
default:
|
||||||
fmt.Printf("unknown type %T\n", obj)
|
fmt.Printf("unknown type %T\n", obj)
|
||||||
}
|
}
|
||||||
|
sort.Slice(list, func(a, b int) bool { return list[a].Id_ < list[b].Id_ })
|
||||||
return list
|
return list
|
||||||
},
|
},
|
||||||
|
"season": func(seconds int) string {
|
||||||
|
r := ""
|
||||||
|
month := seconds % 100800
|
||||||
|
if month <= 33600 {
|
||||||
|
r += "early "
|
||||||
|
} else if month <= 67200 {
|
||||||
|
r += "mid"
|
||||||
|
} else if month <= 100800 {
|
||||||
|
r += "late "
|
||||||
|
}
|
||||||
|
|
||||||
|
season := seconds % 403200
|
||||||
|
if season < 100800 {
|
||||||
|
r += "spring"
|
||||||
|
} else if season < 201600 {
|
||||||
|
r += "summer"
|
||||||
|
} else if season < 302400 {
|
||||||
|
r += "autumn"
|
||||||
|
} else if season < 403200 {
|
||||||
|
r += "winter"
|
||||||
|
}
|
||||||
|
|
||||||
|
return r
|
||||||
|
},
|
||||||
}
|
}
|
||||||
t := templates.New(functions)
|
t := templates.New(functions)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,209 @@
|
||||||
|
// Code generated by legendsbrowser; DO NOT EDIT.
|
||||||
|
package model
|
||||||
|
|
||||||
|
func (x *HistoricalEventAddHfEntityHonor) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventAddHfEntityHonor"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventAddHfEntityLink) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventAddHfEntityLink"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventAddHfHfLink) Html() string { return "UNKNWON HistoricalEventAddHfHfLink" }
|
||||||
|
func (x *HistoricalEventAddHfSiteLink) Html() string { return "UNKNWON HistoricalEventAddHfSiteLink" }
|
||||||
|
func (x *HistoricalEventAgreementFormed) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventAgreementFormed"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventArtifactClaimFormed) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventArtifactClaimFormed"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventArtifactCopied) Html() string { return "UNKNWON HistoricalEventArtifactCopied" }
|
||||||
|
func (x *HistoricalEventArtifactCreated) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventArtifactCreated"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventArtifactDestroyed) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventArtifactDestroyed"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventArtifactFound) Html() string { return "UNKNWON HistoricalEventArtifactFound" }
|
||||||
|
func (x *HistoricalEventArtifactGiven) Html() string { return "UNKNWON HistoricalEventArtifactGiven" }
|
||||||
|
func (x *HistoricalEventArtifactLost) Html() string { return "UNKNWON HistoricalEventArtifactLost" }
|
||||||
|
func (x *HistoricalEventArtifactPossessed) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventArtifactPossessed"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventArtifactRecovered) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventArtifactRecovered"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventArtifactStored) Html() string { return "UNKNWON HistoricalEventArtifactStored" }
|
||||||
|
func (x *HistoricalEventAssumeIdentity) Html() string { return "UNKNWON HistoricalEventAssumeIdentity" }
|
||||||
|
func (x *HistoricalEventAttackedSite) Html() string { return "UNKNWON HistoricalEventAttackedSite" }
|
||||||
|
func (x *HistoricalEventBodyAbused) Html() string { return "UNKNWON HistoricalEventBodyAbused" }
|
||||||
|
func (x *HistoricalEventBuildingProfileAcquired) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventBuildingProfileAcquired"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventCeremony) Html() string { return "UNKNWON HistoricalEventCeremony" }
|
||||||
|
func (x *HistoricalEventChangeHfBodyState) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventChangeHfBodyState"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventChangeHfJob) Html() string { return "UNKNWON HistoricalEventChangeHfJob" }
|
||||||
|
func (x *HistoricalEventChangeHfState) Html() string { return "UNKNWON HistoricalEventChangeHfState" }
|
||||||
|
func (x *HistoricalEventChangedCreatureType) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventChangedCreatureType"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventCompetition) Html() string { return "UNKNWON HistoricalEventCompetition" }
|
||||||
|
func (x *HistoricalEventCreateEntityPosition) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventCreateEntityPosition"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventCreatedSite) Html() string { return "UNKNWON HistoricalEventCreatedSite" }
|
||||||
|
func (x *HistoricalEventCreatedStructure) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventCreatedStructure"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventCreatedWorldConstruction) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventCreatedWorldConstruction"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventCreatureDevoured) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventCreatureDevoured"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventDanceFormCreated) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventDanceFormCreated"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventDestroyedSite) Html() string { return "UNKNWON HistoricalEventDestroyedSite" }
|
||||||
|
func (x *HistoricalEventEntityAllianceFormed) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventEntityAllianceFormed"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventEntityBreachFeatureLayer) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventEntityBreachFeatureLayer"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventEntityCreated) Html() string { return "UNKNWON HistoricalEventEntityCreated" }
|
||||||
|
func (x *HistoricalEventEntityDissolved) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventEntityDissolved"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventEntityEquipmentPurchase) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventEntityEquipmentPurchase"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventEntityIncorporated) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventEntityIncorporated"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventEntityLaw) Html() string { return "UNKNWON HistoricalEventEntityLaw" }
|
||||||
|
func (x *HistoricalEventEntityOverthrown) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventEntityOverthrown"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventEntityPersecuted) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventEntityPersecuted"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventEntityPrimaryCriminals) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventEntityPrimaryCriminals"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventEntityRelocate) Html() string { return "UNKNWON HistoricalEventEntityRelocate" }
|
||||||
|
func (x *HistoricalEventFailedFrameAttempt) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventFailedFrameAttempt"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventFailedIntrigueCorruption) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventFailedIntrigueCorruption"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventFieldBattle) Html() string { return "UNKNWON HistoricalEventFieldBattle" }
|
||||||
|
func (x *HistoricalEventGamble) Html() string { return "UNKNWON HistoricalEventGamble" }
|
||||||
|
func (x *HistoricalEventHfAbducted) Html() string { return "UNKNWON HistoricalEventHfAbducted" }
|
||||||
|
func (x *HistoricalEventHfAttackedSite) Html() string { return "UNKNWON HistoricalEventHfAttackedSite" }
|
||||||
|
func (x *HistoricalEventHfConfronted) Html() string { return "UNKNWON HistoricalEventHfConfronted" }
|
||||||
|
func (x *HistoricalEventHfConvicted) Html() string { return "UNKNWON HistoricalEventHfConvicted" }
|
||||||
|
func (x *HistoricalEventHfDestroyedSite) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventHfDestroyedSite"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventHfDied) Html() string { return "UNKNWON HistoricalEventHfDied" }
|
||||||
|
func (x *HistoricalEventHfDisturbedStructure) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventHfDisturbedStructure"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventHfDoesInteraction) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventHfDoesInteraction"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventHfEnslaved) Html() string { return "UNKNWON HistoricalEventHfEnslaved" }
|
||||||
|
func (x *HistoricalEventHfEquipmentPurchase) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventHfEquipmentPurchase"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventHfGainsSecretGoal) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventHfGainsSecretGoal"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventHfInterrogated) Html() string { return "UNKNWON HistoricalEventHfInterrogated" }
|
||||||
|
func (x *HistoricalEventHfLearnsSecret) Html() string { return "UNKNWON HistoricalEventHfLearnsSecret" }
|
||||||
|
func (x *HistoricalEventHfNewPet) Html() string { return "UNKNWON HistoricalEventHfNewPet" }
|
||||||
|
func (x *HistoricalEventHfPerformedHorribleExperiments) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventHfPerformedHorribleExperiments"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventHfPrayedInsideStructure) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventHfPrayedInsideStructure"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventHfPreach) Html() string { return "UNKNWON HistoricalEventHfPreach" }
|
||||||
|
func (x *HistoricalEventHfProfanedStructure) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventHfProfanedStructure"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventHfRecruitedUnitTypeForEntity) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventHfRecruitedUnitTypeForEntity"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventHfRelationshipDenied) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventHfRelationshipDenied"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventHfReunion) Html() string { return "UNKNWON HistoricalEventHfReunion" }
|
||||||
|
func (x *HistoricalEventHfRevived) Html() string { return "UNKNWON HistoricalEventHfRevived" }
|
||||||
|
func (x *HistoricalEventHfSimpleBattleEvent) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventHfSimpleBattleEvent"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventHfTravel) Html() string { return "UNKNWON HistoricalEventHfTravel" }
|
||||||
|
func (x *HistoricalEventHfViewedArtifact) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventHfViewedArtifact"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventHfWounded) Html() string { return "UNKNWON HistoricalEventHfWounded" }
|
||||||
|
func (x *HistoricalEventHfsFormedIntrigueRelationship) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventHfsFormedIntrigueRelationship"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventHfsFormedReputationRelationship) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventHfsFormedReputationRelationship"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventHolyCityDeclaration) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventHolyCityDeclaration"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventItemStolen) Html() string { return "UNKNWON HistoricalEventItemStolen" }
|
||||||
|
func (x *HistoricalEventKnowledgeDiscovered) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventKnowledgeDiscovered"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventMasterpieceItem) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventMasterpieceItem"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventMerchant) Html() string { return "UNKNWON HistoricalEventMerchant" }
|
||||||
|
func (x *HistoricalEventModifiedBuilding) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventModifiedBuilding"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventMusicalFormCreated) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventMusicalFormCreated"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventNewSiteLeader) Html() string { return "UNKNWON HistoricalEventNewSiteLeader" }
|
||||||
|
func (x *HistoricalEventPeaceAccepted) Html() string { return "UNKNWON HistoricalEventPeaceAccepted" }
|
||||||
|
func (x *HistoricalEventPeaceRejected) Html() string { return "UNKNWON HistoricalEventPeaceRejected" }
|
||||||
|
func (x *HistoricalEventPerformance) Html() string { return "UNKNWON HistoricalEventPerformance" }
|
||||||
|
func (x *HistoricalEventPlunderedSite) Html() string { return "UNKNWON HistoricalEventPlunderedSite" }
|
||||||
|
func (x *HistoricalEventPoeticFormCreated) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventPoeticFormCreated"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventProcession) Html() string { return "UNKNWON HistoricalEventProcession" }
|
||||||
|
func (x *HistoricalEventRazedStructure) Html() string { return "UNKNWON HistoricalEventRazedStructure" }
|
||||||
|
func (x *HistoricalEventReclaimSite) Html() string { return "UNKNWON HistoricalEventReclaimSite" }
|
||||||
|
func (x *HistoricalEventRegionpopIncorporatedIntoEntity) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventRegionpopIncorporatedIntoEntity"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventRemoveHfEntityLink) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventRemoveHfEntityLink"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventRemoveHfHfLink) Html() string { return "UNKNWON HistoricalEventRemoveHfHfLink" }
|
||||||
|
func (x *HistoricalEventRemoveHfSiteLink) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventRemoveHfSiteLink"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventReplacedStructure) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventReplacedStructure"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventSiteDispute) Html() string { return "UNKNWON HistoricalEventSiteDispute" }
|
||||||
|
func (x *HistoricalEventSiteTakenOver) Html() string { return "UNKNWON HistoricalEventSiteTakenOver" }
|
||||||
|
func (x *HistoricalEventSquadVsSquad) Html() string { return "UNKNWON HistoricalEventSquadVsSquad" }
|
||||||
|
func (x *HistoricalEventTacticalSituation) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventTacticalSituation"
|
||||||
|
}
|
||||||
|
func (x *HistoricalEventTrade) Html() string { return "UNKNWON HistoricalEventTrade" }
|
||||||
|
func (x *HistoricalEventWrittenContentComposed) Html() string {
|
||||||
|
return "UNKNWON HistoricalEventWrittenContentComposed"
|
||||||
|
}
|
|
@ -10,8 +10,19 @@ func (e *Entity) Position(id int) *EntityPosition {
|
||||||
}
|
}
|
||||||
|
|
||||||
type HistoricalEventDetails interface {
|
type HistoricalEventDetails interface {
|
||||||
|
RelatedToEntity(int) bool
|
||||||
RelatedToHf(int) bool
|
RelatedToHf(int) bool
|
||||||
|
Html() string
|
||||||
}
|
}
|
||||||
|
|
||||||
type HistoricalEventCollectionDetails interface {
|
type HistoricalEventCollectionDetails interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func containsInt(list []int, id int) bool {
|
||||||
|
for _, v := range list {
|
||||||
|
if v == id {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,10 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -15,6 +17,8 @@ func (e *HistoricalEvent) Name() string { return "" }
|
||||||
func (e *HistoricalEventCollection) Name() string { return "" }
|
func (e *HistoricalEventCollection) Name() string { return "" }
|
||||||
|
|
||||||
func Parse(file string) (*DfWorld, error) {
|
func Parse(file string) (*DfWorld, error) {
|
||||||
|
InitSameFields()
|
||||||
|
|
||||||
xmlFile, err := os.Open(file)
|
xmlFile, err := os.Open(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
@ -80,6 +84,12 @@ BaseLoop:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
same, err := json.MarshalIndent(exportSameFields(), "", " ")
|
||||||
|
if err != nil {
|
||||||
|
return world, err
|
||||||
|
}
|
||||||
|
ioutil.WriteFile("same.json", same, 0644)
|
||||||
|
|
||||||
return world, nil
|
return world, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,3 +175,31 @@ func parseId(d *xml.Decoder) (int, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var sameFields map[string]map[string]map[string]bool
|
||||||
|
|
||||||
|
func exportSameFields() map[string]map[string]string {
|
||||||
|
export := make(map[string]map[string]string)
|
||||||
|
|
||||||
|
for objectType, v := range sameFields {
|
||||||
|
fields := make(map[string]string)
|
||||||
|
for field, v2 := range v {
|
||||||
|
c := 0
|
||||||
|
f := ""
|
||||||
|
for field2, same := range v2 {
|
||||||
|
if same {
|
||||||
|
c++
|
||||||
|
f = field2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if c == 1 {
|
||||||
|
fields[field] = f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(fields) > 0 {
|
||||||
|
export[objectType] = fields
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return export
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
{
|
||||||
|
"Artifact": {
|
||||||
|
"Writing": "StructureLocalId"
|
||||||
|
},
|
||||||
|
"HistoricalEventAddHfEntityLink": {
|
||||||
|
"LinkType": "Link"
|
||||||
|
},
|
||||||
|
"HistoricalEventAddHfSiteLink": {
|
||||||
|
"Site": "SiteId"
|
||||||
|
},
|
||||||
|
"HistoricalEventCreatedStructure": {
|
||||||
|
"Structure": "StructureId"
|
||||||
|
},
|
||||||
|
"HistoricalEventHfDied": {
|
||||||
|
"ItemSubtype": "Cause",
|
||||||
|
"Mat": "Cause"
|
||||||
|
},
|
||||||
|
"HistoricalEventHfDoesInteraction": {
|
||||||
|
"InteractionAction": "Interaction"
|
||||||
|
},
|
||||||
|
"HistoricalEventHfLearnsSecret": {
|
||||||
|
"SecretText": "Interaction"
|
||||||
|
},
|
||||||
|
"HistoricalEventMasterpieceItem": {
|
||||||
|
"Maker": "Hfid",
|
||||||
|
"MakerEntity": "EntityId",
|
||||||
|
"Site": "SiteId"
|
||||||
|
},
|
||||||
|
"HistoricalEventMerchant": {
|
||||||
|
"Destination": "DepotEntityId",
|
||||||
|
"Site": "SiteId",
|
||||||
|
"Source": "TraderEntityId"
|
||||||
|
},
|
||||||
|
"HistoricalEventPeaceAccepted": {
|
||||||
|
"Site": "SiteId"
|
||||||
|
},
|
||||||
|
"HistoricalEventPeaceRejected": {
|
||||||
|
"Site": "SiteId"
|
||||||
|
},
|
||||||
|
"HistoricalEventRemoveHfEntityLink": {
|
||||||
|
"LinkType": "Link"
|
||||||
|
},
|
||||||
|
"HistoricalEventRemoveHfSiteLink": {
|
||||||
|
"Site": "SiteId"
|
||||||
|
},
|
||||||
|
"Structure": {
|
||||||
|
"Name2": "Subtype"
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,5 +3,12 @@
|
||||||
{{define "title"}}{{ title .Name }}{{end}}
|
{{define "title"}}{{ title .Name }}{{end}}
|
||||||
|
|
||||||
{{define "content"}}
|
{{define "content"}}
|
||||||
{{ json . }}
|
<h1>{{ title .Name }}</h1>
|
||||||
|
{{ .Race }} {{ .Type }}
|
||||||
|
|
||||||
|
<h3>Events</h3>
|
||||||
|
|
||||||
|
{{ template "events.html" . }}
|
||||||
|
|
||||||
|
<p>{{ json . }}</p>
|
||||||
{{- end }}
|
{{- end }}
|
|
@ -1,7 +1,8 @@
|
||||||
<ul>
|
<ul>
|
||||||
{{- range $event := events . }}
|
{{- range $event := events . }}
|
||||||
<li>
|
<li>
|
||||||
{{ $event.Id }} in of {{ $event.Year }} {{ json $event.Details }}
|
[{{ $event.Id }}] In {{ if gt $event.Seconds72 -1 }}{{ season $event.Seconds72 }} of {{ end }}{{ $event.Year }} {{
|
||||||
|
$event.Details.Html }} {{ json $event.Details }}
|
||||||
</li>
|
</li>
|
||||||
{{- end}}
|
{{- end}}
|
||||||
</ul>
|
</ul>
|
|
@ -1461,7 +1461,7 @@ export interface IntriguePlot {
|
||||||
onHold: boolean;
|
onHold: boolean;
|
||||||
parentPlotHfid: number;
|
parentPlotHfid: number;
|
||||||
parentPlotId: number;
|
parentPlotId: number;
|
||||||
plotActor: PlotActor;
|
plotActor: PlotActor[];
|
||||||
type: string;
|
type: string;
|
||||||
}
|
}
|
||||||
export interface Item {
|
export interface Item {
|
||||||
|
|
Loading…
Reference in New Issue