diff --git a/analyze/overwrites.json b/analyze/overwrites.json
index 304cb99..3a0c267 100644
--- a/analyze/overwrites.json
+++ b/analyze/overwrites.json
@@ -110,6 +110,10 @@
}
],
"Site": [
+ {
+ "Name": "Owner",
+ "Type": "int"
+ },
{
"Name": "Ruin",
"Type": "bool"
diff --git a/backend/model/context.go b/backend/model/context.go
index 594ca0b..4a9a62c 100644
--- a/backend/model/context.go
+++ b/backend/model/context.go
@@ -141,21 +141,9 @@ func (c *Context) artifact(id int) string {
func (c *Context) entity(id int) string {
if x, ok := c.World.Entities[id]; ok {
- 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"`
+ c := x.Color()
+ if c != "" {
+ c = fmt.Sprintf(` style="color:%s"`, c)
}
return fmt.Sprintf(` %s`, x.Id(), x.Icon(), c, util.Title(x.Name()))
}
diff --git a/backend/model/extensions.go b/backend/model/extensions.go
index 50bb8fb..3eef967 100644
--- a/backend/model/extensions.go
+++ b/backend/model/extensions.go
@@ -96,6 +96,26 @@ func (e *Entity) Type() string {
return e.Type_.String()
}
+func (x *Entity) Color() string {
+ c := ""
+ switch x.Race {
+ case "dwarf":
+ c = `#FFCC33`
+ case "elf":
+ c = `#99FF00`
+ case "human":
+ c = `#0000CC`
+ case "kobold":
+ c = `#333`
+ case "goblin":
+ c = `#CC0000`
+ }
+ if x.Necromancer {
+ c = `#A0A`
+ }
+ return c
+}
+
func (e *Entity) Weapons() []string {
return util.Map(e.Weapon, func(w EntityWeapon) string { return w.String() })
}
diff --git a/backend/model/functions.go b/backend/model/functions.go
index f364036..2b42b7e 100644
--- a/backend/model/functions.go
+++ b/backend/model/functions.go
@@ -82,7 +82,11 @@ var AddMapSite = func(w *DfWorld, id int) template.HTML {
c2 := strings.Split(coords[1], ",")
x2, _ := strconv.ParseFloat(c2[0], 32)
y2, _ := strconv.ParseFloat(c2[1], 32)
- return template.HTML(fmt.Sprintf(``, site.Name(), x1/16.0, y1/16.0-1, x2/16.0, y2/16.0-1))
+ c := "#ff0"
+ if e, ok := w.Entities[site.Owner]; ok {
+ c = e.Color()
+ }
+ return template.HTML(fmt.Sprintf(``, site.Name(), x1/16.0, y1/16.0-1, x2/16.0, y2/16.0-1, c))
} else {
return ""
}
diff --git a/backend/model/model.go b/backend/model/model.go
index b4d7a23..10db265 100644
--- a/backend/model/model.go
+++ b/backend/model/model.go
@@ -21131,6 +21131,7 @@ type Site struct {
SiteProperties map[int]*SiteSiteProperty `json:"siteProperties" legend:"base" related:""` // site_properties
Structures map[int]*Structure `json:"structures" legend:"both" related:""` // structures
Type_ SiteType `json:"type" legend:"base" related:""` // type
+ Owner int `json:"owner" legend:"add" related:""` // Owner
Ruin bool `json:"ruin" legend:"add" related:""` // Ruin
}
@@ -21141,6 +21142,7 @@ func NewSite() *Site {
Id_: -1,
SiteProperties: make(map[int]*SiteSiteProperty),
Structures: make(map[int]*Structure),
+ Owner: -1,
}
}
func (x *Site) Id() int { return x.Id_ }
@@ -21169,6 +21171,9 @@ func (x *Site) MarshalJSON() ([]byte, error) {
if x.Type_ != 0 {
d["type"] = x.Type_
}
+ if x.Owner != -1 {
+ d["owner"] = x.Owner
+ }
d["ruin"] = x.Ruin
return json.Marshal(d)
}
diff --git a/backend/model/process.go b/backend/model/process.go
index c4f6f3c..67b9367 100644
--- a/backend/model/process.go
+++ b/backend/model/process.go
@@ -76,6 +76,7 @@ func (w *DfWorld) processEvents() {
w.addEntitySite(d.CivId, d.SiteId)
w.addEntitySite(d.SiteCivId, d.SiteId)
w.Sites[d.SiteId].Ruin = false
+ w.Sites[d.SiteId].Owner = d.SiteCivId
case *HistoricalEventDestroyedSite:
w.addEntitySite(d.DefenderCivId, d.SiteId)
w.addEntitySite(d.SiteCivId, d.SiteId)
@@ -86,6 +87,7 @@ func (w *DfWorld) processEvents() {
w.addEntitySite(d.DefenderCivId, d.SiteId)
w.addEntitySite(d.NewSiteCivId, d.SiteId)
w.Sites[d.SiteId].Ruin = false
+ w.Sites[d.SiteId].Owner = d.NewSiteCivId
case *HistoricalEventHfDestroyedSite:
w.addEntitySite(d.SiteCivId, d.SiteId)
w.addEntitySite(d.DefenderCivId, d.SiteId)
@@ -94,6 +96,7 @@ func (w *DfWorld) processEvents() {
w.addEntitySite(d.SiteCivId, d.SiteId)
w.addEntitySite(d.SiteCivId, d.SiteId)
w.Sites[d.SiteId].Ruin = false
+ w.Sites[d.SiteId].Owner = d.SiteCivId
case *HistoricalEventAddHfEntityLink:
if d.Link == HistoricalEventAddHfEntityLinkLink_Position {
if hf, ok := w.HistoricalFigures[d.Hfid]; ok {