related to structure

This commit is contained in:
Robert Janetzko 2022-04-30 08:25:50 +00:00
parent 8b7fa14258
commit 444b0cd24a
6 changed files with 1267 additions and 853 deletions

View File

@ -7526,6 +7526,7 @@
"air": true,
"blood": true,
"blood drained": true,
"cage blasted": true,
"chasm": true,
"crushed": true,
"crushed bridge": true,
@ -7558,7 +7559,8 @@
"suicide leaping": true,
"thirst": true,
"trap": true,
"vanish": true
"vanish": true,
"vehicle": true
},
"Enum": true
},
@ -7573,6 +7575,7 @@
"bleed": true,
"burn_alive": true,
"bury_alive": true,
"cage": true,
"cavein": true,
"chasm": true,
"collision": true,
@ -7604,7 +7607,8 @@
"suffocate": true,
"thirst": true,
"trap": true,
"vanish": true
"vanish": true,
"vehicle": true
},
"Enum": true
},
@ -7711,10 +7715,13 @@
"Plus": true,
"Values": {
"apple wood": true,
"bismuth bronze": true,
"bronze": true,
"chestnut": true,
"copper": true,
"iron": true
"date palm wood": true,
"iron": true,
"steel": true
},
"Enum": true
},
@ -16271,6 +16278,93 @@
"plus": ""
}
},
"df_world|historical_figures|historical_figure|intrigue_plot": {
"": {
"name": "",
"base": "",
"plus": ""
},
"AcquireArtifact": {
"name": "AcquireArtifact",
"base": "acquire artifact",
"plus": ""
},
"AssassinateActor": {
"name": "AssassinateActor",
"base": "assassinate actor",
"plus": ""
},
"AttainRank": {
"name": "AttainRank",
"base": "attain rank",
"plus": ""
},
"BecomeImmortal": {
"name": "BecomeImmortal",
"base": "become immortal",
"plus": ""
},
"CorruptActorsGovernment": {
"name": "CorruptActorsGovernment",
"base": "corrupt actor's government",
"plus": ""
},
"CorruptlyPunishActor": {
"name": "CorruptlyPunishActor",
"base": "corruptly punish actor",
"plus": ""
},
"Counterintelligence": {
"name": "Counterintelligence",
"base": "counterintelligence",
"plus": ""
},
"DirectWarToActor": {
"name": "DirectWarToActor",
"base": "direct war to actor",
"plus": ""
},
"FrameActor": {
"name": "FrameActor",
"base": "frame actor",
"plus": ""
},
"GrowAssetNetwork": {
"name": "GrowAssetNetwork",
"base": "grow asset network",
"plus": ""
},
"GrowCorruptionNetwork": {
"name": "GrowCorruptionNetwork",
"base": "grow corruption network",
"plus": ""
},
"GrowFundingNetwork": {
"name": "GrowFundingNetwork",
"base": "grow funding network",
"plus": ""
},
"InfiltrateSociety": {
"name": "InfiltrateSociety",
"base": "infiltrate society",
"plus": ""
},
"KidnapActor": {
"name": "KidnapActor",
"base": "kidnap actor",
"plus": ""
},
"SabotageActor": {
"name": "SabotageActor",
"base": "sabotage actor",
"plus": ""
},
"UndeadWorldConquest": {
"name": "UndeadWorldConquest",
"base": "undead world conquest",
"plus": ""
}
},
"df_world|regions|region": {
"Desert": {
"name": "Desert",
@ -16435,63 +16529,63 @@
"df_world|sites|site|structures|structure": {
"CountingHouse": {
"name": "CountingHouse",
"base": "",
"base": "counting house",
"plus": "counting_house"
},
"Dungeon": {
"name": "Dungeon",
"base": "",
"base": "dungeon",
"plus": "dungeon"
},
"Guildhall": {
"name": "Guildhall",
"base": "",
"base": "guildhall",
"plus": "guildhall"
},
"InnTavern": {
"name": "InnTavern",
"base": "",
"base": "inn tavern",
"plus": "inn_tavern"
},
"Keep": {
"name": "Keep",
"base": "",
"plus": "keep"
"base": "keep",
"plus": ""
},
"Library": {
"name": "Library",
"base": "",
"base": "library",
"plus": "library"
},
"Market": {
"name": "Market",
"base": "",
"plus": "market"
"base": "market",
"plus": ""
},
"MeadHall": {
"name": "MeadHall",
"base": "",
"plus": "mead_hall"
"base": "mead hall",
"plus": ""
},
"Temple": {
"name": "Temple",
"base": "",
"base": "temple",
"plus": "temple"
},
"Tomb": {
"name": "Tomb",
"base": "",
"base": "tomb",
"plus": "tomb"
},
"Tower": {
"name": "Tower",
"base": "",
"base": "tower",
"plus": "tower"
},
"UnderworldSpire": {
"name": "UnderworldSpire",
"base": "",
"plus": "underworld_spire"
"base": "underworld spire",
"plus": ""
}
},
"df_world|underground_regions|underground_region": {

View File

@ -134,6 +134,7 @@ func (x *{{ $obj.Name }}) RelatedToEntity(id int) bool { return {{ $obj.RelatedT
func (x *{{ $obj.Name }}) RelatedToHf(id int) bool { return {{ $obj.RelatedToHf }} }
func (x *{{ $obj.Name }}) RelatedToArtifact(id int) bool { return {{ $obj.RelatedToArtifact }} }
func (x *{{ $obj.Name }}) RelatedToSite(id int) bool { return {{ $obj.RelatedToSite }} }
func (x *{{ $obj.Name }}) RelatedToStructure(siteId, id int) bool { return {{ $obj.RelatedToStructure }} }
func (x *{{ $obj.Name }}) RelatedToRegion(id int) bool { return {{ $obj.RelatedToRegion }} }
func (x *{{ $obj.Name }}) CheckFields() {
@ -441,25 +442,29 @@ var entityRegex, _ = regexp.Compile("(civ|civ_id|enid|[^d]*entity(_id)?|^entity(
var hfRegex, _ = regexp.Compile("(hfid|hf_id|hist_figure_id|histfig_id|histfig|bodies|_hf)")
var artifactRegex, _ = regexp.Compile("(item(_id)?|artifact_id)$")
var siteRegex, _ = regexp.Compile("(site_id|site)[0-9]?$")
var structureRegex, _ = regexp.Compile("(structure(_id)?)$")
var regionRegex, _ = regexp.Compile("(region_id|srid)$")
func (obj Object) RelatedToEntity() string {
return obj.Related(entityRegex)
return obj.Related(entityRegex, "")
}
func (obj Object) RelatedToHf() string {
return obj.Related(hfRegex)
return obj.Related(hfRegex, "")
}
func (obj Object) RelatedToArtifact() string {
return obj.Related(artifactRegex)
return obj.Related(artifactRegex, "")
}
func (obj Object) RelatedToSite() string {
return obj.Related(siteRegex)
return obj.Related(siteRegex, "")
}
func (obj Object) RelatedToStructure() string {
return obj.Related(structureRegex, "x.RelatedToSite(siteId)")
}
func (obj Object) RelatedToRegion() string {
return obj.Related(regionRegex)
return obj.Related(regionRegex, "")
}
func (obj Object) Related(regex *regexp.Regexp) string {
func (obj Object) Related(regex *regexp.Regexp, init string) string {
var list []string
for n, f := range obj.Fields {
if f.Type == "int" && !f.SameField(obj) && regex.MatchString(n) {
@ -472,7 +477,12 @@ func (obj Object) Related(regex *regexp.Regexp) string {
}
sort.Strings(list)
if len(list) > 0 {
return strings.Join(list, " || ")
l := strings.Join(list, " || ")
if init == "" {
return l
} else {
return init + "&& (" + l + ")"
}
}
return "false"
}
@ -511,6 +521,9 @@ func (f Field) SameField(obj Object) bool {
func (f Field) CorrectedName(obj Object) string {
if f.Legend != "plus" {
if f.Name == "LocalId" && obj.Id {
return "Id_"
}
return f.Name
}
n, ok := sameFields[obj.Name][f.Name]

View File

@ -269,7 +269,7 @@ Loop:
return nil, err
}
if v != nil {
if v.Name == "id" {
if v.Name == "id" || v.Name == "local_id" {
idFound = true
id, _ = strconv.Atoi(v.Value)
}

View File

@ -9,6 +9,7 @@ type HistoricalEventDetails interface {
RelatedToHf(int) bool
RelatedToArtifact(int) bool
RelatedToSite(int) bool
RelatedToStructure(int, int) bool
RelatedToRegion(int) bool
Html(*Context) string
Type() string
@ -40,6 +41,8 @@ func NewEventList(world *DfWorld, obj any) *EventList {
el.Events = world.EventsMatching(func(d HistoricalEventDetails) bool { return d.RelatedToArtifact(x.Id()) })
case *Site:
el.Events = world.EventsMatching(func(d HistoricalEventDetails) bool { return d.RelatedToSite(x.Id()) })
case *Structure:
el.Events = world.EventsMatching(func(d HistoricalEventDetails) bool { return d.RelatedToStructure(x.SiteId, x.Id()) })
case *Region:
el.Events = world.EventsMatching(func(d HistoricalEventDetails) bool { return d.RelatedToRegion(x.Id()) })
case []*HistoricalEvent:

File diff suppressed because it is too large Load Diff

View File

@ -33,6 +33,9 @@ func (h searchHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
results = seachMap(term, h.server.context.world.HistoricalFigures, results, "/hf")
results = seachMap(term, h.server.context.world.Entities, results, "/entity")
results = seachMap(term, h.server.context.world.Sites, results, "/site")
for _, site := range h.server.context.world.Sites {
results = seachMap(term, site.Structures, results, fmt.Sprintf("/site/%d/structure", site.Id_))
}
results = seachMap(term, h.server.context.world.Regions, results, "/region")
results = seachMap(term, h.server.context.world.Artifacts, results, "/artifavt")
results = seachMap(term, h.server.context.world.WorldConstructions, results, "/worldconstruction")