diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 6b3bc95..8dcd1ab 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -9,8 +9,8 @@ ARG NODE_VERSION="none" RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi # [Optional] Uncomment this section to install additional OS packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends graphviz # [Optional] Uncomment the next lines to use go get to install anything else you need # USER vscode diff --git a/analyze/analyze.go b/analyze/analyze.go new file mode 100644 index 0000000..e224876 --- /dev/null +++ b/analyze/analyze.go @@ -0,0 +1,304 @@ +package analyze + +import ( + "encoding/json" + "encoding/xml" + "fmt" + "io" + "io/ioutil" + "legendsbrowser/util" + "log" + "os" + "path/filepath" + "sort" + "strconv" + "strings" + "text/template" + + "github.com/iancoleman/strcase" +) + +func Analyze(filex string) { + files, err := filepath.Glob("*.xml") + if err != nil { + log.Fatal(err) + } + fmt.Println(files) + + files = []string{filex} + + a := NewAnalyzeData() + + for _, file := range files { + xmlFile, err := os.Open(file) + if err != nil { + fmt.Println(err) + } + + fmt.Println("Successfully Opened", file) + defer xmlFile.Close() + + converter := util.NewConvertReader(xmlFile) + analyze(converter, a) + } + + createMetadata(a) +} + +type analyzeData struct { + path []string + types *map[string]bool + fields *map[string]bool + isString *map[string]bool + multiple *map[string]bool +} + +func NewAnalyzeData() analyzeData { + path := make([]string, 0) + types := make(map[string]bool, 0) + fields := make(map[string]bool, 0) + isString := make(map[string]bool, 0) + multiple := make(map[string]bool, 0) + + return analyzeData{ + path: path, + types: &types, + fields: &fields, + isString: &isString, + multiple: &multiple, + } +} + +func analyzeElement(d *xml.Decoder, a analyzeData) error { + if len(a.path) > 1 { + (*a.fields)[strings.Join(a.path, ">")] = true + } + + var ( + data []byte + ) + value := true + + fields := make(map[string]bool) + +Loop: + for { + tok, err := d.Token() + if err == io.EOF { + break Loop + } else if err != nil { + return err + } + switch t := tok.(type) { + case xml.StartElement: + value = false + + (*a.types)[strings.Join(a.path, ">")] = true + + a2 := a + a2.path = append(a.path, t.Name.Local) + + if _, ok := fields[t.Name.Local]; ok { + (*a.multiple)[strings.Join(a2.path, ">")] = true + } + fields[t.Name.Local] = true + + analyzeElement(d, a2) + + case xml.CharData: + data = append(data, t...) + + case xml.EndElement: + if value { + if _, err := strconv.Atoi(string(data)); err != nil { + (*a.isString)[strings.Join(a.path, ">")] = true + } + } + + if t.Name.Local == "type" { + a.path[len(a.path)-2] = a.path[len(a.path)-2] + strcase.ToCamel(string(data)) + fmt.Println(a.path) + } + + return nil + } + } + return nil +} + +func analyze(r io.Reader, a analyzeData) error { + d := xml.NewDecoder(r) + return analyzeElement(d, a) +} + +func createMetadata(a analyzeData) { + ts := util.Keys(*a.types) + sort.Strings(ts) + + fs := util.Keys(*a.fields) + sort.Strings(fs) + + objects := make(map[string]Object, 0) + + for _, k := range ts { + if ok, _ := isArray(k, fs); !ok { + n := k + if strings.Contains(k, ">") { + n = k[strings.LastIndex(k, ">")+1:] + } + + if n == "" { + continue + } + + objFields := make(map[string]Field, 0) + + fmt.Println("\n", n) + for _, f := range fs { + if strings.HasPrefix(f, k+">") { + fn := f[len(k)+1:] + if !strings.Contains(fn, ">") { + fmt.Println(" ", fn) + + if ok, elements := isArray(f, fs); ok { + el := elements[strings.LastIndex(elements, ">")+1:] + objFields[fn] = Field{ + Name: strcase.ToCamel(fn), + Type: "array", + ElementType: &(el), + } + } else if ok, _ := isObject(f, fs); ok { + objFields[fn] = Field{ + Name: strcase.ToCamel(fn), + Type: "object", + Multiple: (*a.multiple)[f], + } + } else if (*a.isString)[f] { + objFields[fn] = Field{ + Name: strcase.ToCamel(fn), + Type: "string", + Multiple: (*a.multiple)[f], + } + } else { + objFields[fn] = Field{ + Name: strcase.ToCamel(fn), + Type: "int", + Multiple: (*a.multiple)[f], + } + } + } + } + } + + objects[n] = Object{ + Name: strcase.ToCamel(n), + Id: (*a.fields)[k+">id"], + Named: (*a.fields)[k+">name"], + Typed: (*a.fields)[k+">type"], + Fields: objFields, + } + } + } + + file, _ := json.MarshalIndent(objects, "", " ") + _ = ioutil.WriteFile("model.json", file, 0644) + + f, err := os.Create("contributors.go") + defer f.Close() + + err = packageTemplate.Execute(f, struct { + Objects map[string]Object + }{ + Objects: objects, + }) + if err != nil { + fmt.Println(err) + } +} + +func isArray(typ string, types []string) (bool, string) { + fc := 0 + elements := "" + + for _, t := range types { + if !strings.HasPrefix(t, typ+">") { + continue + } + f := t[len(typ)+1:] + if strings.Contains(f, ">") { + continue + } + fc++ + elements = t + } + return fc == 1, elements +} + +func isObject(typ string, types []string) (bool, string) { + fc := 0 + + for _, t := range types { + if !strings.HasPrefix(t, typ+">") { + continue + } + fc++ + } + return fc > 0, typ +} + +type Object struct { + Name string `json:"name"` + Id bool `json:"id,omitempty"` + Named bool `json:"named,omitempty"` + Typed bool `json:"typed,omitempty"` + Fields map[string]Field `json:"fields"` +} + +type Field struct { + Name string `json:"name"` + Type string `json:"type"` + Multiple bool `json:"multiple,omitempty"` + ElementType *string `json:"elements,omitempty"` +} + +func (f Field) TypeLine(objects map[string]Object) string { + n := f.Name + + if n == "Id" || n == "Name" { + n = n + "_" + } + + m := "" + if f.Multiple { + m = "[]" + } + t := f.Type + if f.Type == "array" { + t = "map[int]*" + objects[*f.ElementType].Name + } + if f.Type == "object" { + t = f.Name + } + j := "`json:\"" + strcase.ToLowerCamel(f.Name) + "\"`" + return fmt.Sprintf("%s %s%s %s", n, m, t, j) +} + +var packageTemplate = template.Must(template.New("").Parse(`// Code generated by go generate; DO NOT EDIT. +package generate + +{{- range $name, $obj := .Objects }} +type {{ $obj.Name }} struct { + {{- range $fname, $field := $obj.Fields }} + {{ $field.TypeLine $.Objects }} + {{- end }} +} + +{{- if $obj.Id }} +func (x *{{ $obj.Name }}) Id() int { return x.Id_ } +{{- end }} +{{- if $obj.Named }} +func (x *{{ $obj.Name }}) Name() string { return x.Name_ } +{{- end }} + +{{- end }} +`)) diff --git a/contributors.go b/contributors.go new file mode 100644 index 0000000..732f100 --- /dev/null +++ b/contributors.go @@ -0,0 +1,745 @@ +// Code generated by go generate; DO NOT EDIT. +package generate +type Artifact struct { + AbsTileX int `json:"absTileX"` + AbsTileY int `json:"absTileY"` + AbsTileZ int `json:"absTileZ"` + HolderHfid int `json:"holderHfid"` + Id_ int `json:"id"` + Item Item `json:"item"` + Name_ string `json:"name"` + SiteId int `json:"siteId"` + StructureLocalId int `json:"structureLocalId"` + SubregionId int `json:"subregionId"` +} +func (x *Artifact) Id() int { return x.Id_ } +func (x *Artifact) Name() string { return x.Name_ } +type DanceForm struct { + Description string `json:"description"` + Id_ int `json:"id"` +} +func (x *DanceForm) Id() int { return x.Id_ } +type DfWorld struct { + Artifacts map[int]*Artifact `json:"artifacts"` + DanceForms map[int]*DanceForm `json:"danceForms"` + Entities map[int]*Entity `json:"entities"` + EntityPopulations map[int]* `json:"entityPopulations"` + HistoricalEras map[int]*HistoricalEra `json:"historicalEras"` + HistoricalEventCollections map[int]*HistoricalEventCollection `json:"historicalEventCollections"` + HistoricalEvents map[int]*HistoricalEvent `json:"historicalEvents"` + HistoricalFigures map[int]*HistoricalFigure `json:"historicalFigures"` + MusicalForms map[int]*MusicalForm `json:"musicalForms"` + PoeticForms map[int]*PoeticForm `json:"poeticForms"` + Regions map[int]*Region `json:"regions"` + Sites map[int]*Site `json:"sites"` + UndergroundRegions map[int]*UndergroundRegion `json:"undergroundRegions"` + WorldConstructions string `json:"worldConstructions"` + WrittenContents map[int]*WrittenContent `json:"writtenContents"` +} +type Entity struct { + Id_ int `json:"id"` + Name_ string `json:"name"` +} +func (x *Entity) Id() int { return x.Id_ } +func (x *Entity) Name() string { return x.Name_ } +type EntityFormerPositionLink struct { + EndYear int `json:"endYear"` + EntityId int `json:"entityId"` + PositionProfileId int `json:"positionProfileId"` + StartYear int `json:"startYear"` +} +type EntityLink struct { + EntityId int `json:"entityId"` + LinkStrength int `json:"linkStrength"` + LinkType string `json:"linkType"` +} +type EntityPositionLink struct { + EntityId int `json:"entityId"` + PositionProfileId int `json:"positionProfileId"` + StartYear int `json:"startYear"` +} +type EntitySquadLink struct { + EntityId int `json:"entityId"` + SquadId int `json:"squadId"` + SquadPosition int `json:"squadPosition"` + StartYear int `json:"startYear"` +} +type HfLink struct { + Hfid int `json:"hfid"` + LinkStrength int `json:"linkStrength"` + LinkType string `json:"linkType"` +} +type HfSkill struct { + Skill string `json:"skill"` + TotalIp int `json:"totalIp"` +} +type HistoricalEra struct { + Name_ string `json:"name"` + StartYear int `json:"startYear"` +} +func (x *HistoricalEra) Name() string { return x.Name_ } +type HistoricalEvent struct { + Id_ int `json:"id"` + Seconds72 int `json:"seconds72"` + Type string `json:"type"` + Year int `json:"year"` +} +func (x *HistoricalEvent) Id() int { return x.Id_ } +type HistoricalEventAddHfEntityLink struct { + CivId int `json:"civId"` + Hfid int `json:"hfid"` + Link string `json:"link"` + PositionId int `json:"positionId"` +} +type HistoricalEventAddHfHfLink struct { + Hfid int `json:"hfid"` + HfidTarget int `json:"hfidTarget"` +} +type HistoricalEventArtifactClaimFormed struct { + ArtifactId int `json:"artifactId"` + Circumstance string `json:"circumstance"` + Claim string `json:"claim"` + EntityId int `json:"entityId"` + HistFigureId int `json:"histFigureId"` + PositionProfileId int `json:"positionProfileId"` +} +type HistoricalEventArtifactCreated struct { + ArtifactId int `json:"artifactId"` + HistFigureId int `json:"histFigureId"` + SiteId int `json:"siteId"` + UnitId int `json:"unitId"` +} +type HistoricalEventArtifactLost struct { + ArtifactId int `json:"artifactId"` + SiteId int `json:"siteId"` + SubregionId int `json:"subregionId"` +} +type HistoricalEventArtifactStored struct { + ArtifactId int `json:"artifactId"` + HistFigureId int `json:"histFigureId"` + SiteId int `json:"siteId"` + UnitId int `json:"unitId"` +} +type HistoricalEventAssumeIdentity struct { + IdentityId int `json:"identityId"` + TargetEnid int `json:"targetEnid"` + TricksterHfid int `json:"tricksterHfid"` +} +type HistoricalEventAttackedSite struct { + AttackerCivId int `json:"attackerCivId"` + AttackerGeneralHfid int `json:"attackerGeneralHfid"` + DefenderCivId int `json:"defenderCivId"` + DefenderGeneralHfid int `json:"defenderGeneralHfid"` + SiteCivId int `json:"siteCivId"` + SiteId int `json:"siteId"` +} +type HistoricalEventBodyAbused struct { + Coords string `json:"coords"` + FeatureLayerId int `json:"featureLayerId"` + SiteId int `json:"siteId"` + SubregionId int `json:"subregionId"` +} +type HistoricalEventCeremony struct { + CivId int `json:"civId"` + FeatureLayerId int `json:"featureLayerId"` + OccasionId int `json:"occasionId"` + ScheduleId int `json:"scheduleId"` + SiteId int `json:"siteId"` + SubregionId int `json:"subregionId"` +} +type HistoricalEventChangeHfJob struct { + FeatureLayerId int `json:"featureLayerId"` + Hfid int `json:"hfid"` + SiteId int `json:"siteId"` + SubregionId int `json:"subregionId"` +} +type HistoricalEventChangeHfState struct { + Coords string `json:"coords"` + FeatureLayerId int `json:"featureLayerId"` + Hfid int `json:"hfid"` + Mood string `json:"mood"` + Reason string `json:"reason"` + SiteId int `json:"siteId"` + State string `json:"state"` + SubregionId int `json:"subregionId"` +} +type HistoricalEventChangedCreatureType struct { + ChangeeHfid int `json:"changeeHfid"` + ChangerHfid int `json:"changerHfid"` + NewCaste string `json:"newCaste"` + NewRace string `json:"newRace"` + OldCaste string `json:"oldCaste"` + OldRace string `json:"oldRace"` +} +type HistoricalEventCompetition struct { + CivId int `json:"civId"` + CompetitorHfid []int `json:"competitorHfid"` + FeatureLayerId int `json:"featureLayerId"` + OccasionId int `json:"occasionId"` + ScheduleId int `json:"scheduleId"` + SiteId int `json:"siteId"` + SubregionId int `json:"subregionId"` + WinnerHfid int `json:"winnerHfid"` +} +type HistoricalEventCreatedSite struct { + BuilderHfid int `json:"builderHfid"` + CivId int `json:"civId"` + SiteCivId int `json:"siteCivId"` + SiteId int `json:"siteId"` +} +type HistoricalEventCreatedStructure struct { + BuilderHfid int `json:"builderHfid"` + CivId int `json:"civId"` + SiteCivId int `json:"siteCivId"` + SiteId int `json:"siteId"` + StructureId int `json:"structureId"` +} +type HistoricalEventCreatedWorldConstruction struct { + CivId int `json:"civId"` + MasterWcid int `json:"masterWcid"` + SiteCivId int `json:"siteCivId"` + SiteId1 int `json:"siteId1"` + SiteId2 int `json:"siteId2"` + Wcid int `json:"wcid"` +} +type HistoricalEventCreatureDevoured struct { + FeatureLayerId int `json:"featureLayerId"` + SiteId int `json:"siteId"` + SubregionId int `json:"subregionId"` +} +type HistoricalEventEntityAllianceFormed struct { + InitiatingEnid int `json:"initiatingEnid"` + JoiningEnid int `json:"joiningEnid"` +} +type HistoricalEventEntityBreachFeatureLayer struct { + CivEntityId int `json:"civEntityId"` + FeatureLayerId int `json:"featureLayerId"` + SiteEntityId int `json:"siteEntityId"` + SiteId int `json:"siteId"` +} +type HistoricalEventEntityCreated struct { + EntityId int `json:"entityId"` + SiteId int `json:"siteId"` + StructureId int `json:"structureId"` +} +type HistoricalEventFailedFrameAttempt struct { + ConvicterEnid int `json:"convicterEnid"` + Crime string `json:"crime"` + FooledHfid int `json:"fooledHfid"` + FramerHfid int `json:"framerHfid"` + TargetHfid int `json:"targetHfid"` +} +type HistoricalEventFieldBattle struct { + AttackerCivId int `json:"attackerCivId"` + AttackerGeneralHfid int `json:"attackerGeneralHfid"` + Coords string `json:"coords"` + DefenderCivId int `json:"defenderCivId"` + DefenderGeneralHfid int `json:"defenderGeneralHfid"` + FeatureLayerId int `json:"featureLayerId"` + SubregionId int `json:"subregionId"` +} +type HistoricalEventGamble struct { + GamblerHfid int `json:"gamblerHfid"` + NewAccount int `json:"newAccount"` + OldAccount int `json:"oldAccount"` + SiteId int `json:"siteId"` + StructureId int `json:"structureId"` +} +type HistoricalEventHfAbducted struct { + FeatureLayerId int `json:"featureLayerId"` + SiteId int `json:"siteId"` + SnatcherHfid int `json:"snatcherHfid"` + SubregionId int `json:"subregionId"` + TargetHfid int `json:"targetHfid"` +} +type HistoricalEventHfAttackedSite struct { + AttackerHfid int `json:"attackerHfid"` + DefenderCivId int `json:"defenderCivId"` + SiteCivId int `json:"siteCivId"` + SiteId int `json:"siteId"` +} +type HistoricalEventHfConvicted struct { + ConvictedHfid int `json:"convictedHfid"` + ConvicterEnid int `json:"convicterEnid"` + Crime string `json:"crime"` + PrisonMonths int `json:"prisonMonths"` +} +type HistoricalEventHfDestroyedSite struct { + AttackerHfid int `json:"attackerHfid"` + DefenderCivId int `json:"defenderCivId"` + SiteCivId int `json:"siteCivId"` + SiteId int `json:"siteId"` +} +type HistoricalEventHfDied struct { + Cause string `json:"cause"` + FeatureLayerId int `json:"featureLayerId"` + Hfid int `json:"hfid"` + SiteId int `json:"siteId"` + SlayerCaste string `json:"slayerCaste"` + SlayerHfid int `json:"slayerHfid"` + SlayerItemId int `json:"slayerItemId"` + SlayerRace string `json:"slayerRace"` + SlayerShooterItemId int `json:"slayerShooterItemId"` + SubregionId int `json:"subregionId"` +} +type HistoricalEventHfGainsSecretGoal struct { + Hfid int `json:"hfid"` + SecretGoal string `json:"secretGoal"` +} +type HistoricalEventHfNewPet struct { + Coords string `json:"coords"` + FeatureLayerId int `json:"featureLayerId"` + GroupHfid int `json:"groupHfid"` + SiteId int `json:"siteId"` + SubregionId int `json:"subregionId"` +} +type HistoricalEventHfRelationshipDenied struct { + FeatureLayerId int `json:"featureLayerId"` + Reason string `json:"reason"` + ReasonId int `json:"reasonId"` + Relationship string `json:"relationship"` + SeekerHfid int `json:"seekerHfid"` + SiteId int `json:"siteId"` + SubregionId int `json:"subregionId"` + TargetHfid int `json:"targetHfid"` +} +type HistoricalEventHfSimpleBattleEvent struct { + FeatureLayerId int `json:"featureLayerId"` + Group1Hfid int `json:"group1Hfid"` + Group2Hfid int `json:"group2Hfid"` + SiteId int `json:"siteId"` + SubregionId int `json:"subregionId"` + Subtype string `json:"subtype"` +} +type HistoricalEventHfTravel struct { + Coords string `json:"coords"` + FeatureLayerId int `json:"featureLayerId"` + GroupHfid int `json:"groupHfid"` + Return string `json:"return"` + SiteId int `json:"siteId"` + SubregionId int `json:"subregionId"` +} +type HistoricalEventHfWounded struct { + FeatureLayerId int `json:"featureLayerId"` + SiteId int `json:"siteId"` + SubregionId int `json:"subregionId"` + WoundeeHfid int `json:"woundeeHfid"` + WounderHfid int `json:"wounderHfid"` +} +type HistoricalEventHfsFormedReputationRelationship struct { + FeatureLayerId int `json:"featureLayerId"` + HfRep1Of2 string `json:"hfRep1Of2"` + HfRep2Of1 string `json:"hfRep2Of1"` + Hfid1 int `json:"hfid1"` + Hfid2 int `json:"hfid2"` + IdentityId1 int `json:"identityId1"` + IdentityId2 int `json:"identityId2"` + SiteId int `json:"siteId"` + SubregionId int `json:"subregionId"` +} +type HistoricalEventItemStolen struct { + Circumstance string `json:"circumstance"` + CircumstanceId int `json:"circumstanceId"` +} +type HistoricalEventKnowledgeDiscovered struct { + First string `json:"first"` + Hfid int `json:"hfid"` + Knowledge string `json:"knowledge"` +} +type HistoricalEventMasterpieceItem struct { + EntityId int `json:"entityId"` + Hfid int `json:"hfid"` + SiteId int `json:"siteId"` + SkillAtTime int `json:"skillAtTime"` +} +type HistoricalEventMerchant struct { + DepotEntityId int `json:"depotEntityId"` + SiteId int `json:"siteId"` + TraderEntityId int `json:"traderEntityId"` +} +type HistoricalEventPerformance struct { + CivId int `json:"civId"` + FeatureLayerId int `json:"featureLayerId"` + OccasionId int `json:"occasionId"` + ScheduleId int `json:"scheduleId"` + SiteId int `json:"siteId"` + SubregionId int `json:"subregionId"` +} +type HistoricalEventPlunderedSite struct { + AttackerCivId int `json:"attackerCivId"` + DefenderCivId int `json:"defenderCivId"` + Detected string `json:"detected"` + SiteCivId int `json:"siteCivId"` + SiteId int `json:"siteId"` +} +type HistoricalEventProcession struct { + CivId int `json:"civId"` + FeatureLayerId int `json:"featureLayerId"` + OccasionId int `json:"occasionId"` + ScheduleId int `json:"scheduleId"` + SiteId int `json:"siteId"` + SubregionId int `json:"subregionId"` +} +type HistoricalEventRazedStructure struct { + CivId int `json:"civId"` + SiteId int `json:"siteId"` + StructureId int `json:"structureId"` +} +type HistoricalEventReclaimSite struct { + CivId int `json:"civId"` + SiteCivId int `json:"siteCivId"` + SiteId int `json:"siteId"` +} +type HistoricalEventRemoveHfEntityLink struct { + CivId int `json:"civId"` + Hfid int `json:"hfid"` + Link string `json:"link"` + PositionId int `json:"positionId"` +} +type HistoricalEventRemoveHfHfLink struct { + Hfid int `json:"hfid"` + HfidTarget int `json:"hfidTarget"` +} +type HistoricalEventSiteDispute struct { + Dispute string `json:"dispute"` + EntityId1 int `json:"entityId1"` + EntityId2 int `json:"entityId2"` + SiteId1 int `json:"siteId1"` + SiteId2 int `json:"siteId2"` +} +type HistoricalEventSiteTakenOver struct { + AttackerCivId int `json:"attackerCivId"` + DefenderCivId int `json:"defenderCivId"` + NewSiteCivId int `json:"newSiteCivId"` + SiteCivId int `json:"siteCivId"` + SiteId int `json:"siteId"` +} +type HistoricalEventSquadVsSquad struct { + AHfid int `json:"aHfid"` + ASquadId int `json:"aSquadId"` + DEffect int `json:"dEffect"` + DInteraction int `json:"dInteraction"` + DNumber int `json:"dNumber"` + DRace int `json:"dRace"` + DSlain int `json:"dSlain"` + DSquadId int `json:"dSquadId"` + FeatureLayerId int `json:"featureLayerId"` + SiteId int `json:"siteId"` + StructureId int `json:"structureId"` + SubregionId int `json:"subregionId"` +} +type HistoricalEventTacticalSituation struct { + ATacticianHfid int `json:"aTacticianHfid"` + ATacticsRoll int `json:"aTacticsRoll"` + DTacticianHfid int `json:"dTacticianHfid"` + DTacticsRoll int `json:"dTacticsRoll"` + FeatureLayerId int `json:"featureLayerId"` + SiteId int `json:"siteId"` + Situation string `json:"situation"` + Start string `json:"start"` + StructureId int `json:"structureId"` + SubregionId int `json:"subregionId"` +} +type HistoricalEventWrittenContentComposed struct { + Circumstance string `json:"circumstance"` + CircumstanceId int `json:"circumstanceId"` + HistFigureId int `json:"histFigureId"` + Reason string `json:"reason"` + ReasonId int `json:"reasonId"` + SiteId int `json:"siteId"` + WcId int `json:"wcId"` +} +type HistoricalEventCollection struct { + EndSeconds72 int `json:"endSeconds72"` + EndYear int `json:"endYear"` + Event []int `json:"event"` + Eventcol []int `json:"eventcol"` + Id_ int `json:"id"` + StartSeconds72 int `json:"startSeconds72"` + StartYear int `json:"startYear"` + Type string `json:"type"` +} +func (x *HistoricalEventCollection) Id() int { return x.Id_ } +type HistoricalEventCollectionBattle struct { + AttackingHfid []int `json:"attackingHfid"` + AttackingSquadDeaths []int `json:"attackingSquadDeaths"` + AttackingSquadEntityPop []int `json:"attackingSquadEntityPop"` + AttackingSquadNumber []int `json:"attackingSquadNumber"` + AttackingSquadRace []string `json:"attackingSquadRace"` + AttackingSquadSite []int `json:"attackingSquadSite"` + Coords string `json:"coords"` + DefendingHfid []int `json:"defendingHfid"` + DefendingSquadDeaths []int `json:"defendingSquadDeaths"` + DefendingSquadEntityPop []int `json:"defendingSquadEntityPop"` + DefendingSquadNumber []int `json:"defendingSquadNumber"` + DefendingSquadRace []string `json:"defendingSquadRace"` + DefendingSquadSite []int `json:"defendingSquadSite"` + FeatureLayerId int `json:"featureLayerId"` + IndividualMerc []string `json:"individualMerc"` + Name_ string `json:"name"` + NoncomHfid []int `json:"noncomHfid"` + Outcome string `json:"outcome"` + SiteId int `json:"siteId"` + SubregionId int `json:"subregionId"` + WarEventcol int `json:"warEventcol"` +} +func (x *HistoricalEventCollectionBattle) Name() string { return x.Name_ } +type HistoricalEventCollectionBeastAttack struct { + Coords string `json:"coords"` + DefendingEnid int `json:"defendingEnid"` + FeatureLayerId int `json:"featureLayerId"` + Ordinal int `json:"ordinal"` + ParentEventcol int `json:"parentEventcol"` + SiteId int `json:"siteId"` + SubregionId int `json:"subregionId"` +} +type HistoricalEventCollectionDuel struct { + AttackingHfid int `json:"attackingHfid"` + Coords string `json:"coords"` + DefendingHfid int `json:"defendingHfid"` + FeatureLayerId int `json:"featureLayerId"` + Ordinal int `json:"ordinal"` + ParentEventcol int `json:"parentEventcol"` + SiteId int `json:"siteId"` + SubregionId int `json:"subregionId"` +} +type HistoricalEventCollectionOccasion struct { + CivId int `json:"civId"` + OccasionId int `json:"occasionId"` + Ordinal int `json:"ordinal"` +} +type HistoricalEventCollectionSiteConquered struct { + AttackingEnid int `json:"attackingEnid"` + DefendingEnid int `json:"defendingEnid"` + Ordinal int `json:"ordinal"` + SiteId int `json:"siteId"` + WarEventcol int `json:"warEventcol"` +} +type HistoricalEventCollectionWar struct { + AggressorEntId int `json:"aggressorEntId"` + DefenderEntId int `json:"defenderEntId"` + Name_ string `json:"name"` +} +func (x *HistoricalEventCollectionWar) Name() string { return x.Name_ } +type HistoricalFigure struct { + Appeared int `json:"appeared"` + AssociatedType string `json:"associatedType"` + BirthSeconds72 int `json:"birthSeconds72"` + BirthYear int `json:"birthYear"` + Caste string `json:"caste"` + CurrentIdentityId int `json:"currentIdentityId"` + DeathSeconds72 int `json:"deathSeconds72"` + DeathYear int `json:"deathYear"` + Deity string `json:"deity"` + EntPopId int `json:"entPopId"` + EntityFormerPositionLink []EntityFormerPositionLink `json:"entityFormerPositionLink"` + EntityLink []EntityLink `json:"entityLink"` + EntityPositionLink []EntityPositionLink `json:"entityPositionLink"` + EntityReputation map[int]* `json:"entityReputation"` + EntitySquadLink EntitySquadLink `json:"entitySquadLink"` + Force string `json:"force"` + Goal []string `json:"goal"` + HfLink []HfLink `json:"hfLink"` + HfSkill []HfSkill `json:"hfSkill"` + HoldsArtifact int `json:"holdsArtifact"` + Id_ int `json:"id"` + InteractionKnowledge []string `json:"interactionKnowledge"` + IntrigueActor IntrigueActor `json:"intrigueActor"` + IntriguePlot []IntriguePlot `json:"intriguePlot"` + JourneyPet []string `json:"journeyPet"` + Name_ string `json:"name"` + Race string `json:"race"` + RelationshipProfileHfHistorical RelationshipProfileHfHistorical `json:"relationshipProfileHfHistorical"` + RelationshipProfileHfVisual []RelationshipProfileHfVisual `json:"relationshipProfileHfVisual"` + SiteLink SiteLink `json:"siteLink"` + Sphere []string `json:"sphere"` + UsedIdentityId int `json:"usedIdentityId"` + VagueRelationship []VagueRelationship `json:"vagueRelationship"` +} +func (x *HistoricalFigure) Id() int { return x.Id_ } +func (x *HistoricalFigure) Name() string { return x.Name_ } +type IntrigueActor struct { + Hfid int `json:"hfid"` + LocalId int `json:"localId"` + Role string `json:"role"` + Strategy string `json:"strategy"` +} +type IntriguePlot struct { + ActorId int `json:"actorId"` + ArtifactId int `json:"artifactId"` + EntityId int `json:"entityId"` + LocalId int `json:"localId"` + OnHold string `json:"onHold"` + Type string `json:"type"` +} +type Item struct { + NameString string `json:"nameString"` + PageNumber int `json:"pageNumber"` + PageWrittenContentId int `json:"pageWrittenContentId"` + WritingWrittenContentId int `json:"writingWrittenContentId"` +} +type MusicalForm struct { + Description string `json:"description"` + Id_ int `json:"id"` +} +func (x *MusicalForm) Id() int { return x.Id_ } +type PoeticForm struct { + Description string `json:"description"` + Id_ int `json:"id"` +} +func (x *PoeticForm) Id() int { return x.Id_ } +type Region struct { + Id_ int `json:"id"` + Name_ string `json:"name"` + Type string `json:"type"` +} +func (x *Region) Id() int { return x.Id_ } +func (x *Region) Name() string { return x.Name_ } +type RelationshipProfileHfHistorical struct { + Fear int `json:"fear"` + HfId int `json:"hfId"` + Love int `json:"love"` + Loyalty int `json:"loyalty"` + Respect int `json:"respect"` + Trust int `json:"trust"` +} +type RelationshipProfileHfVisual struct { + Fear int `json:"fear"` + HfId int `json:"hfId"` + KnownIdentityId int `json:"knownIdentityId"` + LastMeetSeconds72 int `json:"lastMeetSeconds72"` + LastMeetYear int `json:"lastMeetYear"` + Love int `json:"love"` + Loyalty int `json:"loyalty"` + MeetCount int `json:"meetCount"` + RepFriendly int `json:"repFriendly"` + RepInformationSource int `json:"repInformationSource"` + Respect int `json:"respect"` + Trust int `json:"trust"` +} +type Site struct { + Id_ int `json:"id"` + Type string `json:"type"` +} +func (x *Site) Id() int { return x.Id_ } +type SiteCamp struct { + Coords string `json:"coords"` + Name_ string `json:"name"` + Rectangle string `json:"rectangle"` +} +func (x *SiteCamp) Name() string { return x.Name_ } +type SiteCave struct { + Coords string `json:"coords"` + Name_ string `json:"name"` + Rectangle string `json:"rectangle"` + Structures map[int]*Structure `json:"structures"` +} +func (x *SiteCave) Name() string { return x.Name_ } +type SiteDarkFortress struct { + Coords string `json:"coords"` + Name_ string `json:"name"` + Rectangle string `json:"rectangle"` + Structures map[int]*Structure `json:"structures"` +} +func (x *SiteDarkFortress) Name() string { return x.Name_ } +type SiteDarkPits struct { + Coords string `json:"coords"` + Name_ string `json:"name"` + Rectangle string `json:"rectangle"` +} +func (x *SiteDarkPits) Name() string { return x.Name_ } +type SiteForestRetreat struct { + Coords string `json:"coords"` + Name_ string `json:"name"` + Rectangle string `json:"rectangle"` + Structures map[int]*Structure `json:"structures"` +} +func (x *SiteForestRetreat) Name() string { return x.Name_ } +type SiteFortress struct { + Coords string `json:"coords"` + Name_ string `json:"name"` + Rectangle string `json:"rectangle"` + Structures map[int]*Structure `json:"structures"` +} +func (x *SiteFortress) Name() string { return x.Name_ } +type SiteHamlet struct { + Coords string `json:"coords"` + Name_ string `json:"name"` + Rectangle string `json:"rectangle"` + Structures map[int]*Structure `json:"structures"` +} +func (x *SiteHamlet) Name() string { return x.Name_ } +type SiteHillocks struct { + Coords string `json:"coords"` + Name_ string `json:"name"` + Rectangle string `json:"rectangle"` +} +func (x *SiteHillocks) Name() string { return x.Name_ } +type SiteLabyrinth struct { + Coords string `json:"coords"` + Name_ string `json:"name"` + Rectangle string `json:"rectangle"` +} +func (x *SiteLabyrinth) Name() string { return x.Name_ } +type SiteLair struct { + Coords string `json:"coords"` + Name_ string `json:"name"` + Rectangle string `json:"rectangle"` +} +func (x *SiteLair) Name() string { return x.Name_ } +type SiteShrine struct { + Coords string `json:"coords"` + Name_ string `json:"name"` + Rectangle string `json:"rectangle"` +} +func (x *SiteShrine) Name() string { return x.Name_ } +type SiteTown struct { + Coords string `json:"coords"` + Name_ string `json:"name"` + Rectangle string `json:"rectangle"` + Structures map[int]*Structure `json:"structures"` +} +func (x *SiteTown) Name() string { return x.Name_ } +type SiteVault struct { + Coords string `json:"coords"` + Name_ string `json:"name"` + Rectangle string `json:"rectangle"` +} +func (x *SiteVault) Name() string { return x.Name_ } +type SiteLink struct { + EntityId int `json:"entityId"` + LinkType string `json:"linkType"` + OccupationId int `json:"occupationId"` + SiteId int `json:"siteId"` + SubId int `json:"subId"` +} +type Structure struct { + LocalId int `json:"localId"` + Type string `json:"type"` +} +type StructureTemple struct { + EntityId int `json:"entityId"` + Name_ string `json:"name"` +} +func (x *StructureTemple) Name() string { return x.Name_ } +type UndergroundRegion struct { + Id_ int `json:"id"` + Type string `json:"type"` +} +func (x *UndergroundRegion) Id() int { return x.Id_ } +type VagueRelationship struct { + ChildhoodFriend string `json:"childhoodFriend"` + Hfid int `json:"hfid"` + JealousObsession string `json:"jealousObsession"` + WarBuddy string `json:"warBuddy"` +} +type WrittenContent struct { + AuthorHfid int `json:"authorHfid"` + AuthorRoll int `json:"authorRoll"` + Form string `json:"form"` + FormId int `json:"formId"` + Id_ int `json:"id"` + Style []string `json:"style"` + Title string `json:"title"` +} +func (x *WrittenContent) Id() int { return x.Id_ } diff --git a/generate.go b/generate.go new file mode 100644 index 0000000..76395cf --- /dev/null +++ b/generate.go @@ -0,0 +1,7 @@ +//go:build ignore + +package main + +// func main() { +// generate.Generate() +// } diff --git a/generate/model.go b/generate/model.go new file mode 100644 index 0000000..e20ae22 --- /dev/null +++ b/generate/model.go @@ -0,0 +1,64 @@ +package generate + +import ( + "bufio" + "log" + "net/http" + "os" + "strings" + "text/template" + "time" +) + +func Generate() { + const url = "https://github.com/golang/go/raw/master/CONTRIBUTORS" + + rsp, err := http.Get(url) + die(err) + defer rsp.Body.Close() + + sc := bufio.NewScanner(rsp.Body) + carls := []string{} + + for sc.Scan() { + if strings.Contains(sc.Text(), "Carl") { + carls = append(carls, sc.Text()) + } + } + + die(sc.Err()) + + f, err := os.Create("contributors.go") + die(err) + defer f.Close() + + packageTemplate.Execute(f, struct { + Timestamp time.Time + URL string + Carls []string + }{ + Timestamp: time.Now(), + URL: url, + Carls: carls, + }) +} + +func die(err error) { + if err != nil { + log.Fatal(err) + } +} + +var packageTemplate = template.Must(template.New("").Parse(`// Code generated by go generate; DO NOT EDIT. +// This file was generated by robots at +// {{ .Timestamp }} +// using data from +// {{ .URL }} +package project + +var Contributors = []string{ +{{- range .Carls }} + {{ printf "%q" . }}, +{{- end }} +} +`)) diff --git a/main.go b/main.go index b7d0279..bfda8fc 100644 --- a/main.go +++ b/main.go @@ -1,23 +1,40 @@ package main import ( + "flag" "fmt" + "legendsbrowser/analyze" "legendsbrowser/model" "legendsbrowser/server" "net/http" _ "net/http/pprof" + "os" "runtime" "github.com/gorilla/mux" + "github.com/pkg/profile" ) var world model.World func main() { - // defer profile.Start(profile.MemProfile).Stop() - // go func() { - // http.ListenAndServe(":8081", nil) - // }() + var a string + flag.StringVar(&a, "a", "", "analyze a file") + flag.Parse() + + if len(a) == 0 { + fmt.Println("Usage: defaults.go -a") + flag.PrintDefaults() + os.Exit(1) + } else { + analyze.Analyze(a) + os.Exit(1) + } + + defer profile.Start(profile.MemProfile).Stop() + go func() { + http.ListenAndServe(":8081", nil) + }() fmt.Println("Hallo Welt!") diff --git a/model.json b/model.json new file mode 100644 index 0000000..8d49c14 --- /dev/null +++ b/model.json @@ -0,0 +1,2633 @@ +{ + "artifact": { + "name": "Artifact", + "id": true, + "named": true, + "fields": { + "abs_tile_x": { + "name": "AbsTileX", + "type": "int" + }, + "abs_tile_y": { + "name": "AbsTileY", + "type": "int" + }, + "abs_tile_z": { + "name": "AbsTileZ", + "type": "int" + }, + "holder_hfid": { + "name": "HolderHfid", + "type": "int" + }, + "id": { + "name": "Id", + "type": "int" + }, + "item": { + "name": "Item", + "type": "object" + }, + "name": { + "name": "Name", + "type": "string" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "structure_local_id": { + "name": "StructureLocalId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "dance_form": { + "name": "DanceForm", + "id": true, + "fields": { + "description": { + "name": "Description", + "type": "string" + }, + "id": { + "name": "Id", + "type": "int" + } + } + }, + "df_world": { + "name": "DfWorld", + "fields": { + "artifacts": { + "name": "Artifacts", + "type": "array", + "elements": "artifact" + }, + "dance_forms": { + "name": "DanceForms", + "type": "array", + "elements": "dance_form" + }, + "entities": { + "name": "Entities", + "type": "array", + "elements": "entity" + }, + "entity_populations": { + "name": "EntityPopulations", + "type": "array", + "elements": "entity_population" + }, + "historical_eras": { + "name": "HistoricalEras", + "type": "array", + "elements": "historical_era" + }, + "historical_event_collections": { + "name": "HistoricalEventCollections", + "type": "array", + "elements": "historical_event_collection" + }, + "historical_events": { + "name": "HistoricalEvents", + "type": "array", + "elements": "historical_event" + }, + "historical_figures": { + "name": "HistoricalFigures", + "type": "array", + "elements": "historical_figure" + }, + "musical_forms": { + "name": "MusicalForms", + "type": "array", + "elements": "musical_form" + }, + "poetic_forms": { + "name": "PoeticForms", + "type": "array", + "elements": "poetic_form" + }, + "regions": { + "name": "Regions", + "type": "array", + "elements": "region" + }, + "sites": { + "name": "Sites", + "type": "array", + "elements": "site" + }, + "underground_regions": { + "name": "UndergroundRegions", + "type": "array", + "elements": "underground_region" + }, + "world_constructions": { + "name": "WorldConstructions", + "type": "string" + }, + "written_contents": { + "name": "WrittenContents", + "type": "array", + "elements": "written_content" + } + } + }, + "entity": { + "name": "Entity", + "id": true, + "named": true, + "fields": { + "id": { + "name": "Id", + "type": "int" + }, + "name": { + "name": "Name", + "type": "string" + } + } + }, + "entity_former_position_link": { + "name": "EntityFormerPositionLink", + "fields": { + "end_year": { + "name": "EndYear", + "type": "int" + }, + "entity_id": { + "name": "EntityId", + "type": "int" + }, + "position_profile_id": { + "name": "PositionProfileId", + "type": "int" + }, + "start_year": { + "name": "StartYear", + "type": "int" + } + } + }, + "entity_link": { + "name": "EntityLink", + "fields": { + "entity_id": { + "name": "EntityId", + "type": "int" + }, + "link_strength": { + "name": "LinkStrength", + "type": "int" + }, + "link_type": { + "name": "LinkType", + "type": "string" + } + } + }, + "entity_position_link": { + "name": "EntityPositionLink", + "fields": { + "entity_id": { + "name": "EntityId", + "type": "int" + }, + "position_profile_id": { + "name": "PositionProfileId", + "type": "int" + }, + "start_year": { + "name": "StartYear", + "type": "int" + } + } + }, + "entity_squad_link": { + "name": "EntitySquadLink", + "fields": { + "entity_id": { + "name": "EntityId", + "type": "int" + }, + "squad_id": { + "name": "SquadId", + "type": "int" + }, + "squad_position": { + "name": "SquadPosition", + "type": "int" + }, + "start_year": { + "name": "StartYear", + "type": "int" + } + } + }, + "hf_link": { + "name": "HfLink", + "fields": { + "hfid": { + "name": "Hfid", + "type": "int" + }, + "link_strength": { + "name": "LinkStrength", + "type": "int" + }, + "link_type": { + "name": "LinkType", + "type": "string" + } + } + }, + "hf_skill": { + "name": "HfSkill", + "fields": { + "skill": { + "name": "Skill", + "type": "string" + }, + "total_ip": { + "name": "TotalIp", + "type": "int" + } + } + }, + "historical_era": { + "name": "HistoricalEra", + "named": true, + "fields": { + "name": { + "name": "Name", + "type": "string" + }, + "start_year": { + "name": "StartYear", + "type": "int" + } + } + }, + "historical_event": { + "name": "HistoricalEvent", + "id": true, + "typed": true, + "fields": { + "id": { + "name": "Id", + "type": "int" + }, + "seconds72": { + "name": "Seconds72", + "type": "int" + }, + "type": { + "name": "Type", + "type": "string" + }, + "year": { + "name": "Year", + "type": "int" + } + } + }, + "historical_eventAddHfEntityLink": { + "name": "HistoricalEventAddHfEntityLink", + "fields": { + "civ_id": { + "name": "CivId", + "type": "int" + }, + "hfid": { + "name": "Hfid", + "type": "int" + }, + "link": { + "name": "Link", + "type": "string" + }, + "position_id": { + "name": "PositionId", + "type": "int" + } + } + }, + "historical_eventAddHfHfLink": { + "name": "HistoricalEventAddHfHfLink", + "fields": { + "hfid": { + "name": "Hfid", + "type": "int" + }, + "hfid_target": { + "name": "HfidTarget", + "type": "int" + } + } + }, + "historical_eventArtifactClaimFormed": { + "name": "HistoricalEventArtifactClaimFormed", + "fields": { + "artifact_id": { + "name": "ArtifactId", + "type": "int" + }, + "circumstance": { + "name": "Circumstance", + "type": "string" + }, + "claim": { + "name": "Claim", + "type": "string" + }, + "entity_id": { + "name": "EntityId", + "type": "int" + }, + "hist_figure_id": { + "name": "HistFigureId", + "type": "int" + }, + "position_profile_id": { + "name": "PositionProfileId", + "type": "int" + } + } + }, + "historical_eventArtifactCreated": { + "name": "HistoricalEventArtifactCreated", + "fields": { + "artifact_id": { + "name": "ArtifactId", + "type": "int" + }, + "hist_figure_id": { + "name": "HistFigureId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "unit_id": { + "name": "UnitId", + "type": "int" + } + } + }, + "historical_eventArtifactLost": { + "name": "HistoricalEventArtifactLost", + "fields": { + "artifact_id": { + "name": "ArtifactId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "historical_eventArtifactStored": { + "name": "HistoricalEventArtifactStored", + "fields": { + "artifact_id": { + "name": "ArtifactId", + "type": "int" + }, + "hist_figure_id": { + "name": "HistFigureId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "unit_id": { + "name": "UnitId", + "type": "int" + } + } + }, + "historical_eventAssumeIdentity": { + "name": "HistoricalEventAssumeIdentity", + "fields": { + "identity_id": { + "name": "IdentityId", + "type": "int" + }, + "target_enid": { + "name": "TargetEnid", + "type": "int" + }, + "trickster_hfid": { + "name": "TricksterHfid", + "type": "int" + } + } + }, + "historical_eventAttackedSite": { + "name": "HistoricalEventAttackedSite", + "fields": { + "attacker_civ_id": { + "name": "AttackerCivId", + "type": "int" + }, + "attacker_general_hfid": { + "name": "AttackerGeneralHfid", + "type": "int" + }, + "defender_civ_id": { + "name": "DefenderCivId", + "type": "int" + }, + "defender_general_hfid": { + "name": "DefenderGeneralHfid", + "type": "int" + }, + "site_civ_id": { + "name": "SiteCivId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + } + } + }, + "historical_eventBodyAbused": { + "name": "HistoricalEventBodyAbused", + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "historical_eventCeremony": { + "name": "HistoricalEventCeremony", + "fields": { + "civ_id": { + "name": "CivId", + "type": "int" + }, + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "occasion_id": { + "name": "OccasionId", + "type": "int" + }, + "schedule_id": { + "name": "ScheduleId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "historical_eventChangeHfJob": { + "name": "HistoricalEventChangeHfJob", + "fields": { + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "hfid": { + "name": "Hfid", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "historical_eventChangeHfState": { + "name": "HistoricalEventChangeHfState", + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "hfid": { + "name": "Hfid", + "type": "int" + }, + "mood": { + "name": "Mood", + "type": "string" + }, + "reason": { + "name": "Reason", + "type": "string" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "state": { + "name": "State", + "type": "string" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "historical_eventChangedCreatureType": { + "name": "HistoricalEventChangedCreatureType", + "fields": { + "changee_hfid": { + "name": "ChangeeHfid", + "type": "int" + }, + "changer_hfid": { + "name": "ChangerHfid", + "type": "int" + }, + "new_caste": { + "name": "NewCaste", + "type": "string" + }, + "new_race": { + "name": "NewRace", + "type": "string" + }, + "old_caste": { + "name": "OldCaste", + "type": "string" + }, + "old_race": { + "name": "OldRace", + "type": "string" + } + } + }, + "historical_eventCompetition": { + "name": "HistoricalEventCompetition", + "fields": { + "civ_id": { + "name": "CivId", + "type": "int" + }, + "competitor_hfid": { + "name": "CompetitorHfid", + "type": "int", + "multiple": true + }, + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "occasion_id": { + "name": "OccasionId", + "type": "int" + }, + "schedule_id": { + "name": "ScheduleId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + }, + "winner_hfid": { + "name": "WinnerHfid", + "type": "int" + } + } + }, + "historical_eventCreatedSite": { + "name": "HistoricalEventCreatedSite", + "fields": { + "builder_hfid": { + "name": "BuilderHfid", + "type": "int" + }, + "civ_id": { + "name": "CivId", + "type": "int" + }, + "site_civ_id": { + "name": "SiteCivId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + } + } + }, + "historical_eventCreatedStructure": { + "name": "HistoricalEventCreatedStructure", + "fields": { + "builder_hfid": { + "name": "BuilderHfid", + "type": "int" + }, + "civ_id": { + "name": "CivId", + "type": "int" + }, + "site_civ_id": { + "name": "SiteCivId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "structure_id": { + "name": "StructureId", + "type": "int" + } + } + }, + "historical_eventCreatedWorldConstruction": { + "name": "HistoricalEventCreatedWorldConstruction", + "fields": { + "civ_id": { + "name": "CivId", + "type": "int" + }, + "master_wcid": { + "name": "MasterWcid", + "type": "int" + }, + "site_civ_id": { + "name": "SiteCivId", + "type": "int" + }, + "site_id1": { + "name": "SiteId1", + "type": "int" + }, + "site_id2": { + "name": "SiteId2", + "type": "int" + }, + "wcid": { + "name": "Wcid", + "type": "int" + } + } + }, + "historical_eventCreatureDevoured": { + "name": "HistoricalEventCreatureDevoured", + "fields": { + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "historical_eventEntityAllianceFormed": { + "name": "HistoricalEventEntityAllianceFormed", + "fields": { + "initiating_enid": { + "name": "InitiatingEnid", + "type": "int" + }, + "joining_enid": { + "name": "JoiningEnid", + "type": "int" + } + } + }, + "historical_eventEntityBreachFeatureLayer": { + "name": "HistoricalEventEntityBreachFeatureLayer", + "fields": { + "civ_entity_id": { + "name": "CivEntityId", + "type": "int" + }, + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "site_entity_id": { + "name": "SiteEntityId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + } + } + }, + "historical_eventEntityCreated": { + "name": "HistoricalEventEntityCreated", + "fields": { + "entity_id": { + "name": "EntityId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "structure_id": { + "name": "StructureId", + "type": "int" + } + } + }, + "historical_eventFailedFrameAttempt": { + "name": "HistoricalEventFailedFrameAttempt", + "fields": { + "convicter_enid": { + "name": "ConvicterEnid", + "type": "int" + }, + "crime": { + "name": "Crime", + "type": "string" + }, + "fooled_hfid": { + "name": "FooledHfid", + "type": "int" + }, + "framer_hfid": { + "name": "FramerHfid", + "type": "int" + }, + "target_hfid": { + "name": "TargetHfid", + "type": "int" + } + } + }, + "historical_eventFieldBattle": { + "name": "HistoricalEventFieldBattle", + "fields": { + "attacker_civ_id": { + "name": "AttackerCivId", + "type": "int" + }, + "attacker_general_hfid": { + "name": "AttackerGeneralHfid", + "type": "int" + }, + "coords": { + "name": "Coords", + "type": "string" + }, + "defender_civ_id": { + "name": "DefenderCivId", + "type": "int" + }, + "defender_general_hfid": { + "name": "DefenderGeneralHfid", + "type": "int" + }, + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "historical_eventGamble": { + "name": "HistoricalEventGamble", + "fields": { + "gambler_hfid": { + "name": "GamblerHfid", + "type": "int" + }, + "new_account": { + "name": "NewAccount", + "type": "int" + }, + "old_account": { + "name": "OldAccount", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "structure_id": { + "name": "StructureId", + "type": "int" + } + } + }, + "historical_eventHfAbducted": { + "name": "HistoricalEventHfAbducted", + "fields": { + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "snatcher_hfid": { + "name": "SnatcherHfid", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + }, + "target_hfid": { + "name": "TargetHfid", + "type": "int" + } + } + }, + "historical_eventHfAttackedSite": { + "name": "HistoricalEventHfAttackedSite", + "fields": { + "attacker_hfid": { + "name": "AttackerHfid", + "type": "int" + }, + "defender_civ_id": { + "name": "DefenderCivId", + "type": "int" + }, + "site_civ_id": { + "name": "SiteCivId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + } + } + }, + "historical_eventHfConvicted": { + "name": "HistoricalEventHfConvicted", + "fields": { + "convicted_hfid": { + "name": "ConvictedHfid", + "type": "int" + }, + "convicter_enid": { + "name": "ConvicterEnid", + "type": "int" + }, + "crime": { + "name": "Crime", + "type": "string" + }, + "prison_months": { + "name": "PrisonMonths", + "type": "int" + } + } + }, + "historical_eventHfDestroyedSite": { + "name": "HistoricalEventHfDestroyedSite", + "fields": { + "attacker_hfid": { + "name": "AttackerHfid", + "type": "int" + }, + "defender_civ_id": { + "name": "DefenderCivId", + "type": "int" + }, + "site_civ_id": { + "name": "SiteCivId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + } + } + }, + "historical_eventHfDied": { + "name": "HistoricalEventHfDied", + "fields": { + "cause": { + "name": "Cause", + "type": "string" + }, + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "hfid": { + "name": "Hfid", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "slayer_caste": { + "name": "SlayerCaste", + "type": "string" + }, + "slayer_hfid": { + "name": "SlayerHfid", + "type": "int" + }, + "slayer_item_id": { + "name": "SlayerItemId", + "type": "int" + }, + "slayer_race": { + "name": "SlayerRace", + "type": "string" + }, + "slayer_shooter_item_id": { + "name": "SlayerShooterItemId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "historical_eventHfGainsSecretGoal": { + "name": "HistoricalEventHfGainsSecretGoal", + "fields": { + "hfid": { + "name": "Hfid", + "type": "int" + }, + "secret_goal": { + "name": "SecretGoal", + "type": "string" + } + } + }, + "historical_eventHfNewPet": { + "name": "HistoricalEventHfNewPet", + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "group_hfid": { + "name": "GroupHfid", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "historical_eventHfRelationshipDenied": { + "name": "HistoricalEventHfRelationshipDenied", + "fields": { + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "reason": { + "name": "Reason", + "type": "string" + }, + "reason_id": { + "name": "ReasonId", + "type": "int" + }, + "relationship": { + "name": "Relationship", + "type": "string" + }, + "seeker_hfid": { + "name": "SeekerHfid", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + }, + "target_hfid": { + "name": "TargetHfid", + "type": "int" + } + } + }, + "historical_eventHfSimpleBattleEvent": { + "name": "HistoricalEventHfSimpleBattleEvent", + "fields": { + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "group_1_hfid": { + "name": "Group1Hfid", + "type": "int" + }, + "group_2_hfid": { + "name": "Group2Hfid", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + }, + "subtype": { + "name": "Subtype", + "type": "string" + } + } + }, + "historical_eventHfTravel": { + "name": "HistoricalEventHfTravel", + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "group_hfid": { + "name": "GroupHfid", + "type": "int" + }, + "return": { + "name": "Return", + "type": "string" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "historical_eventHfWounded": { + "name": "HistoricalEventHfWounded", + "fields": { + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + }, + "woundee_hfid": { + "name": "WoundeeHfid", + "type": "int" + }, + "wounder_hfid": { + "name": "WounderHfid", + "type": "int" + } + } + }, + "historical_eventHfsFormedReputationRelationship": { + "name": "HistoricalEventHfsFormedReputationRelationship", + "fields": { + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "hf_rep_1_of_2": { + "name": "HfRep1Of2", + "type": "string" + }, + "hf_rep_2_of_1": { + "name": "HfRep2Of1", + "type": "string" + }, + "hfid1": { + "name": "Hfid1", + "type": "int" + }, + "hfid2": { + "name": "Hfid2", + "type": "int" + }, + "identity_id1": { + "name": "IdentityId1", + "type": "int" + }, + "identity_id2": { + "name": "IdentityId2", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "historical_eventItemStolen": { + "name": "HistoricalEventItemStolen", + "fields": { + "circumstance": { + "name": "Circumstance", + "type": "string" + }, + "circumstance_id": { + "name": "CircumstanceId", + "type": "int" + } + } + }, + "historical_eventKnowledgeDiscovered": { + "name": "HistoricalEventKnowledgeDiscovered", + "fields": { + "first": { + "name": "First", + "type": "string" + }, + "hfid": { + "name": "Hfid", + "type": "int" + }, + "knowledge": { + "name": "Knowledge", + "type": "string" + } + } + }, + "historical_eventMasterpieceItem": { + "name": "HistoricalEventMasterpieceItem", + "fields": { + "entity_id": { + "name": "EntityId", + "type": "int" + }, + "hfid": { + "name": "Hfid", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "skill_at_time": { + "name": "SkillAtTime", + "type": "int" + } + } + }, + "historical_eventMerchant": { + "name": "HistoricalEventMerchant", + "fields": { + "depot_entity_id": { + "name": "DepotEntityId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "trader_entity_id": { + "name": "TraderEntityId", + "type": "int" + } + } + }, + "historical_eventPerformance": { + "name": "HistoricalEventPerformance", + "fields": { + "civ_id": { + "name": "CivId", + "type": "int" + }, + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "occasion_id": { + "name": "OccasionId", + "type": "int" + }, + "schedule_id": { + "name": "ScheduleId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "historical_eventPlunderedSite": { + "name": "HistoricalEventPlunderedSite", + "fields": { + "attacker_civ_id": { + "name": "AttackerCivId", + "type": "int" + }, + "defender_civ_id": { + "name": "DefenderCivId", + "type": "int" + }, + "detected": { + "name": "Detected", + "type": "string" + }, + "site_civ_id": { + "name": "SiteCivId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + } + } + }, + "historical_eventProcession": { + "name": "HistoricalEventProcession", + "fields": { + "civ_id": { + "name": "CivId", + "type": "int" + }, + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "occasion_id": { + "name": "OccasionId", + "type": "int" + }, + "schedule_id": { + "name": "ScheduleId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "historical_eventRazedStructure": { + "name": "HistoricalEventRazedStructure", + "fields": { + "civ_id": { + "name": "CivId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "structure_id": { + "name": "StructureId", + "type": "int" + } + } + }, + "historical_eventReclaimSite": { + "name": "HistoricalEventReclaimSite", + "fields": { + "civ_id": { + "name": "CivId", + "type": "int" + }, + "site_civ_id": { + "name": "SiteCivId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + } + } + }, + "historical_eventRemoveHfEntityLink": { + "name": "HistoricalEventRemoveHfEntityLink", + "fields": { + "civ_id": { + "name": "CivId", + "type": "int" + }, + "hfid": { + "name": "Hfid", + "type": "int" + }, + "link": { + "name": "Link", + "type": "string" + }, + "position_id": { + "name": "PositionId", + "type": "int" + } + } + }, + "historical_eventRemoveHfHfLink": { + "name": "HistoricalEventRemoveHfHfLink", + "fields": { + "hfid": { + "name": "Hfid", + "type": "int" + }, + "hfid_target": { + "name": "HfidTarget", + "type": "int" + } + } + }, + "historical_eventSiteDispute": { + "name": "HistoricalEventSiteDispute", + "fields": { + "dispute": { + "name": "Dispute", + "type": "string" + }, + "entity_id_1": { + "name": "EntityId1", + "type": "int" + }, + "entity_id_2": { + "name": "EntityId2", + "type": "int" + }, + "site_id_1": { + "name": "SiteId1", + "type": "int" + }, + "site_id_2": { + "name": "SiteId2", + "type": "int" + } + } + }, + "historical_eventSiteTakenOver": { + "name": "HistoricalEventSiteTakenOver", + "fields": { + "attacker_civ_id": { + "name": "AttackerCivId", + "type": "int" + }, + "defender_civ_id": { + "name": "DefenderCivId", + "type": "int" + }, + "new_site_civ_id": { + "name": "NewSiteCivId", + "type": "int" + }, + "site_civ_id": { + "name": "SiteCivId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + } + } + }, + "historical_eventSquadVsSquad": { + "name": "HistoricalEventSquadVsSquad", + "fields": { + "a_hfid": { + "name": "AHfid", + "type": "int" + }, + "a_squad_id": { + "name": "ASquadId", + "type": "int" + }, + "d_effect": { + "name": "DEffect", + "type": "int" + }, + "d_interaction": { + "name": "DInteraction", + "type": "int" + }, + "d_number": { + "name": "DNumber", + "type": "int" + }, + "d_race": { + "name": "DRace", + "type": "int" + }, + "d_slain": { + "name": "DSlain", + "type": "int" + }, + "d_squad_id": { + "name": "DSquadId", + "type": "int" + }, + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "structure_id": { + "name": "StructureId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "historical_eventTacticalSituation": { + "name": "HistoricalEventTacticalSituation", + "fields": { + "a_tactician_hfid": { + "name": "ATacticianHfid", + "type": "int" + }, + "a_tactics_roll": { + "name": "ATacticsRoll", + "type": "int" + }, + "d_tactician_hfid": { + "name": "DTacticianHfid", + "type": "int" + }, + "d_tactics_roll": { + "name": "DTacticsRoll", + "type": "int" + }, + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "situation": { + "name": "Situation", + "type": "string" + }, + "start": { + "name": "Start", + "type": "string" + }, + "structure_id": { + "name": "StructureId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "historical_eventWrittenContentComposed": { + "name": "HistoricalEventWrittenContentComposed", + "fields": { + "circumstance": { + "name": "Circumstance", + "type": "string" + }, + "circumstance_id": { + "name": "CircumstanceId", + "type": "int" + }, + "hist_figure_id": { + "name": "HistFigureId", + "type": "int" + }, + "reason": { + "name": "Reason", + "type": "string" + }, + "reason_id": { + "name": "ReasonId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "wc_id": { + "name": "WcId", + "type": "int" + } + } + }, + "historical_event_collection": { + "name": "HistoricalEventCollection", + "id": true, + "typed": true, + "fields": { + "end_seconds72": { + "name": "EndSeconds72", + "type": "int" + }, + "end_year": { + "name": "EndYear", + "type": "int" + }, + "event": { + "name": "Event", + "type": "int", + "multiple": true + }, + "eventcol": { + "name": "Eventcol", + "type": "int", + "multiple": true + }, + "id": { + "name": "Id", + "type": "int" + }, + "start_seconds72": { + "name": "StartSeconds72", + "type": "int" + }, + "start_year": { + "name": "StartYear", + "type": "int" + }, + "type": { + "name": "Type", + "type": "string" + } + } + }, + "historical_event_collectionBattle": { + "name": "HistoricalEventCollectionBattle", + "named": true, + "fields": { + "attacking_hfid": { + "name": "AttackingHfid", + "type": "int", + "multiple": true + }, + "attacking_squad_deaths": { + "name": "AttackingSquadDeaths", + "type": "int", + "multiple": true + }, + "attacking_squad_entity_pop": { + "name": "AttackingSquadEntityPop", + "type": "int", + "multiple": true + }, + "attacking_squad_number": { + "name": "AttackingSquadNumber", + "type": "int", + "multiple": true + }, + "attacking_squad_race": { + "name": "AttackingSquadRace", + "type": "string", + "multiple": true + }, + "attacking_squad_site": { + "name": "AttackingSquadSite", + "type": "int", + "multiple": true + }, + "coords": { + "name": "Coords", + "type": "string" + }, + "defending_hfid": { + "name": "DefendingHfid", + "type": "int", + "multiple": true + }, + "defending_squad_deaths": { + "name": "DefendingSquadDeaths", + "type": "int", + "multiple": true + }, + "defending_squad_entity_pop": { + "name": "DefendingSquadEntityPop", + "type": "int", + "multiple": true + }, + "defending_squad_number": { + "name": "DefendingSquadNumber", + "type": "int", + "multiple": true + }, + "defending_squad_race": { + "name": "DefendingSquadRace", + "type": "string", + "multiple": true + }, + "defending_squad_site": { + "name": "DefendingSquadSite", + "type": "int", + "multiple": true + }, + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "individual_merc": { + "name": "IndividualMerc", + "type": "string", + "multiple": true + }, + "name": { + "name": "Name", + "type": "string" + }, + "noncom_hfid": { + "name": "NoncomHfid", + "type": "int", + "multiple": true + }, + "outcome": { + "name": "Outcome", + "type": "string" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + }, + "war_eventcol": { + "name": "WarEventcol", + "type": "int" + } + } + }, + "historical_event_collectionBeastAttack": { + "name": "HistoricalEventCollectionBeastAttack", + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "defending_enid": { + "name": "DefendingEnid", + "type": "int" + }, + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "ordinal": { + "name": "Ordinal", + "type": "int" + }, + "parent_eventcol": { + "name": "ParentEventcol", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "historical_event_collectionDuel": { + "name": "HistoricalEventCollectionDuel", + "fields": { + "attacking_hfid": { + "name": "AttackingHfid", + "type": "int" + }, + "coords": { + "name": "Coords", + "type": "string" + }, + "defending_hfid": { + "name": "DefendingHfid", + "type": "int" + }, + "feature_layer_id": { + "name": "FeatureLayerId", + "type": "int" + }, + "ordinal": { + "name": "Ordinal", + "type": "int" + }, + "parent_eventcol": { + "name": "ParentEventcol", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "subregion_id": { + "name": "SubregionId", + "type": "int" + } + } + }, + "historical_event_collectionOccasion": { + "name": "HistoricalEventCollectionOccasion", + "fields": { + "civ_id": { + "name": "CivId", + "type": "int" + }, + "occasion_id": { + "name": "OccasionId", + "type": "int" + }, + "ordinal": { + "name": "Ordinal", + "type": "int" + } + } + }, + "historical_event_collectionSiteConquered": { + "name": "HistoricalEventCollectionSiteConquered", + "fields": { + "attacking_enid": { + "name": "AttackingEnid", + "type": "int" + }, + "defending_enid": { + "name": "DefendingEnid", + "type": "int" + }, + "ordinal": { + "name": "Ordinal", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "war_eventcol": { + "name": "WarEventcol", + "type": "int" + } + } + }, + "historical_event_collectionWar": { + "name": "HistoricalEventCollectionWar", + "named": true, + "fields": { + "aggressor_ent_id": { + "name": "AggressorEntId", + "type": "int" + }, + "defender_ent_id": { + "name": "DefenderEntId", + "type": "int" + }, + "name": { + "name": "Name", + "type": "string" + } + } + }, + "historical_figure": { + "name": "HistoricalFigure", + "id": true, + "named": true, + "fields": { + "appeared": { + "name": "Appeared", + "type": "int" + }, + "associated_type": { + "name": "AssociatedType", + "type": "string" + }, + "birth_seconds72": { + "name": "BirthSeconds72", + "type": "int" + }, + "birth_year": { + "name": "BirthYear", + "type": "int" + }, + "caste": { + "name": "Caste", + "type": "string" + }, + "current_identity_id": { + "name": "CurrentIdentityId", + "type": "int" + }, + "death_seconds72": { + "name": "DeathSeconds72", + "type": "int" + }, + "death_year": { + "name": "DeathYear", + "type": "int" + }, + "deity": { + "name": "Deity", + "type": "string" + }, + "ent_pop_id": { + "name": "EntPopId", + "type": "int" + }, + "entity_former_position_link": { + "name": "EntityFormerPositionLink", + "type": "object", + "multiple": true + }, + "entity_link": { + "name": "EntityLink", + "type": "object", + "multiple": true + }, + "entity_position_link": { + "name": "EntityPositionLink", + "type": "object", + "multiple": true + }, + "entity_reputation": { + "name": "EntityReputation", + "type": "array", + "elements": "entity_id" + }, + "entity_squad_link": { + "name": "EntitySquadLink", + "type": "object" + }, + "force": { + "name": "Force", + "type": "string" + }, + "goal": { + "name": "Goal", + "type": "string", + "multiple": true + }, + "hf_link": { + "name": "HfLink", + "type": "object", + "multiple": true + }, + "hf_skill": { + "name": "HfSkill", + "type": "object", + "multiple": true + }, + "holds_artifact": { + "name": "HoldsArtifact", + "type": "int" + }, + "id": { + "name": "Id", + "type": "int" + }, + "interaction_knowledge": { + "name": "InteractionKnowledge", + "type": "string", + "multiple": true + }, + "intrigue_actor": { + "name": "IntrigueActor", + "type": "object" + }, + "intrigue_plot": { + "name": "IntriguePlot", + "type": "object", + "multiple": true + }, + "journey_pet": { + "name": "JourneyPet", + "type": "string", + "multiple": true + }, + "name": { + "name": "Name", + "type": "string" + }, + "race": { + "name": "Race", + "type": "string" + }, + "relationship_profile_hf_historical": { + "name": "RelationshipProfileHfHistorical", + "type": "object" + }, + "relationship_profile_hf_visual": { + "name": "RelationshipProfileHfVisual", + "type": "object", + "multiple": true + }, + "site_link": { + "name": "SiteLink", + "type": "object" + }, + "sphere": { + "name": "Sphere", + "type": "string", + "multiple": true + }, + "used_identity_id": { + "name": "UsedIdentityId", + "type": "int" + }, + "vague_relationship": { + "name": "VagueRelationship", + "type": "object", + "multiple": true + } + } + }, + "intrigue_actor": { + "name": "IntrigueActor", + "fields": { + "hfid": { + "name": "Hfid", + "type": "int" + }, + "local_id": { + "name": "LocalId", + "type": "int" + }, + "role": { + "name": "Role", + "type": "string" + }, + "strategy": { + "name": "Strategy", + "type": "string" + } + } + }, + "intrigue_plot": { + "name": "IntriguePlot", + "typed": true, + "fields": { + "actor_id": { + "name": "ActorId", + "type": "int" + }, + "artifact_id": { + "name": "ArtifactId", + "type": "int" + }, + "entity_id": { + "name": "EntityId", + "type": "int" + }, + "local_id": { + "name": "LocalId", + "type": "int" + }, + "on_hold": { + "name": "OnHold", + "type": "string" + }, + "type": { + "name": "Type", + "type": "string" + } + } + }, + "item": { + "name": "Item", + "fields": { + "name_string": { + "name": "NameString", + "type": "string" + }, + "page_number": { + "name": "PageNumber", + "type": "int" + }, + "page_written_content_id": { + "name": "PageWrittenContentId", + "type": "int" + }, + "writing_written_content_id": { + "name": "WritingWrittenContentId", + "type": "int" + } + } + }, + "musical_form": { + "name": "MusicalForm", + "id": true, + "fields": { + "description": { + "name": "Description", + "type": "string" + }, + "id": { + "name": "Id", + "type": "int" + } + } + }, + "poetic_form": { + "name": "PoeticForm", + "id": true, + "fields": { + "description": { + "name": "Description", + "type": "string" + }, + "id": { + "name": "Id", + "type": "int" + } + } + }, + "region": { + "name": "Region", + "id": true, + "named": true, + "typed": true, + "fields": { + "id": { + "name": "Id", + "type": "int" + }, + "name": { + "name": "Name", + "type": "string" + }, + "type": { + "name": "Type", + "type": "string" + } + } + }, + "relationship_profile_hf_historical": { + "name": "RelationshipProfileHfHistorical", + "fields": { + "fear": { + "name": "Fear", + "type": "int" + }, + "hf_id": { + "name": "HfId", + "type": "int" + }, + "love": { + "name": "Love", + "type": "int" + }, + "loyalty": { + "name": "Loyalty", + "type": "int" + }, + "respect": { + "name": "Respect", + "type": "int" + }, + "trust": { + "name": "Trust", + "type": "int" + } + } + }, + "relationship_profile_hf_visual": { + "name": "RelationshipProfileHfVisual", + "fields": { + "fear": { + "name": "Fear", + "type": "int" + }, + "hf_id": { + "name": "HfId", + "type": "int" + }, + "known_identity_id": { + "name": "KnownIdentityId", + "type": "int" + }, + "last_meet_seconds72": { + "name": "LastMeetSeconds72", + "type": "int" + }, + "last_meet_year": { + "name": "LastMeetYear", + "type": "int" + }, + "love": { + "name": "Love", + "type": "int" + }, + "loyalty": { + "name": "Loyalty", + "type": "int" + }, + "meet_count": { + "name": "MeetCount", + "type": "int" + }, + "rep_friendly": { + "name": "RepFriendly", + "type": "int" + }, + "rep_information_source": { + "name": "RepInformationSource", + "type": "int" + }, + "respect": { + "name": "Respect", + "type": "int" + }, + "trust": { + "name": "Trust", + "type": "int" + } + } + }, + "site": { + "name": "Site", + "id": true, + "typed": true, + "fields": { + "id": { + "name": "Id", + "type": "int" + }, + "type": { + "name": "Type", + "type": "string" + } + } + }, + "siteCamp": { + "name": "SiteCamp", + "named": true, + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "name": { + "name": "Name", + "type": "string" + }, + "rectangle": { + "name": "Rectangle", + "type": "string" + } + } + }, + "siteCave": { + "name": "SiteCave", + "named": true, + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "name": { + "name": "Name", + "type": "string" + }, + "rectangle": { + "name": "Rectangle", + "type": "string" + }, + "structures": { + "name": "Structures", + "type": "array", + "elements": "structure" + } + } + }, + "siteDarkFortress": { + "name": "SiteDarkFortress", + "named": true, + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "name": { + "name": "Name", + "type": "string" + }, + "rectangle": { + "name": "Rectangle", + "type": "string" + }, + "structures": { + "name": "Structures", + "type": "array", + "elements": "structure" + } + } + }, + "siteDarkPits": { + "name": "SiteDarkPits", + "named": true, + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "name": { + "name": "Name", + "type": "string" + }, + "rectangle": { + "name": "Rectangle", + "type": "string" + } + } + }, + "siteForestRetreat": { + "name": "SiteForestRetreat", + "named": true, + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "name": { + "name": "Name", + "type": "string" + }, + "rectangle": { + "name": "Rectangle", + "type": "string" + }, + "structures": { + "name": "Structures", + "type": "array", + "elements": "structure" + } + } + }, + "siteFortress": { + "name": "SiteFortress", + "named": true, + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "name": { + "name": "Name", + "type": "string" + }, + "rectangle": { + "name": "Rectangle", + "type": "string" + }, + "structures": { + "name": "Structures", + "type": "array", + "elements": "structure" + } + } + }, + "siteHamlet": { + "name": "SiteHamlet", + "named": true, + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "name": { + "name": "Name", + "type": "string" + }, + "rectangle": { + "name": "Rectangle", + "type": "string" + }, + "structures": { + "name": "Structures", + "type": "array", + "elements": "structure" + } + } + }, + "siteHillocks": { + "name": "SiteHillocks", + "named": true, + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "name": { + "name": "Name", + "type": "string" + }, + "rectangle": { + "name": "Rectangle", + "type": "string" + } + } + }, + "siteLabyrinth": { + "name": "SiteLabyrinth", + "named": true, + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "name": { + "name": "Name", + "type": "string" + }, + "rectangle": { + "name": "Rectangle", + "type": "string" + } + } + }, + "siteLair": { + "name": "SiteLair", + "named": true, + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "name": { + "name": "Name", + "type": "string" + }, + "rectangle": { + "name": "Rectangle", + "type": "string" + } + } + }, + "siteShrine": { + "name": "SiteShrine", + "named": true, + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "name": { + "name": "Name", + "type": "string" + }, + "rectangle": { + "name": "Rectangle", + "type": "string" + } + } + }, + "siteTown": { + "name": "SiteTown", + "named": true, + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "name": { + "name": "Name", + "type": "string" + }, + "rectangle": { + "name": "Rectangle", + "type": "string" + }, + "structures": { + "name": "Structures", + "type": "array", + "elements": "structure" + } + } + }, + "siteVault": { + "name": "SiteVault", + "named": true, + "fields": { + "coords": { + "name": "Coords", + "type": "string" + }, + "name": { + "name": "Name", + "type": "string" + }, + "rectangle": { + "name": "Rectangle", + "type": "string" + } + } + }, + "site_link": { + "name": "SiteLink", + "fields": { + "entity_id": { + "name": "EntityId", + "type": "int" + }, + "link_type": { + "name": "LinkType", + "type": "string" + }, + "occupation_id": { + "name": "OccupationId", + "type": "int" + }, + "site_id": { + "name": "SiteId", + "type": "int" + }, + "sub_id": { + "name": "SubId", + "type": "int" + } + } + }, + "structure": { + "name": "Structure", + "typed": true, + "fields": { + "local_id": { + "name": "LocalId", + "type": "int" + }, + "type": { + "name": "Type", + "type": "string" + } + } + }, + "structureTemple": { + "name": "StructureTemple", + "named": true, + "fields": { + "entity_id": { + "name": "EntityId", + "type": "int" + }, + "name": { + "name": "Name", + "type": "string" + } + } + }, + "underground_region": { + "name": "UndergroundRegion", + "id": true, + "typed": true, + "fields": { + "id": { + "name": "Id", + "type": "int" + }, + "type": { + "name": "Type", + "type": "string" + } + } + }, + "vague_relationship": { + "name": "VagueRelationship", + "fields": { + "childhood_friend": { + "name": "ChildhoodFriend", + "type": "string" + }, + "hfid": { + "name": "Hfid", + "type": "int" + }, + "jealous_obsession": { + "name": "JealousObsession", + "type": "string" + }, + "war_buddy": { + "name": "WarBuddy", + "type": "string" + } + } + }, + "written_content": { + "name": "WrittenContent", + "id": true, + "fields": { + "author_hfid": { + "name": "AuthorHfid", + "type": "int" + }, + "author_roll": { + "name": "AuthorRoll", + "type": "int" + }, + "form": { + "name": "Form", + "type": "string" + }, + "form_id": { + "name": "FormId", + "type": "int" + }, + "id": { + "name": "Id", + "type": "int" + }, + "style": { + "name": "Style", + "type": "string", + "multiple": true + }, + "title": { + "name": "Title", + "type": "string" + } + } + } +} \ No newline at end of file diff --git a/model/events.go b/model/events.go index c4948c8..3b727d7 100644 --- a/model/events.go +++ b/model/events.go @@ -1,12 +1,9 @@ package model -import "encoding/xml" - type HistoricalEvent struct { - XMLName xml.Name `xml:"historical_event" json:"-"` - Id_ int `xml:"id" json:"id"` - Year int `xml:"year" json:"year"` - Seconds int `xml:"seconds72" json:"seconds72"` + Id_ int `xml:"id" json:"id"` + Year int `xml:"year" json:"year"` + Seconds int `xml:"seconds72" json:"seconds72"` TypedObject ASupportMercEnid *int `xml:"a_support_merc_enid" json:"aSupportMercEnid,omitempty" legend:"entity"` @@ -226,7 +223,7 @@ type HistoricalEvent struct { WounderHfid *int `xml:"wounder_hfid" json:"wounderHfid,omitempty" legend:"hf"` WrongfulConviction *string `xml:"wrongful_conviction" json:"wrongfulConviction,omitempty"` - OtherElements + //OtherElements } func (r *HistoricalEvent) Id() int { return r.Id_ } diff --git a/model/model.go b/model/model.go index d25c9d0..ea2ddee 100644 --- a/model/model.go +++ b/model/model.go @@ -1,40 +1,34 @@ package model -import "encoding/xml" - type Region struct { - XMLName xml.Name `xml:"region" json:"-"` NamedObject Type string `xml:"type" json:"type"` - OtherElements + // OtherElements EventObject } type UndergroundRegion struct { - XMLName xml.Name `xml:"underground_region" json:"-"` NamedObject Type string `xml:"type" json:"type"` Depth *int `xml:"depth" json:"depth,omitempty"` - OtherElements + // OtherElements EventObject } type Landmass struct { - XMLName xml.Name `xml:"landmass" json:"-"` NamedObject - OtherElements + // OtherElements EventObject } type Site struct { - XMLName xml.Name `xml:"site" json:"-"` NamedObject Type string `xml:"type" json:"type"` Coords string `xml:"coords" json:"coords"` Rectangle string `xml:"rectangle" json:"rectangle"` Structures []Structure `xml:"structures>structure" json:"structures"` - OtherElements + // OtherElements EventObject } @@ -42,23 +36,20 @@ type Site struct { // func (obj Site) name() string { return obj.Name } type Structure struct { - XMLName xml.Name `xml:"structure" json:"-"` - LocalId int `xml:"local_id" json:"localId"` - Name string `xml:"name" json:"name"` - Type string `xml:"type" json:"type"` - OtherElements + LocalId int `xml:"local_id" json:"localId"` + Name string `xml:"name" json:"name"` + Type string `xml:"type" json:"type"` + // OtherElements EventObject } type WorldConstruction struct { - XMLName xml.Name `xml:"world_construction" json:"-"` NamedObject - OtherElements + // OtherElements EventObject } type Artifact struct { - XMLName xml.Name `xml:"artifact" json:"-"` NamedObject SiteId int `xml:"site_id" json:"siteId"` AbsTileX *int `xml:"abs_tile_x" json:"absTileX,omitempty"` @@ -69,13 +60,12 @@ type Artifact struct { StructureLocalId *int `xml:"structure_local_id" json:"structureLocalId,omitempty"` SubregionId *int `xml:"subregion_id" json:"subregionId,omitempty"` - OtherElements + // OtherElements EventObject } type HistoricalFigure struct { - XMLName xml.Name `xml:"historical_figure" json:"-"` NamedObject Race *string `xml:"race" json:"race"` @@ -115,7 +105,7 @@ type HistoricalFigure struct { // UsedIdentityId *[]int `xml:"used_identity_id" json:"usedIdentityId,omitempty" legend:"entity"` // // vague_relationship object - OtherElements + // OtherElements EventObject } @@ -123,7 +113,6 @@ type HistoricalFigure struct { func (r *HistoricalFigure) Type() string { return "hf" } type HistoricalEventCollection struct { - XMLName xml.Name `xml:"historical_event_collection" json:"-"` NamedObject Year int `xml:"year"` Seconds int `xml:"seconds72"` @@ -175,45 +164,38 @@ type HistoricalEventCollection struct { DefendingSquadAnimated *[]string `xml:"defending_squad_animated" json:"defendingSquadAnimated,omitempty"` TargetEntityId *int `xml:"target_entity_id" json:"targetEntityId,omitempty" legend:"entity"` - OtherElements + // OtherElements } type Entity struct { - XMLName xml.Name `xml:"entity" json:"-"` NamedObject - OtherElements + // OtherElements EventObject } type EntityPopulation struct { - XMLName xml.Name `xml:"entity_population" json:"-"` - OtherElements + // OtherElements } type HistoricalEra struct { - XMLName xml.Name `xml:"historical_era" json:"-"` NamedObject StartYear *int `xml:"start_year" json:"startYear,omitempty"` - OtherElements + // OtherElements } type DanceForm struct { - XMLName xml.Name `xml:"dance_form" json:"-"` ArtForm } type MusicalForm struct { - XMLName xml.Name `xml:"musical_form" json:"-"` ArtForm } type PoeticForm struct { - XMLName xml.Name `xml:"poetic_form" json:"-"` ArtForm } type WrittenContent struct { - XMLName xml.Name `xml:"written_content" json:"-"` NamedObject AuthorHfid *int `xml:"author_hfid" json:"authorHfid,omitempty" legend:"hf"` @@ -223,7 +205,7 @@ type WrittenContent struct { Style *[]string `xml:"style" json:"style,omitempty"` Title *string `xml:"title" json:"title,omitempty"` - OtherElements + // OtherElements EventObject } @@ -232,6 +214,6 @@ type ArtForm struct { Description *string `xml:"description" json:"description,omitempty"` - OtherElements + // OtherElements EventObject } diff --git a/model/world.go b/model/world.go index 9152367..4958d79 100644 --- a/model/world.go +++ b/model/world.go @@ -4,7 +4,7 @@ import ( "encoding/xml" "errors" "fmt" - "io" + "legendsbrowser/util" "os" "reflect" "strings" @@ -15,22 +15,6 @@ type World struct { Name string `xml:"name"` AltName string `xml:"altname"` - // Regions []*Region `xml:"regions>region"` - // UndergroundRegions []*UndergroundRegion `xml:"underground_regions>underground_region"` - // Landmasses []*Landmass `xml:"landmasses>landmass"` - // Sites []*Site `xml:"sites>site"` - // WorldConstructions []*WorldConstruction `xml:"world_constructions>world_construction"` - // Artifacts []*Artifact `xml:"artifacts>artifact"` - // HistoricalFigures []*HistoricalFigure //`xml:"historical_figures>historical_figure"` - // HistoricalEvents []*HistoricalEvent //`xml:"historical_events>historical_event"` - // HistoricalEventCollections []*HistoricalEventCollection `xml:"historical_event_collections>historical_event_collection"` - // HistoricalEras []*HistoricalEra `xml:"historical_eras>historical_era"` - // Entities []*Entity `xml:"entities>entity"` - // EntityPopulations []*EntityPopulation `xml:"entity_populations>entity_population"` - // DanceForms []*DanceForm `xml:"dance_forms>dance_form"` - // MusicalForms []*MusicalForm `xml:"musical_forms>musical_form"` - // PoeticForms []*PoeticForm `xml:"poetic_forms>poetic_form"` - // WrittenContents []*WrittenContent `xml:"written_contents>written_content"` OtherElements RegionMap map[int]*Region `xml:"regions>region"` @@ -45,32 +29,11 @@ type World struct { HistoricalEraMap map[int]*HistoricalEra `xml:"historical_eras>historical_era"` EntityMap map[int]*Entity `xml:"entities>entity"` DanceFormMap map[int]*DanceForm `xml:"dance_forms>dance_form"` - MusicalFormMap map[int]*MusicalForm //`xml:"musical_forms>musical_form"` - PoeticFormMap map[int]*PoeticForm // `xml:"poetic_forms>poetic_form"` + MusicalFormMap map[int]*MusicalForm `xml:"musical_forms>musical_form"` + PoeticFormMap map[int]*PoeticForm `xml:"poetic_forms>poetic_form"` WrittenContentMap map[int]*WrittenContent `xml:"written_contents>written_content"` } -var cp437 = []byte(" \t\n \r !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ CueaaaaceeeiiiAAEaAooouuyOU faiounN ") - -// var cp437 = []byte(" \t\n \r !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñÑ ") - -type ConvertReader struct { - r io.Reader - read int -} - -func (c *ConvertReader) Read(b []byte) (n int, err error) { - n, err = c.r.Read(b) - if c.read == 0 && n > 35 { - copy(b[30:35], []byte("UTF-8")) - } - c.read += n - for i := range b { - b[i] = cp437[b[i]] - } - return n, err -} - func (w *World) Load(file string) { xmlFile, err := os.Open(file) if err != nil { @@ -80,7 +43,7 @@ func (w *World) Load(file string) { fmt.Println("Successfully Opened users.xml") defer xmlFile.Close() - converter := &ConvertReader{r: xmlFile} + converter := util.NewConvertReader(xmlFile) // byteValue, _ := io.ReadAll(converter) // fmt.Println(len(byteValue)) @@ -182,7 +145,6 @@ Loop: f.Set(reflect.MakeMapWithSize(ty.Type, 0)) } parseMap(d, ty, f) - val.Field(ty.Index[0]).SetMapIndex(reflect.ValueOf(6), reflect.New(ty.Type.Elem().Elem())) } } else { d.Skip() diff --git a/util/cp473.go b/util/cp473.go new file mode 100644 index 0000000..cf352e2 --- /dev/null +++ b/util/cp473.go @@ -0,0 +1,28 @@ +package util + +import "io" + +var cp437 = []byte(" \t\n \r !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ CueaaaaceeeiiiAAEaAooouuyOU faiounN ") + +// var cp437 = []byte(" \t\n \r !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñÑ ") + +type ConvertReader struct { + r io.Reader + read int +} + +func NewConvertReader(r io.Reader) *ConvertReader { + return &ConvertReader{r: r} +} + +func (c *ConvertReader) Read(b []byte) (n int, err error) { + n, err = c.r.Read(b) + if c.read == 0 && n > 35 { + copy(b[30:35], []byte("UTF-8")) + } + c.read += n + for i := range b { + b[i] = cp437[b[i]] + } + return n, err +}