related to mountain
This commit is contained in:
parent
bb97b91b7c
commit
bac7694706
|
@ -156,9 +156,10 @@ func CreateMetadata(a *AnalyzeData) (*Metadata, error) {
|
||||||
if afs, ok := a.Overwrites.AdditionalFields[typeNames[k]]; ok {
|
if afs, ok := a.Overwrites.AdditionalFields[typeNames[k]]; ok {
|
||||||
for _, add := range afs {
|
for _, add := range afs {
|
||||||
additional[add.Name] = Field{
|
additional[add.Name] = Field{
|
||||||
Name: add.Name,
|
Name: add.Name,
|
||||||
Type: add.Type,
|
Type: add.Type,
|
||||||
Legend: "add",
|
Legend: "add",
|
||||||
|
Related: a.Overwrites.Relations[fmt.Sprintf("%s.%s", typeNames[k], add.Name)],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 }}) RelatedToDanceForm(id int) bool { return {{ $obj.RelatedToDanceForm }} }
|
||||||
func (x *{{ $obj.Name }}) RelatedToMusicalForm(id int) bool { return {{ $obj.RelatedToMusicalForm }} }
|
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 }}) RelatedToPoeticForm(id int) bool { return {{ $obj.RelatedToPoeticForm }} }
|
||||||
|
func (x *{{ $obj.Name }}) RelatedToMountain(id int) bool { return {{ $obj.RelatedToMountain }} }
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
func (x *{{ $obj.Name }}) CheckFields() {
|
func (x *{{ $obj.Name }}) CheckFields() {
|
||||||
|
@ -330,7 +331,7 @@ func (f Field) TypeLine() string {
|
||||||
if f.Type == "enum" {
|
if f.Type == "enum" {
|
||||||
t = *f.ElementType
|
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)
|
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 {
|
func (obj Object) RelatedToPoeticForm() string {
|
||||||
return obj.Related("poeticForm", noRegex, "")
|
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 {
|
func (obj Object) Related(relation string, regex *regexp.Regexp, init string) string {
|
||||||
var list []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)
|
sort.Strings(list)
|
||||||
if len(list) > 0 {
|
if len(list) > 0 {
|
||||||
l := strings.Join(list, " || ")
|
l := strings.Join(list, " || ")
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
"Relations": {
|
"Relations": {
|
||||||
"HistoricalEventDanceFormCreated.FormId": "danceForm",
|
"HistoricalEventDanceFormCreated.FormId": "danceForm",
|
||||||
"HistoricalEventMusicalFormCreated.FormId": "musicalForm",
|
"HistoricalEventMusicalFormCreated.FormId": "musicalForm",
|
||||||
"HistoricalEventPoeticFormCreated.FormId": "poeticForm"
|
"HistoricalEventPoeticFormCreated.FormId": "poeticForm",
|
||||||
|
"HistoricalEventHfReachSummit.MountainPeakId": "mountain"
|
||||||
},
|
},
|
||||||
"AdditionalFields": {
|
"AdditionalFields": {
|
||||||
"DfWorld": [
|
"DfWorld": [
|
||||||
|
@ -80,6 +81,12 @@
|
||||||
"Type": "HistoricalEventRelationshipRelationship"
|
"Type": "HistoricalEventRelationshipRelationship"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"HistoricalEventHfReachSummit": [
|
||||||
|
{
|
||||||
|
"Name": "MountainPeakId",
|
||||||
|
"Type": "int"
|
||||||
|
}
|
||||||
|
],
|
||||||
"HistoricalEventCollectionAbduction": [
|
"HistoricalEventCollectionAbduction": [
|
||||||
{
|
{
|
||||||
"Name": "TargetHfids",
|
"Name": "TargetHfids",
|
||||||
|
|
|
@ -18,6 +18,7 @@ type HistoricalEventDetails interface {
|
||||||
RelatedToDanceForm(int) bool
|
RelatedToDanceForm(int) bool
|
||||||
RelatedToMusicalForm(int) bool
|
RelatedToMusicalForm(int) bool
|
||||||
RelatedToPoeticForm(int) bool
|
RelatedToPoeticForm(int) bool
|
||||||
|
RelatedToMountain(int) bool
|
||||||
Html(*Context) string
|
Html(*Context) string
|
||||||
Type() 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()) })
|
el.Events = world.EventsMatching(func(d HistoricalEventDetails) bool { return d.RelatedToMusicalForm(x.Id()) })
|
||||||
case *PoeticForm:
|
case *PoeticForm:
|
||||||
el.Events = world.EventsMatching(func(d HistoricalEventDetails) bool { return d.RelatedToPoeticForm(x.Id()) })
|
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:
|
case []*HistoricalEvent:
|
||||||
el.Events = x
|
el.Events = x
|
||||||
case []int:
|
case []int:
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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.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] })
|
srv.RegisterWorldResourcePage("/region/{id}", "region.html", func(id int) any { return srv.context.world.Regions[id] })
|
||||||
|
|
|
@ -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 }}
|
|
@ -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 }}
|
|
@ -3,9 +3,10 @@
|
||||||
{{define "title"}}{{ title .Name }}{{end}}
|
{{define "title"}}{{ title .Name }}{{end}}
|
||||||
|
|
||||||
{{define "content"}}
|
{{define "content"}}
|
||||||
<h1>{{ title .Name }}</h1>
|
<h3>{{ title .Name }}</h3>
|
||||||
|
<p>{{ .Type }}</p>
|
||||||
|
|
||||||
<h3>Events</h3>
|
<h5>Events</h5>
|
||||||
|
|
||||||
{{ template "events.html" events . }}
|
{{ template "events.html" events . }}
|
||||||
|
|
||||||
|
|
|
@ -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 }}
|
Loading…
Reference in New Issue