relationship events
This commit is contained in:
parent
849349b7fd
commit
97cdf624be
|
@ -374,7 +374,12 @@ func (f Field) StartAction(obj Object, plus bool) string {
|
||||||
gen := fmt.Sprintf("parse%s", *f.ElementType)
|
gen := fmt.Sprintf("parse%s", *f.ElementType)
|
||||||
|
|
||||||
if f.Type == "array" {
|
if f.Type == "array" {
|
||||||
return fmt.Sprintf("parseArray(p, &obj.%s, %s)", f.Name, gen)
|
if !plus {
|
||||||
|
return fmt.Sprintf("parseArray(p, &obj.%s, %s)", f.Name, gen)
|
||||||
|
} else {
|
||||||
|
gen = fmt.Sprintf("parse%sPlus", *f.ElementType)
|
||||||
|
return fmt.Sprintf("parseArrayPlus(p, &obj.%s, %s)", f.Name, gen)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.Type == "map" {
|
if f.Type == "map" {
|
||||||
|
|
|
@ -74,6 +74,12 @@
|
||||||
"Type": "int"
|
"Type": "int"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"HistoricalEventAddHfHfLink": [
|
||||||
|
{
|
||||||
|
"Name": "Relationship",
|
||||||
|
"Type": "HistoricalEventRelationshipRelationship"
|
||||||
|
}
|
||||||
|
],
|
||||||
"HistoricalEventCollectionAbduction": [
|
"HistoricalEventCollectionAbduction": [
|
||||||
{
|
{
|
||||||
"Name": "TargetHfids",
|
"Name": "TargetHfids",
|
||||||
|
|
|
@ -58,12 +58,15 @@ func (x *HistoricalEventAddHfHfLink) Html(c *Context) string {
|
||||||
case HistoricalEventAddHfHfLinkLinkType_Master:
|
case HistoricalEventAddHfHfLinkLinkType_Master:
|
||||||
return h + " began an apprenticeship under " + t
|
return h + " began an apprenticeship under " + t
|
||||||
case HistoricalEventAddHfHfLinkLinkType_PetOwner:
|
case HistoricalEventAddHfHfLinkLinkType_PetOwner:
|
||||||
return h + " became the owner of " + t
|
return t + " became the owner of " + h
|
||||||
case HistoricalEventAddHfHfLinkLinkType_Prisoner:
|
case HistoricalEventAddHfHfLinkLinkType_Prisoner:
|
||||||
return h + " imprisoned " + t
|
return h + " imprisoned " + t
|
||||||
case HistoricalEventAddHfHfLinkLinkType_Spouse:
|
case HistoricalEventAddHfHfLinkLinkType_Spouse:
|
||||||
return h + " married " + t
|
return h + " married " + t
|
||||||
default:
|
default:
|
||||||
|
if x.Relationship != HistoricalEventRelationshipRelationship_Unknown {
|
||||||
|
return h + " and " + t + " became " + x.Relationship.String() + "s" // TODO Texts
|
||||||
|
}
|
||||||
return h + " LINKED TO " + t
|
return h + " LINKED TO " + t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -883,7 +886,6 @@ func (x *HistoricalEventHfDied) Html(c *Context) string {
|
||||||
|
|
||||||
if x.SlayerItemId != -1 {
|
if x.SlayerItemId != -1 {
|
||||||
slayer += " with " + c.artifact(x.SlayerItemId)
|
slayer += " with " + c.artifact(x.SlayerItemId)
|
||||||
} else {
|
|
||||||
}
|
}
|
||||||
switch x.Cause {
|
switch x.Cause {
|
||||||
case HistoricalEventHfDiedCause_Behead, HistoricalEventHfDiedCause_ExecBeheaded:
|
case HistoricalEventHfDiedCause_Behead, HistoricalEventHfDiedCause_ExecBeheaded:
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"image/png"
|
"image/png"
|
||||||
_ "image/png"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
|
@ -3035,9 +3035,10 @@ func (s HistoricalEventAddHfHfLinkLinkType) MarshalJSON() ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type HistoricalEventAddHfHfLink struct {
|
type HistoricalEventAddHfHfLink struct {
|
||||||
Hfid int `json:"hfid" legend:"base"` // hfid
|
Hfid int `json:"hfid" legend:"base"` // hfid
|
||||||
HfidTarget int `json:"hfidTarget" legend:"base"` // hfid_target
|
HfidTarget int `json:"hfidTarget" legend:"base"` // hfid_target
|
||||||
LinkType HistoricalEventAddHfHfLinkLinkType `json:"linkType" legend:"plus"` // link_type
|
LinkType HistoricalEventAddHfHfLinkLinkType `json:"linkType" legend:"plus"` // link_type
|
||||||
|
Relationship HistoricalEventRelationshipRelationship `json:"relationship" legend:"add"` // Relationship
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHistoricalEventAddHfHfLink() *HistoricalEventAddHfHfLink {
|
func NewHistoricalEventAddHfHfLink() *HistoricalEventAddHfHfLink {
|
||||||
|
@ -3075,6 +3076,7 @@ func (x *HistoricalEventAddHfHfLink) MarshalJSON() ([]byte, error) {
|
||||||
if x.LinkType != 0 {
|
if x.LinkType != 0 {
|
||||||
d["linkType"] = x.LinkType
|
d["linkType"] = x.LinkType
|
||||||
}
|
}
|
||||||
|
d["relationship"] = x.Relationship
|
||||||
return json.Marshal(d)
|
return json.Marshal(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23016,7 +23018,7 @@ func parseDfWorldPlus(p *util.XMLParser, obj *DfWorld) (*DfWorld, error) {
|
||||||
case "artifacts":
|
case "artifacts":
|
||||||
parseMapPlus(p, &obj.Artifacts, parseArtifactPlus)
|
parseMapPlus(p, &obj.Artifacts, parseArtifactPlus)
|
||||||
case "creature_raw":
|
case "creature_raw":
|
||||||
parseArray(p, &obj.CreatureRaw, parseCreature)
|
parseArrayPlus(p, &obj.CreatureRaw, parseCreaturePlus)
|
||||||
case "dance_forms":
|
case "dance_forms":
|
||||||
parseMapPlus(p, &obj.DanceForms, parseDanceFormPlus)
|
parseMapPlus(p, &obj.DanceForms, parseDanceFormPlus)
|
||||||
case "entities":
|
case "entities":
|
||||||
|
@ -23024,13 +23026,13 @@ func parseDfWorldPlus(p *util.XMLParser, obj *DfWorld) (*DfWorld, error) {
|
||||||
case "entity_populations":
|
case "entity_populations":
|
||||||
parseMapPlus(p, &obj.EntityPopulations, parseEntityPopulationPlus)
|
parseMapPlus(p, &obj.EntityPopulations, parseEntityPopulationPlus)
|
||||||
case "historical_eras":
|
case "historical_eras":
|
||||||
parseArray(p, &obj.HistoricalEras, parseHistoricalEra)
|
parseArrayPlus(p, &obj.HistoricalEras, parseHistoricalEraPlus)
|
||||||
case "historical_event_collections":
|
case "historical_event_collections":
|
||||||
parseMapPlus(p, &obj.HistoricalEventCollections, parseHistoricalEventCollectionPlus)
|
parseMapPlus(p, &obj.HistoricalEventCollections, parseHistoricalEventCollectionPlus)
|
||||||
case "historical_event_relationship_supplements":
|
case "historical_event_relationship_supplements":
|
||||||
parseArray(p, &obj.HistoricalEventRelationshipSupplements, parseHistoricalEventRelationshipSupplement)
|
parseArrayPlus(p, &obj.HistoricalEventRelationshipSupplements, parseHistoricalEventRelationshipSupplementPlus)
|
||||||
case "historical_event_relationships":
|
case "historical_event_relationships":
|
||||||
parseArray(p, &obj.HistoricalEventRelationships, parseHistoricalEventRelationship)
|
parseArrayPlus(p, &obj.HistoricalEventRelationships, parseHistoricalEventRelationshipPlus)
|
||||||
case "historical_events":
|
case "historical_events":
|
||||||
parseMapPlus(p, &obj.HistoricalEvents, parseHistoricalEventPlus)
|
parseMapPlus(p, &obj.HistoricalEvents, parseHistoricalEventPlus)
|
||||||
case "historical_figures":
|
case "historical_figures":
|
||||||
|
@ -23054,7 +23056,7 @@ func parseDfWorldPlus(p *util.XMLParser, obj *DfWorld) (*DfWorld, error) {
|
||||||
case "regions":
|
case "regions":
|
||||||
parseMapPlus(p, &obj.Regions, parseRegionPlus)
|
parseMapPlus(p, &obj.Regions, parseRegionPlus)
|
||||||
case "rivers":
|
case "rivers":
|
||||||
parseArray(p, &obj.Rivers, parseRiver)
|
parseArrayPlus(p, &obj.Rivers, parseRiverPlus)
|
||||||
case "sites":
|
case "sites":
|
||||||
parseMapPlus(p, &obj.Sites, parseSitePlus)
|
parseMapPlus(p, &obj.Sites, parseSitePlus)
|
||||||
case "underground_regions":
|
case "underground_regions":
|
||||||
|
|
|
@ -166,6 +166,24 @@ func parseArray[T any](p *util.XMLParser, dest *[]T, creator func(*util.XMLParse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseArrayPlus[T any](p *util.XMLParser, dest *[]T, creator func(*util.XMLParser, T) (T, error)) {
|
||||||
|
for {
|
||||||
|
t, _, err := p.Token()
|
||||||
|
if err != nil {
|
||||||
|
return // nil, err
|
||||||
|
}
|
||||||
|
switch t {
|
||||||
|
case util.StartElement:
|
||||||
|
var x T
|
||||||
|
x, _ = creator(p, x)
|
||||||
|
*dest = append(*dest, x)
|
||||||
|
|
||||||
|
case util.EndElement:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func parseMap[T Identifiable](p *util.XMLParser, dest *map[int]T, creator func(*util.XMLParser) (T, error)) {
|
func parseMap[T Identifiable](p *util.XMLParser, dest *map[int]T, creator func(*util.XMLParser) (T, error)) {
|
||||||
for {
|
for {
|
||||||
t, _, err := p.Token()
|
t, _, err := p.Token()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/robertjanetzko/LegendsBrowser2/backend/util"
|
"github.com/robertjanetzko/LegendsBrowser2/backend/util"
|
||||||
|
@ -8,6 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (w *DfWorld) process() {
|
func (w *DfWorld) process() {
|
||||||
|
w.addRelationshipEvents()
|
||||||
|
|
||||||
// set site in structure
|
// set site in structure
|
||||||
for _, site := range w.Sites {
|
for _, site := range w.Sites {
|
||||||
|
@ -139,3 +141,18 @@ func (w *DfWorld) addEntitySite(entityId, siteId int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *DfWorld) addRelationshipEvents() {
|
||||||
|
for _, r := range w.HistoricalEventRelationships {
|
||||||
|
fmt.Println(r)
|
||||||
|
w.HistoricalEvents[r.Event] = &HistoricalEvent{
|
||||||
|
Id_: r.Event,
|
||||||
|
Year: r.Year,
|
||||||
|
Details: &HistoricalEventAddHfHfLink{
|
||||||
|
Hfid: r.SourceHf,
|
||||||
|
HfidTarget: r.TargetHf,
|
||||||
|
Relationship: r.Relationship,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue