This commit is contained in:
Robert Janetzko 2022-04-22 15:45:10 +00:00
parent 0f30dccbae
commit d2064ae059
14 changed files with 4375 additions and 1805 deletions

File diff suppressed because it is too large Load Diff

View File

@ -120,8 +120,11 @@ func (x *{{ $obj.Name }}) Name() string { return x.Name_ }
{{- if $obj.SubType }}
func (x *{{ $obj.Name }}) Type() string { return "{{ $obj.SubType }}" }
{{- end }}
func (x *{{ $obj.Name }}) RelatedToEntity(id int) bool { return {{ $obj.Related "civId,civ_id,entity_id,entity" }} }
func (x *{{ $obj.Name }}) RelatedToEntity(id int) bool { return {{ $obj.Related "civId,civ_id,entity_id,entity,enid" }} }
func (x *{{ $obj.Name }}) RelatedToHf(id int) bool { return {{ $obj.Related "hfid,hf_id,_hf,hist_figure_id,Hfid,histfig_id,histfig,bodies" }} }
func (x *{{ $obj.Name }}) RelatedToArtifact(id int) bool { return {{ $obj.Related "artifact_id" }} }
func (x *{{ $obj.Name }}) RelatedToSite(id int) bool { return {{ $obj.Related "site_id" }} }
func (x *{{ $obj.Name }}) RelatedToRegion(id int) bool { return {{ $obj.Related "region_id" }} }
func (x *{{ $obj.Name }}) CheckFields() {
{{- range $field := ($obj.LegendFields "plus") }}
@ -129,7 +132,7 @@ func (x *{{ $obj.Name }}) CheckFields() {
{{- range $field2 := ($obj.LegendFields "base") }}
{{- if eq $field.Type $field2.Type }}
{{- if eq $field.Type "int" }}
if x.{{ $field.Name}} != x.{{ $field2.Name}} && x.{{ $field.Name}} != 0 && x.{{ $field2.Name}} != 0 {
if x.{{ $field.Name}} != x.{{ $field2.Name}} {
sameFields["{{$obj.Name}}"]["{{ $field.Name}}"]["{{ $field2.Name}}"] = false
}
{{- end }}

View File

@ -39,11 +39,15 @@
"BuilderHf": "BuilderHfid",
"Civ": "CivId",
"Site": "SiteId",
"SiteCiv": "SiteCivId"
"SiteCiv": "SiteCivId",
"Structure": "StructureId"
},
"HistoricalEventCreatureDevoured": {
"Site": "SiteId"
},
"HistoricalEventDiplomatLost": {
"Site": "SiteId"
},
"HistoricalEventEntityPrimaryCriminals": {
"Entity": "EntityId",
"Site": "SiteId",
@ -94,6 +98,21 @@
"Woundee": "WoundeeHfid",
"Wounder": "WounderHfid"
},
"HistoricalEventMasterpieceEngraving": {
"Maker": "Hfid",
"MakerEntity": "EntityId",
"Site": "SiteId"
},
"HistoricalEventMasterpieceItem": {
"Maker": "Hfid",
"MakerEntity": "EntityId",
"Site": "SiteId"
},
"HistoricalEventMerchant": {
"Destination": "DepotEntityId",
"Site": "SiteId",
"Source": "TraderEntityId"
},
"HistoricalEventPeaceAccepted": {
"Site": "SiteId"
},
@ -108,6 +127,13 @@
"HistoricalEventRemoveHfSiteLink": {
"Site": "SiteId"
},
"HistoricalEventReplacedStructure": {
"Civ": "CivId",
"NewStructure": "NewAbId",
"OldStructure": "OldAbId",
"Site": "SiteId",
"SiteCiv": "SiteCivId"
},
"Structure": {},
"WrittenContent": {
"Author": "AuthorHfid"

View File

@ -41,8 +41,14 @@ func main() {
return nil
},
"title": util.Title,
"hf": model.LinkHf,
"getHf": func(id int) *model.HistoricalFigure { return world.HistoricalFigures[id] },
"entity": model.LinkEntity,
"getEntity": func(id int) *model.Entity { return world.Entities[id] },
"site": model.LinkSite,
"getSite": func(id int) *model.Site { return world.Sites[id] },
"region": model.LinkRegion,
"getRegion": func(id int) *model.Region { return world.Regions[id] },
"events": func(obj model.Identifiable) []*model.HistoricalEvent {
id := obj.Id()
var list []*model.HistoricalEvent
@ -59,6 +65,24 @@ func main() {
list = append(list, e)
}
}
case *model.Artifact:
for _, e := range world.HistoricalEvents {
if e.Details.RelatedToArtifact(id) {
list = append(list, e)
}
}
case *model.Site:
for _, e := range world.HistoricalEvents {
if e.Details.RelatedToSite(id) {
list = append(list, e)
}
}
case *model.Region:
for _, e := range world.HistoricalEvents {
if e.Details.RelatedToRegion(id) {
list = append(list, e)
}
}
default:
fmt.Printf("unknown type %T\n", obj)
}
@ -150,6 +174,9 @@ func main() {
RegisterResourcePage(router, "/entity/{id}", t, "entity.html", func(id int) any { return world.Entities[id] })
RegisterResourcePage(router, "/hf/{id}", t, "hf.html", func(id int) any { return world.HistoricalFigures[id] })
RegisterResourcePage(router, "/region/{id}", t, "region.html", func(id int) any { return world.Regions[id] })
RegisterResourcePage(router, "/site/{id}", t, "site.html", func(id int) any { return world.Sites[id] })
RegisterResourcePage(router, "/artifact/{id}", t, "artifact.html", func(id int) any { return world.Artifacts[id] })
RegisterPage(router, "/events", t, "eventTypes.html", func(p Parms) any { return allEventTypes() })
RegisterPage(router, "/events/{type}", t, "eventType.html", func(p Parms) any { return eventsOfType(p["type"]) })
}

View File

@ -101,6 +101,10 @@ func (x *HistoricalEventAddHfSiteLink) Html() string {
return h + " took up residence in " + b + c + " " + s
case HistoricalEventAddHfSiteLinkLinkType_Occupation:
return h + " started working at " + b + c + " " + s
case HistoricalEventAddHfSiteLinkLinkType_PrisonAbstractBuilding:
return h + " was imprisoned in " + b + c + " " + s
case HistoricalEventAddHfSiteLinkLinkType_PrisonSiteBuildingProfile:
return h + " was imprisoned in " + b + c + " " + s
case HistoricalEventAddHfSiteLinkLinkType_SeatOfPower:
return h + " ruled from " + b + c + " " + s
default:
@ -112,7 +116,9 @@ func (x *HistoricalEventAgreementFormed) Html() string { // TODO
return "UNKNWON HistoricalEventAgreementFormed"
}
func (x *HistoricalEventAgreementMade) Html() string { return "UNKNWON HistoricalEventAgreementMade" } // TODO
func (x *HistoricalEventAgreementMade) Html() string { // TODO
return "UNKNWON HistoricalEventAgreementMade"
}
func (x *HistoricalEventAgreementRejected) Html() string { // TODO
return "UNKNWON HistoricalEventAgreementRejected"
@ -143,9 +149,9 @@ func (x *HistoricalEventArtifactClaimFormed) Html() string {
func (x *HistoricalEventArtifactCopied) Html() string {
s := util.If(x.FromOriginal, "made a copy of the original", "aquired a copy of")
return fmt.Sprintf("%s %s %s from %s%s of %s, keeping it within %s%s",
entity(x.DestEntityId), s, artifact(x.ArtifactId), structure(x.SourceSiteId, x.SourceStructureId), site(x.SourceSiteId, " in "),
entity(x.SourceEntityId), structure(x.DestSiteId, x.DestStructureId), site(x.DestSiteId, " in "))
return fmt.Sprintf("%s %s %s %s of %s, keeping it%s",
entity(x.DestEntityId), s, artifact(x.ArtifactId), siteStructure(x.SourceSiteId, x.SourceStructureId, "from"),
entity(x.SourceEntityId), siteStructure(x.DestSiteId, x.DestStructureId, "within"))
}
func (x *HistoricalEventArtifactCreated) Html() string {
@ -176,13 +182,22 @@ func (x *HistoricalEventArtifactCreated) Html() string {
return fmt.Sprintf("%s received its name%s from %s %s", a, s, h, c)
}
}
func (x *HistoricalEventArtifactDestroyed) Html() string {
return fmt.Sprintf("%s was destroyed by %s in %s", artifact(x.ArtifactId), entity(x.DestroyerEnid), site(x.SiteId, ""))
}
func (x *HistoricalEventArtifactFound) Html() string {
return fmt.Sprintf("%s was found in %s by %s", artifact(x.ArtifactId), site(x.SiteId, ""), hf(x.HistFigureId))
w := ""
if x.SiteId != -1 {
w = site(x.SiteId, "")
if x.SitePropertyId != -1 {
w = property(x.SiteId, x.SitePropertyId) + " in " + w
}
}
return fmt.Sprintf("%s was found in %s by %s", artifact(x.ArtifactId), w, util.If(x.HistFigureId != -1, hf(x.HistFigureId), "an unknown creature"))
}
func (x *HistoricalEventArtifactGiven) Html() string {
r := ""
if x.ReceiverHistFigureId != -1 {
@ -216,6 +231,9 @@ func (x *HistoricalEventArtifactLost) Html() string {
}
if x.SiteId != -1 {
w = site(x.SiteId, "")
if x.SitePropertyId != -1 {
w = property(x.SiteId, x.SitePropertyId) + " in " + w
}
}
return fmt.Sprintf("%s was lost in %s", artifact(x.ArtifactId), w)
}
@ -255,14 +273,18 @@ func (x *HistoricalEventArtifactRecovered) Html() string {
if x.SiteId != -1 {
w = site(x.SiteId, "in ")
if x.StructureId != -1 {
w = "from " + structure(x.SiteId, x.StructureId) + " " + w
w = siteStructure(x.SiteId, x.StructureId, "from")
}
}
return fmt.Sprintf("%s was recovered %s by %s", a, w, h)
}
func (x *HistoricalEventArtifactStored) Html() string {
return fmt.Sprintf("%s stored %s in %s", hf(x.HistFigureId), artifact(x.ArtifactId), site(x.SiteId, ""))
func (x *HistoricalEventArtifactStored) Html() string { // TODO export siteProperty
if x.HistFigureId != -1 {
return fmt.Sprintf("%s stored %s in %s", hf(x.HistFigureId), artifact(x.ArtifactId), site(x.SiteId, ""))
} else {
return fmt.Sprintf("%s was stored in %s", artifact(x.ArtifactId), site(x.SiteId, ""))
}
}
func (x *HistoricalEventArtifactTransformed) Html() string {
@ -386,6 +408,7 @@ func (x *HistoricalEventChangeHfJob) Html() string {
return hf(x.Hfid) + " gave up being " + old + " to become a " + new + w
}
}
func (x *HistoricalEventChangeHfState) Html() string {
r := ""
switch x.Reason {
@ -434,9 +457,11 @@ func (x *HistoricalEventChangeHfState) Html() string {
}
}
switch x.Mood { // TODO catatonic
switch x.Mood {
case HistoricalEventChangeHfStateMood_Berserk:
return hf(x.Hfid) + " went berserk " + site(x.SiteId, "in") + r
case HistoricalEventChangeHfStateMood_Catatonic:
return hf(x.Hfid) + " stopped responding to the outside world " + site(x.SiteId, "in") + r
case HistoricalEventChangeHfStateMood_Fell:
return hf(x.Hfid) + " was taken by a fell mood " + site(x.SiteId, "in") + r
case HistoricalEventChangeHfStateMood_Fey:
@ -502,12 +527,12 @@ func (x *HistoricalEventCreatedSite) Html() string {
}
func (x *HistoricalEventCreatedStructure) Html() string { // TODO rebuild/rebuilt; Structure/StructureId
func (x *HistoricalEventCreatedStructure) Html() string { // TODO rebuild/rebuilt
if x.BuilderHfid != -1 {
return hf(x.BuilderHfid) + " thrust a spire of slade up from the underworld, naming it " + structure(x.SiteId, x.StructureId) +
", and established a gateway between worlds in " + site(x.SiteId, "")
}
return siteCiv(x.SiteCivId, x.CivId) + util.If(x.Rebuilt, " rebuild ", " constructed ") + structure(x.SiteId, x.StructureId) + site(x.SiteId, " in")
return siteCiv(x.SiteCivId, x.CivId) + util.If(x.Rebuilt, " rebuild ", " constructed ") + siteStructure(x.SiteId, x.StructureId, "")
}
func (x *HistoricalEventCreatedWorldConstruction) Html() string {
@ -539,22 +564,51 @@ func (x *HistoricalEventDanceFormCreated) Html() string {
case HistoricalEventDanceFormCreatedCircumstance_PrayToHf:
circumstance = " after praying to " + hf(x.CircumstanceId)
}
return danceForm(x.FormId) + " was created by " + hf(x.HistFigureId) + site(x.SiteId, " in") + reason + circumstance
return danceForm(x.FormId) + " was created by " + hf(x.HistFigureId) + location(x.SiteId, " in", x.SubregionId, " in") + reason + circumstance
}
func (x *HistoricalEventDestroyedSite) Html() string { return "UNKNWON HistoricalEventDestroyedSite" }
func (x *HistoricalEventDiplomatLost) Html() string { return "UNKNWON HistoricalEventDiplomatLost" }
func (x *HistoricalEventDestroyedSite) Html() string { // TODO NoDefeatMention
return entity(x.AttackerCivId) + " defeated " + siteCiv(x.SiteCivId, x.DefenderCivId) + " and destroyed " + site(x.SiteId, "")
}
func (x *HistoricalEventDiplomatLost) Html() string { // TODO
return "UNKNWON HistoricalEventDiplomatLost"
}
func (x *HistoricalEventEntityAllianceFormed) Html() string {
return "UNKNWON HistoricalEventEntityAllianceFormed"
return entityList(x.JoiningEnid) + " swore to support " + entity(x.InitiatingEnid) + " in war if the latter did likewise"
}
func (x *HistoricalEventEntityBreachFeatureLayer) Html() string {
return "UNKNWON HistoricalEventEntityBreachFeatureLayer"
return siteCiv(x.SiteEntityId, x.CivEntityId) + " breached the Underworld at " + site(x.SiteId, "")
}
func (x *HistoricalEventEntityCreated) Html() string { return "UNKNWON HistoricalEventEntityCreated" }
func (x *HistoricalEventEntityCreated) Html() string {
if x.CreatorHfid != -1 {
return hf(x.CreatorHfid) + " formed " + entity(x.EntityId) + siteStructure(x.SiteId, x.StructureId, "in")
} else {
return entity(x.EntityId) + " formed" + siteStructure(x.SiteId, x.StructureId, "in")
}
}
func (x *HistoricalEventEntityDissolved) Html() string {
return "UNKNWON HistoricalEventEntityDissolved"
return entity(x.EntityId) + " dissolved after " + x.Reason.String()
}
func (x *HistoricalEventEntityEquipmentPurchase) Html() string {
return "UNKNWON HistoricalEventEntityEquipmentPurchase"
func (x *HistoricalEventEntityEquipmentPurchase) Html() string { // todo check hfid
l := ""
switch x.NewEquipmentLevel {
case 1:
l = "well-crafted"
case 2:
l = "finely-crafted"
case 3:
l = "superior quality"
case 4:
l = "exceptional"
case 5:
l = "masterwork"
}
return entity(x.EntityId) + " purchased " + l + " equipment"
}
func (x *HistoricalEventEntityExpelsHf) Html() string { return "UNKNWON HistoricalEventEntityExpelsHf" }
func (x *HistoricalEventEntityFledSite) Html() string { return "UNKNWON HistoricalEventEntityFledSite" }
@ -727,3 +781,10 @@ func (x *HistoricalEventTrade) Html() string { return "UNKNWON HistoricalEventTr
func (x *HistoricalEventWrittenContentComposed) Html() string {
return "UNKNWON HistoricalEventWrittenContentComposed"
}
func (x *HistoricalEventAgreementConcluded) Html() string {
return "UNKNWON HistoricalEventAgreementConcluded"
}
func (x *HistoricalEventMasterpieceDye) Html() string {
return "UNKNWON HistoricalEventMasterpieceDye"
}

View File

@ -2,6 +2,7 @@ package model
import (
"fmt"
"html/template"
"regexp"
"strings"
@ -39,6 +40,9 @@ func (hf *HistoricalFigure) Male() bool {
type HistoricalEventDetails interface {
RelatedToEntity(int) bool
RelatedToHf(int) bool
RelatedToArtifact(int) bool
RelatedToSite(int) bool
RelatedToRegion(int) bool
Html() string
Type() string
}
@ -85,6 +89,10 @@ func entity(id int) string {
return "UNKNOWN ENTITY"
}
func entityList(ids []int) string {
return andList(util.Map(ids, entity))
}
func siteCiv(siteCivId, civId int) string {
if siteCivId == civId {
return entity(civId)
@ -92,9 +100,16 @@ func siteCiv(siteCivId, civId int) string {
return util.If(siteCivId != -1, entity(siteCivId), "") + util.If(civId != -1 && siteCivId != -1, " of ", "") + util.If(civId != -1, entity(civId), "")
}
func siteStructure(siteId, structureId int, prefix string) string {
if siteId == -1 {
return ""
}
return " " + prefix + " " + util.If(structureId != -1, structure(siteId, structureId)+" in ", "") + site(siteId, "")
}
func hf(id int) string {
if x, ok := world.HistoricalFigures[id]; ok {
return fmt.Sprintf(`the %s <a class="hf" href="/hf/%d">%s</a>`, x.Race, x.Id(), util.Title(x.Name()))
return fmt.Sprintf(`the %s <a class="hf" href="/hf/%d">%s</a>`, x.Race+util.If(x.Deity, " deity", "")+util.If(x.Force, " force", ""), x.Id(), util.Title(x.Name()))
}
return "UNKNOWN HISTORICAL FIGURE"
}
@ -214,3 +229,8 @@ func worldConstruction(id int) string {
}
return "UNKNOWN WORLD CONSTRUCTION"
}
var LinkHf = func(id int) template.HTML { return template.HTML(hf(id)) }
var LinkEntity = func(id int) template.HTML { return template.HTML(entity(id)) }
var LinkSite = func(id int) template.HTML { return template.HTML(site(id, "")) }
var LinkRegion = func(id int) template.HTML { return template.HTML(region(id)) }

File diff suppressed because it is too large Load Diff

View File

@ -5,11 +5,24 @@
"HistoricalEventAddHfSiteLink": {
"Site": "SiteId"
},
"HistoricalEventAgreementMade": {
"Destination": "SiteId",
"Site": "SiteId",
"Source": "SiteId"
},
"HistoricalEventAgreementRejected": {
"Destination": "SiteId",
"Site": "SiteId",
"Source": "SiteId"
},
"HistoricalEventDiplomatLost": {
"Entity": "SiteId",
"Involved": "SiteId",
"Site": "SiteId"
},
"HistoricalEventHfDied": {
"ShooterArtifactId": "FeatureLayerId"
},
"HistoricalEventPeaceAccepted": {
"Site": "SiteId"
},
@ -21,12 +34,5 @@
},
"HistoricalEventRemoveHfSiteLink": {
"Site": "SiteId"
},
"HistoricalEventReplacedStructure": {
"Civ": "OldAbId",
"NewStructure": "OldAbId",
"OldStructure": "OldAbId",
"Site": "OldAbId",
"SiteCiv": "OldAbId"
}
}

View File

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

View File

@ -1 +0,0 @@
<a href="/entity/{{ .Id }}">{{ title .Name }}</a>

View File

@ -12,13 +12,13 @@
<ul>
{{- range $i := .EntityFormerPositionLink }}
<li>
{{ ((getEntity $i.EntityId).Position $i.PositionProfileId).Name }} of {{ template "entityLink.html" (getEntity $i.EntityId) }} ({{
{{ ((getEntity $i.EntityId).Position $i.PositionProfileId).Name }} of {{ entity $i.EntityId }} ({{
$i.StartYear }} - {{ $i.EndYear }})
</li>
{{- end }}
{{- range $i := .EntityPositionLink }}
<li>
of {{ template "entityLink.html" (getEntity $i.EntityId) }}
of {{ entity $i.EntityId }}
</li>
{{- end }}
</ul>
@ -29,7 +29,7 @@
<ul>
{{- range $i := .HfLink }}
<li>
{{ template "hfLink.html" (getHf $i.Hfid) }} ({{ $i.LinkType }})
{{ hf $i.Hfid }} ({{ $i.LinkType }})
</li>
{{- end }}
</ul>
@ -40,7 +40,7 @@
<ul>
{{- range $i := .EntityLink }}
<li>
{{ template "entityLink.html" (getEntity $i.EntityId) }} ({{ $i.LinkType }})
{{ entity $i.EntityId }} ({{ $i.LinkType }})
</li>
{{- end }}
</ul>

View File

@ -1,5 +0,0 @@
the
{{ .Race }}
{{ check .Deity "deity"}}
{{ check .Force "force"}}
<a href="/hf/{{ .Id }}">{{ title .Name }}</a>

View File

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

View File

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