related to mountain

This commit is contained in:
Robert Janetzko 2022-05-04 12:07:35 +00:00
parent bb97b91b7c
commit bac7694706
10 changed files with 1686 additions and 1475 deletions

View File

@ -156,9 +156,10 @@ func CreateMetadata(a *AnalyzeData) (*Metadata, error) {
if afs, ok := a.Overwrites.AdditionalFields[typeNames[k]]; ok {
for _, add := range afs {
additional[add.Name] = Field{
Name: add.Name,
Type: add.Type,
Legend: "add",
Name: add.Name,
Type: add.Type,
Legend: "add",
Related: a.Overwrites.Relations[fmt.Sprintf("%s.%s", typeNames[k], add.Name)],
}
}
}

View File

@ -142,6 +142,7 @@ func (x *{{ $obj.Name }}) RelatedToWrittenContent(id int) bool { return {{ $obj.
func (x *{{ $obj.Name }}) RelatedToDanceForm(id int) bool { return {{ $obj.RelatedToDanceForm }} }
func (x *{{ $obj.Name }}) RelatedToMusicalForm(id int) bool { return {{ $obj.RelatedToMusicalForm }} }
func (x *{{ $obj.Name }}) RelatedToPoeticForm(id int) bool { return {{ $obj.RelatedToPoeticForm }} }
func (x *{{ $obj.Name }}) RelatedToMountain(id int) bool { return {{ $obj.RelatedToMountain }} }
{{- end }}
func (x *{{ $obj.Name }}) CheckFields() {
@ -330,7 +331,7 @@ func (f Field) TypeLine() string {
if f.Type == "enum" {
t = *f.ElementType
}
j := fmt.Sprintf("`json:\"%s\" legend:\"%s\"`", strcase.ToLowerCamel(f.Name), f.Legend)
j := fmt.Sprintf("`json:\"%s\" legend:\"%s\" related:\"%s\"`", strcase.ToLowerCamel(f.Name), f.Legend, f.Related)
return fmt.Sprintf("%s %s%s %s", n, m, t, j)
}
@ -503,6 +504,9 @@ func (obj Object) RelatedToMusicalForm() string {
func (obj Object) RelatedToPoeticForm() string {
return obj.Related("poeticForm", noRegex, "")
}
func (obj Object) RelatedToMountain() string {
return obj.Related("mountain", noRegex, "")
}
func (obj Object) Related(relation string, regex *regexp.Regexp, init string) string {
var list []string
@ -515,6 +519,13 @@ func (obj Object) Related(relation string, regex *regexp.Regexp, init string) st
}
}
}
for _, f := range obj.Additional {
if f.Type == "int" && relation == f.Related {
list = append(list, fmt.Sprintf("x.%s == id", f.Name))
} else if f.Type == "[]int" && relation == f.Related {
list = append(list, fmt.Sprintf("containsInt(x.%s, id)", f.Name))
}
}
sort.Strings(list)
if len(list) > 0 {
l := strings.Join(list, " || ")

View File

@ -7,7 +7,8 @@
"Relations": {
"HistoricalEventDanceFormCreated.FormId": "danceForm",
"HistoricalEventMusicalFormCreated.FormId": "musicalForm",
"HistoricalEventPoeticFormCreated.FormId": "poeticForm"
"HistoricalEventPoeticFormCreated.FormId": "poeticForm",
"HistoricalEventHfReachSummit.MountainPeakId": "mountain"
},
"AdditionalFields": {
"DfWorld": [
@ -80,6 +81,12 @@
"Type": "HistoricalEventRelationshipRelationship"
}
],
"HistoricalEventHfReachSummit": [
{
"Name": "MountainPeakId",
"Type": "int"
}
],
"HistoricalEventCollectionAbduction": [
{
"Name": "TargetHfids",

View File

@ -18,6 +18,7 @@ type HistoricalEventDetails interface {
RelatedToDanceForm(int) bool
RelatedToMusicalForm(int) bool
RelatedToPoeticForm(int) bool
RelatedToMountain(int) bool
Html(*Context) string
Type() string
}
@ -65,6 +66,8 @@ func NewEventList(world *DfWorld, obj any) *EventList {
el.Events = world.EventsMatching(func(d HistoricalEventDetails) bool { return d.RelatedToMusicalForm(x.Id()) })
case *PoeticForm:
el.Events = world.EventsMatching(func(d HistoricalEventDetails) bool { return d.RelatedToPoeticForm(x.Id()) })
case *MountainPeak:
el.Events = world.EventsMatching(func(d HistoricalEventDetails) bool { return d.RelatedToMountain(x.Id()) })
case []*HistoricalEvent:
el.Events = x
case []int:

File diff suppressed because it is too large Load Diff

View File

@ -65,6 +65,9 @@ func StartServer(world *model.DfWorld, static embed.FS) error {
},
}
})
srv.RegisterWorldResourcePage("/landmass/{id}", "landmass.html", func(id int) any { return srv.context.world.Landmasses[id] })
srv.RegisterWorldResourcePage("/mountain/{id}", "mountain.html", func(id int) any { return srv.context.world.MountainPeaks[id] })
srv.RegisterWorldResourcePage("/river/{id}", "river.html", func(id int) any { return srv.context.world.Rivers[id] })
srv.RegisterWorldPage("/regions", "regions.html", func(p Parms) any { return groupByType(srv.context.world.Regions) })
srv.RegisterWorldResourcePage("/region/{id}", "region.html", func(id int) any { return srv.context.world.Regions[id] })

View File

@ -0,0 +1,10 @@
{{template "layout.html" .}}
{{define "title"}}{{ title .Name }}{{end}}
{{define "content"}}
<h1>{{ title .Name }}</h1>
<p>landmass</p>
<p>{{ json . }}</p>
{{- end }}

View File

@ -0,0 +1,14 @@
{{template "layout.html" .}}
{{define "title"}}{{ title .Name }}{{end}}
{{define "content"}}
<h1>{{ title .Name }}</h1>
<p>{{ if .IsVolcano }}volcano{{else}}mountain{{end}}</p>
<h5>Events</h5>
{{ template "events.html" events . }}
<p>{{ json . }}</p>
{{- end }}

View File

@ -3,9 +3,10 @@
{{define "title"}}{{ title .Name }}{{end}}
{{define "content"}}
<h1>{{ title .Name }}</h1>
<h3>{{ title .Name }}</h3>
<p>{{ .Type }}</p>
<h3>Events</h3>
<h5>Events</h5>
{{ template "events.html" events . }}

View File

@ -0,0 +1,10 @@
{{template "layout.html" .}}
{{define "title"}}{{ title .Name }}{{end}}
{{define "content"}}
<h1>{{ title .Name }}</h1>
<p>river</p>
<p>{{ json . }}</p>
{{- end }}