civ colors

This commit is contained in:
Robert Janetzko 2022-05-06 13:16:16 +00:00
parent 185a62dcc0
commit ce57fd472b
10 changed files with 122 additions and 69 deletions

View File

@ -87,6 +87,10 @@
}
],
"Entity": [
{
"Name": "Parent",
"Type": "int"
},
{
"Name": "Necromancer",
"Type": "bool"

View File

@ -94,10 +94,13 @@ func hfIcon(x *HistoricalFigure) string {
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> `
return `<i class="fa-solid fa-cloud-moon fa-xs"></i> `
case x.Vampire:
return `<i class="fa-solid fa-droplet fa-xs"></i> `
}
if len(x.SiteLink) > 0 && x.SiteLink[0].LinkType == SiteLinkLinkType_Lair {
return `<i class="fa-solid fa-paw fa-xs"></i> `
}
return ""
}
@ -138,7 +141,23 @@ func (c *Context) artifact(id int) string {
func (c *Context) entity(id int) string {
if x, ok := c.World.Entities[id]; ok {
return fmt.Sprintf(`<a class="entity" href="/entity/%d"><i class="%s fa-xs"></i> %s</a>`, x.Id(), x.Icon(), util.Title(x.Name()))
c := ""
switch x.Race {
case "dwarf":
c = ` style="color:#FFCC33"`
case "elf":
c = ` style="color:#99FF00"`
case "human":
c = ` style="color:#0000CC"`
case "kobold":
c = ` style="color:#333"`
case "goblin":
c = ` style="color:#CC0000"`
}
if x.Necromancer {
c = ` style="color:#A0A"`
}
return fmt.Sprintf(`<a class="entity" href="/entity/%d"><i class="%s fa-xs" %s></i> %s</a>`, x.Id(), x.Icon(), c, util.Title(x.Name()))
}
return "UNKNOWN ENTITY"
}

View File

@ -1992,6 +1992,7 @@ type Entity struct {
WorshipId []int `json:"worshipId" legend:"plus" related:""` // worship_id
Leaders []*EntityLeader `json:"leaders" legend:"add" related:""` // Leaders
Necromancer bool `json:"necromancer" legend:"add" related:""` // Necromancer
Parent int `json:"parent" legend:"add" related:""` // Parent
Sites []int `json:"sites" legend:"add" related:""` // Sites
Wars []*HistoricalEventCollection `json:"wars" legend:"add" related:""` // Wars
}
@ -1999,6 +2000,7 @@ type Entity struct {
func NewEntity() *Entity {
return &Entity{
Id_: -1,
Parent: -1,
}
}
func (x *Entity) Id() int { return x.Id_ }
@ -2033,6 +2035,9 @@ func (x *Entity) MarshalJSON() ([]byte, error) {
d["worshipId"] = x.WorshipId
d["leaders"] = x.Leaders
d["necromancer"] = x.Necromancer
if x.Parent != -1 {
d["parent"] = x.Parent
}
d["sites"] = x.Sites
d["wars"] = x.Wars
return json.Marshal(d)

View File

@ -32,6 +32,12 @@ func (w *DfWorld) process() {
}
}
for _, l := range e.EntityLink {
if l.Type_ == EntityEntityLinkType_PARENT {
e.Parent = l.Target
}
}
idx := slices.Index(e.Child, e.Id_)
if idx != -1 {
e.Child = append(e.Child[:idx], e.Child[idx+1:]...)

View File

@ -86,6 +86,11 @@ td.object {
@media (prefers-color-scheme: dark) {
.bg-light {
--bs-bg-opacity: 1;
background-color: rgba(var(--bs-dark-rgb), var(--bs-bg-opacity)) !important;
}
a {
color: #337ab7;
}

View File

@ -7,24 +7,25 @@
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
{{ $active := " active"}}
{{- range $t, $v := .DanceForms }}
<button class="nav-link active" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button" role="tab">{{$t}} ({{
len $v
}})</button>
{{- end}}
<button class="nav-link{{$active}}" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button" role="tab">{{$t}} ({{
len $v }})</button>
{{ $active = ""}}{{- end}}
{{- range $t, $v := .MusicalForms }}
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button" role="tab">{{$t}} ({{ len $v
}})</button>
{{- end}}
<button class="nav-link{{$active}}" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button" role="tab">{{$t}} ({{ len
$v }})</button>
{{ $active = ""}}{{- end}}
{{- range $t, $v := .PoeticForms }}
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button" role="tab">{{$t}} ({{ len $v
}})</button>
{{- end}}
<button class="nav-link{{$active}}" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button" role="tab">{{$t}} ({{ len
$v }})</button>
{{ $active = ""}}{{- end}}
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
{{ $active := " active"}}
{{- range $t, $v := .DanceForms }}
<div class="tab-pane active" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<div class="tab-pane{{$active}}" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<table class="table table-hover table-sm table-borderless">
<tr>
<th width="100%">Name</th>
@ -38,9 +39,9 @@
{{- end}}{{- end}}
</table>
</div>
{{- end}}
{{ $active = ""}}{{- end}}
{{- range $t, $v := .MusicalForms }}
<div class="tab-pane" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<div class="tab-pane{{$active}}" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<table class="table table-hover table-sm table-borderless">
<tr>
<th width="100%">Name</th>
@ -54,9 +55,9 @@
{{- end}}{{- end}}
</table>
</div>
{{- end}}
{{ $active = ""}}{{- end}}
{{- range $t, $v := .PoeticForms }}
<div class="tab-pane" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<div class="tab-pane{{$active}}" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<table class="table table-hover table-sm table-borderless object-table">
<tr>
<th width="100%">Name</th>
@ -70,7 +71,7 @@
{{- end}}{{- end}}
</table>
</div>
{{- end}}
{{ $active = ""}}{{- end}}
</div>
{{- end }}

View File

@ -9,6 +9,9 @@
{{- if .Profession }}
of {{ .Profession }}s
{{- end }}
{{- if ne .Parent -1 }}
of {{ entity .Parent }}
{{- end }}
{{- if and (eq .Type "religion") (gt (len .WorshipId) 0) }}
centered around the worship of {{ hfList .WorshipId }}
{{- end }}
@ -24,26 +27,28 @@
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
{{ $active := " active"}}
{{- if gt (len .Leaders) 0 }}
<button class="nav-link active" data-bs-toggle="tab" data-bs-target="#nav-leaders" type="button" role="tab">Sites</button>
{{- end}}
<button class="nav-link{{$active}}" data-bs-toggle="tab" data-bs-target="#nav-leaders" type="button" role="tab">Leaders</button>
{{ $active = ""}}{{- end}}
{{- if gt (len .Sites) 0 }}
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#nav-sites" type="button" role="tab">Sites</button>
{{- end}}
<button class="nav-link{{$active}}" data-bs-toggle="tab" data-bs-target="#nav-sites" type="button" role="tab">Sites</button>
{{ $active = ""}}{{- end}}
{{- if gt (len .HistfigId) 0 }}
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#nav-members" type="button" role="tab">Members</button>
{{- end}}
<button class="nav-link{{$active}}" data-bs-toggle="tab" data-bs-target="#nav-members" type="button" role="tab">Members</button>
{{ $active = ""}}{{- end}}
{{- if gt (len .Child) 0 }}
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#nav-children" type="button" role="tab">Groups</button>
{{- end}}
<button class="nav-link{{$active}}" data-bs-toggle="tab" data-bs-target="#nav-children" type="button" role="tab">Groups</button>
{{ $active = ""}}{{- end}}
{{- if gt (len .Wars) 0 }}
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#nav-wars" type="button" role="tab">Wars</button>
{{- end}}
<button class="nav-link{{$active}}" data-bs-toggle="tab" data-bs-target="#nav-wars" type="button" role="tab">Wars</button>
{{ $active = ""}}{{- end}}
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
{{ $active := " active"}}
{{- if gt (len .Leaders) 0 }}
<div class="tab-pane active" id="nav-leaders" role="tabpanel">
<div class="tab-pane{{$active}}" id="nav-leaders" role="tabpanel">
<table class="table table-hover table-sm table-borderless object-table">
<tr>
<th>Date</th>
@ -64,9 +69,9 @@
{{- end}}
</table>
</div>
{{- end}}
{{ $active = ""}}{{- end}}
{{- if gt (len .Sites) 0 }}
<div class="tab-pane" id="nav-sites" role="tabpanel">
<div class="tab-pane{{$active}}" id="nav-sites" role="tabpanel">
<table class="table table-hover table-sm table-borderless">
<tr>
<th>Name</th>
@ -80,9 +85,9 @@
{{- end}}
</table>
</div>
{{- end}}
{{ $active = ""}}{{- end}}
{{- if gt (len .HistfigId) 0 }}
<div class="tab-pane" id="nav-members" role="tabpanel">
<div class="tab-pane{{$active}}" id="nav-members" role="tabpanel">
<table class="table table-hover table-sm table-borderless object-table">
<tr>
<th width="100%">Type</th>
@ -94,9 +99,9 @@
{{- end}}
</table>
</div>
{{- end}}
{{ $active = ""}}{{- end}}
{{- if gt (len .Child) 0 }}
<div class="tab-pane" id="nav-children" role="tabpanel">
<div class="tab-pane{{$active}}" id="nav-children" role="tabpanel">
<table class="table table-hover table-sm table-borderless object-table">
<tr>
<th width="100%">Type</th>
@ -108,9 +113,9 @@
{{- end}}
</table>
</div>
{{- end}}
{{ $active = ""}}{{- end}}
{{- if gt (len .Wars) 0 }}
<div class="tab-pane" id="nav-wars" role="tabpanel">
<div class="tab-pane{{$active}}" id="nav-wars" role="tabpanel">
<table class="table table-hover table-sm table-borderless object-table">
<tr>
<th>Year</th>
@ -140,7 +145,7 @@
{{- end}}
</table>
</div>
{{- end}}
{{ $active = ""}}{{- end}}
</div>
<h5>Events</h5>

View File

@ -7,28 +7,29 @@
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
{{ $active := " active"}}
{{- range $t, $v := .Regions }}
<button class="nav-link active" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button" role="tab">{{$t}} ({{
len $v
}})</button>
{{- end}}
<button class="nav-link{{$active}}" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button" role="tab">{{$t}} ({{
len $v }})</button>
{{ $active = ""}}{{- end}}
{{- range $t, $v := .Landmasses }}
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button" role="tab">{{$t}} ({{ len $v
}})</button>
{{- end}}
<button class="nav-link{{$active}}" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button" role="tab">{{$t}} ({{ len
$v }})</button>
{{ $active = ""}}{{- end}}
{{- range $t, $v := .MountainPeaks }}
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button" role="tab">{{$t}} ({{ len $v
}})</button>
{{- end}}
<button class="nav-link{{$active}}" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button" role="tab">{{$t}} ({{ len
$v }})</button>
{{ $active = ""}}{{- end}}
{{- range $t, $v := .Rivers }}
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button" role="tab">{{$t}} ({{ len $v
}})</button>
{{- end}}
<button class="nav-link{{$active}}" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button" role="tab">{{$t}} ({{ len
$v }})</button>
{{ $active = ""}}{{- end}}
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
{{ $active := " active"}}
{{- range $t, $v := .Regions }}
<div class="tab-pane active" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<div class="tab-pane{{$active}}" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<table class="table table-hover table-sm table-borderless">
<tr>
<th width="100%">Name</th>
@ -42,9 +43,9 @@
{{- end}}{{- end}}
</table>
</div>
{{- end}}
{{ $active = ""}}{{- end}}
{{- range $t, $v := .Landmasses }}
<div class="tab-pane" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<div class="tab-pane{{$active}}" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<table class="table table-hover table-sm table-borderless">
<tr>
<th width="100%">Name</th>
@ -58,9 +59,9 @@
{{- end}}{{- end}}
</table>
</div>
{{- end}}
{{ $active = ""}}{{- end}}
{{- range $t, $v := .MountainPeaks }}
<div class="tab-pane" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<div class="tab-pane{{$active}}" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<table class="table table-hover table-sm table-borderless object-table">
<tr>
<th width="100%">Name</th>
@ -74,9 +75,9 @@
{{- end}}{{- end}}
</table>
</div>
{{- end}}
{{ $active = ""}}{{- end}}
{{- range $t, $v := .Rivers }}
<div class="tab-pane" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<div class="tab-pane{{$active}}" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<table class="table table-hover table-sm table-borderless object-table">
<tr>
<th width="100%">Name</th>
@ -90,7 +91,7 @@
{{- end}}{{- end}}
</table>
</div>
{{- end}}
{{ $active = ""}}{{- end}}
</div>
{{- end }}

View File

@ -1,7 +1,10 @@
{{ .Race }} {{ .Type }}
{{ .Race }}{{ if .Necromancer}} necromancer{{end}} {{ .Type }}
{{- if .Profession }}
of {{ .Profession }}s
{{- end }}
{{- if ne .Parent -1 }}
of {{ entity .Parent }}
{{- end }}
{{- if and (eq .Type "religion") (gt (len .WorshipId) 0) }}
<br />centered around the worship of {{ hfList .WorshipId }}
{{- end }}

View File

@ -8,17 +8,21 @@
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
{{ $active := " active"}}
{{- if gt (len .Structures) 0 }}
<button class="nav-link active" data-bs-toggle="tab" data-bs-target="#nav-structures" type="button" role="tab">Structures</button>
{{- end}}
<button class="nav-link{{$active}}" data-bs-toggle="tab" data-bs-target="#nav-structures" type="button"
role="tab">Structures</button>
{{ $active = ""}}{{- end}}
{{- if gt (len .SiteProperties) 0 }}
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#nav-site-properties" type="button" role="tab">Properties</button>
{{- end}}
<button class="nav-link{{$active}}" data-bs-toggle="tab" data-bs-target="#nav-site-properties" type="button"
role="tab">Properties</button>
{{ $active = ""}}{{- end}}
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
{{ $active := " active"}}
{{- if gt (len .Structures) 0 }}
<div class="tab-pane active" id="nav-structures" role="tabpanel">
<div class="tab-pane{{$active}}" id="nav-structures" role="tabpanel">
<table class="table table-hover table-sm table-borderless object-table">
<tr>
<th>Name</th>
@ -32,9 +36,9 @@
{{- end}}
</table>
</div>
{{- end}}
{{ $active = ""}}{{- end}}
{{- if gt (len .SiteProperties) 0 }}
<div class="tab-pane" id="nav-site-properties" role="tabpanel">
<div class="tab-pane{{$active}}" id="nav-site-properties" role="tabpanel">
<table class="table table-hover table-sm table-borderless object-table">
<tr>
<th>Type</th>
@ -49,7 +53,7 @@
{{- end}}
</table>
</div>
{{- end}}
{{ $active = ""}}{{- end}}
</div>
<h5 class="mt-3">Events</h5>