more details
This commit is contained in:
parent
b63c76f48c
commit
185a62dcc0
|
@ -77,12 +77,20 @@
|
||||||
"Name": "VampireSince",
|
"Name": "VampireSince",
|
||||||
"Type": "int"
|
"Type": "int"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Name": "NecromancerSince",
|
||||||
|
"Type": "int"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"Name": "NecromancerSince",
|
"Name": "NecromancerSince",
|
||||||
"Type": "int"
|
"Type": "int"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Entity": [
|
"Entity": [
|
||||||
|
{
|
||||||
|
"Name": "Necromancer",
|
||||||
|
"Type": "bool"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"Name": "Leaders",
|
"Name": "Leaders",
|
||||||
"Type": "[]*EntityLeader"
|
"Type": "[]*EntityLeader"
|
||||||
|
|
|
@ -85,6 +85,18 @@ func hfIcon(x *HistoricalFigure) string {
|
||||||
switch {
|
switch {
|
||||||
case x.Leader:
|
case x.Leader:
|
||||||
return `<i class="fa-solid fa-crown fa-xs"></i> `
|
return `<i class="fa-solid fa-crown fa-xs"></i> `
|
||||||
|
case x.Deity:
|
||||||
|
return `<i class="fa-solid fa-hands-holding fa-xs"></i> `
|
||||||
|
case x.Force:
|
||||||
|
return `<i class="fa-solid fa-hands-holding-circle fa-xs"></i> `
|
||||||
|
case x.Adventurer:
|
||||||
|
return `<i class="fa-solid fa-person-hiking fa-xs"></i> `
|
||||||
|
case x.Necromancer:
|
||||||
|
return `<i class="fa-solid fa-book-skull fa-xs"></i> `
|
||||||
|
case x.Werebeast:
|
||||||
|
return `<i class="fa-solid fa-moon fa-xs"></i> `
|
||||||
|
case x.Vampire:
|
||||||
|
return `<i class="fa-solid fa-droplet fa-xs"></i> `
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,10 @@ func (e *Entity) Type() string {
|
||||||
return e.Type_.String()
|
return e.Type_.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *Entity) Weapons() []string {
|
||||||
|
return util.Map(e.Weapon, func(w EntityWeapon) string { return w.String() })
|
||||||
|
}
|
||||||
|
|
||||||
func (e *Entity) Position(id int) *EntityPosition {
|
func (e *Entity) Position(id int) *EntityPosition {
|
||||||
for _, p := range e.EntityPosition {
|
for _, p := range e.EntityPosition {
|
||||||
if p.Id_ == id {
|
if p.Id_ == id {
|
||||||
|
|
|
@ -45,6 +45,8 @@ var AddMapSite = func(w *DfWorld, id int) template.HTML {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var AndList = func(s []string) template.HTML { return template.HTML(andList(s)) }
|
||||||
|
|
||||||
func andList(list []string) string {
|
func andList(list []string) string {
|
||||||
if len(list) > 1 {
|
if len(list) > 1 {
|
||||||
return strings.Join(list[:len(list)-1], ", ") + " and " + list[len(list)-1]
|
return strings.Join(list[:len(list)-1], ", ") + " and " + list[len(list)-1]
|
||||||
|
|
|
@ -1991,6 +1991,7 @@ type Entity struct {
|
||||||
Weapon []EntityWeapon `json:"weapon" legend:"plus" related:""` // weapon
|
Weapon []EntityWeapon `json:"weapon" legend:"plus" related:""` // weapon
|
||||||
WorshipId []int `json:"worshipId" legend:"plus" related:""` // worship_id
|
WorshipId []int `json:"worshipId" legend:"plus" related:""` // worship_id
|
||||||
Leaders []*EntityLeader `json:"leaders" legend:"add" related:""` // Leaders
|
Leaders []*EntityLeader `json:"leaders" legend:"add" related:""` // Leaders
|
||||||
|
Necromancer bool `json:"necromancer" legend:"add" related:""` // Necromancer
|
||||||
Sites []int `json:"sites" legend:"add" related:""` // Sites
|
Sites []int `json:"sites" legend:"add" related:""` // Sites
|
||||||
Wars []*HistoricalEventCollection `json:"wars" legend:"add" related:""` // Wars
|
Wars []*HistoricalEventCollection `json:"wars" legend:"add" related:""` // Wars
|
||||||
}
|
}
|
||||||
|
@ -2031,6 +2032,7 @@ func (x *Entity) MarshalJSON() ([]byte, error) {
|
||||||
d["weapon"] = x.Weapon
|
d["weapon"] = x.Weapon
|
||||||
d["worshipId"] = x.WorshipId
|
d["worshipId"] = x.WorshipId
|
||||||
d["leaders"] = x.Leaders
|
d["leaders"] = x.Leaders
|
||||||
|
d["necromancer"] = x.Necromancer
|
||||||
d["sites"] = x.Sites
|
d["sites"] = x.Sites
|
||||||
d["wars"] = x.Wars
|
d["wars"] = x.Wars
|
||||||
return json.Marshal(d)
|
return json.Marshal(d)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/robertjanetzko/LegendsBrowser2/backend/util"
|
"github.com/robertjanetzko/LegendsBrowser2/backend/util"
|
||||||
|
"golang.org/x/exp/maps"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -23,6 +24,14 @@ func (w *DfWorld) process() {
|
||||||
w.processHistoricalFigures()
|
w.processHistoricalFigures()
|
||||||
|
|
||||||
for _, e := range w.Entities {
|
for _, e := range w.Entities {
|
||||||
|
if len(e.Sites) > 0 {
|
||||||
|
if site, ok := w.Sites[e.Sites[0]]; ok {
|
||||||
|
if site.Type_ == SiteType_Tower {
|
||||||
|
e.Necromancer = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
idx := slices.Index(e.Child, e.Id_)
|
idx := slices.Index(e.Child, e.Id_)
|
||||||
if idx != -1 {
|
if idx != -1 {
|
||||||
e.Child = append(e.Child[:idx], e.Child[idx+1:]...)
|
e.Child = append(e.Child[:idx], e.Child[idx+1:]...)
|
||||||
|
@ -37,7 +46,10 @@ func (w *DfWorld) process() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *DfWorld) processEvents() {
|
func (w *DfWorld) processEvents() {
|
||||||
for _, e := range w.HistoricalEvents {
|
list := maps.Values(w.HistoricalEvents)
|
||||||
|
sort.Slice(list, func(i, j int) bool { return list[i].Id_ < list[j].Id_ })
|
||||||
|
|
||||||
|
for _, e := range list {
|
||||||
switch d := e.Details.(type) {
|
switch d := e.Details.(type) {
|
||||||
case *HistoricalEventHfDoesInteraction:
|
case *HistoricalEventHfDoesInteraction:
|
||||||
if strings.HasPrefix(d.Interaction, "DEITY_CURSE_WEREBEAST_") {
|
if strings.HasPrefix(d.Interaction, "DEITY_CURSE_WEREBEAST_") {
|
||||||
|
@ -123,7 +135,10 @@ func (w *DfWorld) processEvents() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *DfWorld) processCollections() {
|
func (w *DfWorld) processCollections() {
|
||||||
for _, col := range w.HistoricalEventCollections {
|
list := maps.Values(w.HistoricalEventCollections)
|
||||||
|
sort.Slice(list, func(i, j int) bool { return list[i].Id_ < list[j].Id_ })
|
||||||
|
|
||||||
|
for _, col := range list {
|
||||||
for _, eventId := range col.Event {
|
for _, eventId := range col.Event {
|
||||||
if e, ok := w.HistoricalEvents[eventId]; ok {
|
if e, ok := w.HistoricalEvents[eventId]; ok {
|
||||||
e.Collection = col.Id_
|
e.Collection = col.Id_
|
||||||
|
|
|
@ -129,8 +129,10 @@ func StartServer(config *Config, world *model.DfWorld, static embed.FS) error {
|
||||||
Civilizations map[string][]*model.Entity
|
Civilizations map[string][]*model.Entity
|
||||||
}{
|
}{
|
||||||
Civilizations: groupBy(srv.context.world.Entities,
|
Civilizations: groupBy(srv.context.world.Entities,
|
||||||
func(e *model.Entity) string { return e.Race },
|
func(e *model.Entity) string { return util.If(e.Necromancer, "necromancer", e.Race) },
|
||||||
func(e *model.Entity) bool { return e.Name() != "" && e.Type_ == model.EntityType_Civilization },
|
func(e *model.Entity) bool {
|
||||||
|
return e.Name() != "" && (e.Type_ == model.EntityType_Civilization || e.Necromancer)
|
||||||
|
},
|
||||||
func(e *model.Entity) string { return e.Name() }),
|
func(e *model.Entity) string { return e.Name() }),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -23,6 +23,7 @@ func (srv *DfServer) LoadTemplates() {
|
||||||
},
|
},
|
||||||
"title": util.Title,
|
"title": util.Title,
|
||||||
"kebab": func(s string) string { return strcase.ToKebab(s) },
|
"kebab": func(s string) string { return strcase.ToKebab(s) },
|
||||||
|
"andList": model.AndList,
|
||||||
"world": func() *model.DfWorld { return srv.context.world },
|
"world": func() *model.DfWorld { return srv.context.world },
|
||||||
"context": func(r any) *model.Context { return model.NewContext(srv.context.world, r) },
|
"context": func(r any) *model.Context { return model.NewContext(srv.context.world, r) },
|
||||||
"initMap": func() template.HTML {
|
"initMap": func() template.HTML {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
a {
|
a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.popover {
|
.popover {
|
||||||
|
|
|
@ -18,13 +18,37 @@
|
||||||
<div class="tab-pane{{ ifFirst $ $t " active" }}" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
|
<div class="tab-pane{{ ifFirst $ $t " active" }}" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
|
||||||
<table class="table table-hover table-sm table-borderless object-table">
|
<table class="table table-hover table-sm table-borderless object-table">
|
||||||
<tr>
|
<tr>
|
||||||
<th width="100%">Name</th>
|
<th>Name</th>
|
||||||
<th>Race</th>
|
<th>
|
||||||
|
{{- if eq $t "guild" }}
|
||||||
|
Profession
|
||||||
|
{{- else if eq $t "religion" }}
|
||||||
|
Worshpipping
|
||||||
|
{{- else }}
|
||||||
|
Race
|
||||||
|
{{- end }}
|
||||||
|
</th>
|
||||||
|
{{- if eq $t "militaryunit" }}
|
||||||
|
<th width="50%">Worshpipping</th>
|
||||||
|
<th width="50%">Weapons</th>
|
||||||
|
{{- end }}
|
||||||
</tr>
|
</tr>
|
||||||
{{- range $v }}{{- if not (eq .Name "") }}
|
{{- range $v }}{{- if not (eq .Name "") }}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ entity .Id }}</td>
|
<td>{{ entity .Id }}</td>
|
||||||
<td>{{ .Race }}</td>
|
<td>
|
||||||
|
{{- if eq $t "guild" }}
|
||||||
|
{{ .Profession }}s
|
||||||
|
{{- else if eq $t "religion" }}
|
||||||
|
{{ hfList .WorshipId }}
|
||||||
|
{{- else }}
|
||||||
|
{{ .Race }}
|
||||||
|
{{- end }}
|
||||||
|
</td>
|
||||||
|
{{- if eq $t "militaryunit" }}
|
||||||
|
<td style="white-space: normal;">{{ hfList .WorshipId }}</td>
|
||||||
|
<td style="white-space: normal;">{{ andList .Weapons }}</td>
|
||||||
|
{{- end }}
|
||||||
</tr>
|
</tr>
|
||||||
{{- end}}{{- end}}
|
{{- end}}{{- end}}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -5,10 +5,21 @@
|
||||||
{{define "content"}}
|
{{define "content"}}
|
||||||
<h3>{{ title .Name }}</h3>
|
<h3>{{ title .Name }}</h3>
|
||||||
<p>
|
<p>
|
||||||
{{ .Race }} {{ .Type }}
|
{{ .Race }}{{ if .Necromancer}} necromancer{{end}} {{ .Type }}
|
||||||
{{- if gt (len .WorshipId) 0 }}
|
{{- if .Profession }}
|
||||||
|
of {{ .Profession }}s
|
||||||
|
{{- end }}
|
||||||
|
{{- if and (eq .Type "religion") (gt (len .WorshipId) 0) }}
|
||||||
centered around the worship of {{ hfList .WorshipId }}
|
centered around the worship of {{ hfList .WorshipId }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if eq .Type "militaryunit" }}
|
||||||
|
{{- if gt (len .WorshipId) 0 }}
|
||||||
|
devoted to the worship of {{ hfList .WorshipId }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if gt (len .WorshipId) 0 }}
|
||||||
|
, dedicated to the mastery of {{ andList .Weapons }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
|
|
|
@ -127,7 +127,8 @@
|
||||||
<ul>
|
<ul>
|
||||||
{{- range $i := .IntriguePlot }}
|
{{- range $i := .IntriguePlot }}
|
||||||
<li>
|
<li>
|
||||||
{{ .Type_ }}{{if .OnHold}} (on hold){{end}}
|
{{ .Type_ }} {{ if ne .ArtifactId -1 }}{{ artifact .ArtifactId}}{{end}}
|
||||||
|
{{if .OnHold}} (on hold){{end}}
|
||||||
</li>
|
</li>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -73,13 +73,6 @@
|
||||||
onInput: value => $.get("/search?term=" + value, data => ac.setData(data)),
|
onInput: value => $.get("/search?term=" + value, data => ac.setData(data)),
|
||||||
onSelectItem: ({ label, value }) => window.location = value
|
onSelectItem: ({ label, value }) => window.location = value
|
||||||
});
|
});
|
||||||
|
|
||||||
// later, when you need to change the dataset
|
|
||||||
|
|
||||||
ac.setData([
|
|
||||||
{ label: 'New York JFK', value: 'JFK' },
|
|
||||||
{ label: 'Moscow SVO', value: 'SVO' },
|
|
||||||
]);
|
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
{{ .Race }} {{ .Type }}
|
{{ .Race }} {{ .Type }}
|
||||||
{{- if gt (len .WorshipId) 0 }}
|
{{- if .Profession }}
|
||||||
centered around the worship of {{ hfList .WorshipId }}
|
of {{ .Profession }}s
|
||||||
|
{{- end }}
|
||||||
|
{{- if and (eq .Type "religion") (gt (len .WorshipId) 0) }}
|
||||||
|
<br />centered around the worship of {{ hfList .WorshipId }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if eq .Type "militaryunit" }}
|
||||||
|
{{- if gt (len .WorshipId) 0 }}
|
||||||
|
<br />devoted to the worship of {{ hfList .WorshipId }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if gt (len .WorshipId) 0 }}
|
||||||
|
<br />dedicated to the mastery of {{ andList .Weapons }}
|
||||||
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
Loading…
Reference in New Issue