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, "air": true,
"blood": true, "blood": true,
"blood drained": true, "blood drained": true,
"cage blasted": true,
"chasm": true, "chasm": true,
"crushed": true, "crushed": true,
"crushed bridge": true, "crushed bridge": true,
@ -7558,7 +7559,8 @@
"suicide leaping": true, "suicide leaping": true,
"thirst": true, "thirst": true,
"trap": true, "trap": true,
"vanish": true "vanish": true,
"vehicle": true
}, },
"Enum": true "Enum": true
}, },
@ -7573,6 +7575,7 @@
"bleed": true, "bleed": true,
"burn_alive": true, "burn_alive": true,
"bury_alive": true, "bury_alive": true,
"cage": true,
"cavein": true, "cavein": true,
"chasm": true, "chasm": true,
"collision": true, "collision": true,
@ -7604,7 +7607,8 @@
"suffocate": true, "suffocate": true,
"thirst": true, "thirst": true,
"trap": true, "trap": true,
"vanish": true "vanish": true,
"vehicle": true
}, },
"Enum": true "Enum": true
}, },
@ -7711,10 +7715,13 @@
"Plus": true, "Plus": true,
"Values": { "Values": {
"apple wood": true, "apple wood": true,
"bismuth bronze": true,
"bronze": true, "bronze": true,
"chestnut": true, "chestnut": true,
"copper": true, "copper": true,
"iron": true "date palm wood": true,
"iron": true,
"steel": true
}, },
"Enum": true "Enum": true
}, },
@ -16271,6 +16278,93 @@
"plus": "" "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": { "df_world|regions|region": {
"Desert": { "Desert": {
"name": "Desert", "name": "Desert",
@ -16435,63 +16529,63 @@
"df_world|sites|site|structures|structure": { "df_world|sites|site|structures|structure": {
"CountingHouse": { "CountingHouse": {
"name": "CountingHouse", "name": "CountingHouse",
"base": "", "base": "counting house",
"plus": "counting_house" "plus": "counting_house"
}, },
"Dungeon": { "Dungeon": {
"name": "Dungeon", "name": "Dungeon",
"base": "", "base": "dungeon",
"plus": "dungeon" "plus": "dungeon"
}, },
"Guildhall": { "Guildhall": {
"name": "Guildhall", "name": "Guildhall",
"base": "", "base": "guildhall",
"plus": "guildhall" "plus": "guildhall"
}, },
"InnTavern": { "InnTavern": {
"name": "InnTavern", "name": "InnTavern",
"base": "", "base": "inn tavern",
"plus": "inn_tavern" "plus": "inn_tavern"
}, },
"Keep": { "Keep": {
"name": "Keep", "name": "Keep",
"base": "", "base": "keep",
"plus": "keep" "plus": ""
}, },
"Library": { "Library": {
"name": "Library", "name": "Library",
"base": "", "base": "library",
"plus": "library" "plus": "library"
}, },
"Market": { "Market": {
"name": "Market", "name": "Market",
"base": "", "base": "market",
"plus": "market" "plus": ""
}, },
"MeadHall": { "MeadHall": {
"name": "MeadHall", "name": "MeadHall",
"base": "", "base": "mead hall",
"plus": "mead_hall" "plus": ""
}, },
"Temple": { "Temple": {
"name": "Temple", "name": "Temple",
"base": "", "base": "temple",
"plus": "temple" "plus": "temple"
}, },
"Tomb": { "Tomb": {
"name": "Tomb", "name": "Tomb",
"base": "", "base": "tomb",
"plus": "tomb" "plus": "tomb"
}, },
"Tower": { "Tower": {
"name": "Tower", "name": "Tower",
"base": "", "base": "tower",
"plus": "tower" "plus": "tower"
}, },
"UnderworldSpire": { "UnderworldSpire": {
"name": "UnderworldSpire", "name": "UnderworldSpire",
"base": "", "base": "underworld spire",
"plus": "underworld_spire" "plus": ""
} }
}, },
"df_world|underground_regions|underground_region": { "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 }}) RelatedToHf(id int) bool { return {{ $obj.RelatedToHf }} }
func (x *{{ $obj.Name }}) RelatedToArtifact(id int) bool { return {{ $obj.RelatedToArtifact }} } 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 }}) 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 }}) RelatedToRegion(id int) bool { return {{ $obj.RelatedToRegion }} }
func (x *{{ $obj.Name }}) CheckFields() { 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 hfRegex, _ = regexp.Compile("(hfid|hf_id|hist_figure_id|histfig_id|histfig|bodies|_hf)")
var artifactRegex, _ = regexp.Compile("(item(_id)?|artifact_id)$") var artifactRegex, _ = regexp.Compile("(item(_id)?|artifact_id)$")
var siteRegex, _ = regexp.Compile("(site_id|site)[0-9]?$") var siteRegex, _ = regexp.Compile("(site_id|site)[0-9]?$")
var structureRegex, _ = regexp.Compile("(structure(_id)?)$")
var regionRegex, _ = regexp.Compile("(region_id|srid)$") var regionRegex, _ = regexp.Compile("(region_id|srid)$")
func (obj Object) RelatedToEntity() string { func (obj Object) RelatedToEntity() string {
return obj.Related(entityRegex) return obj.Related(entityRegex, "")
} }
func (obj Object) RelatedToHf() string { func (obj Object) RelatedToHf() string {
return obj.Related(hfRegex) return obj.Related(hfRegex, "")
} }
func (obj Object) RelatedToArtifact() string { func (obj Object) RelatedToArtifact() string {
return obj.Related(artifactRegex) return obj.Related(artifactRegex, "")
} }
func (obj Object) RelatedToSite() string { 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 { 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 var list []string
for n, f := range obj.Fields { for n, f := range obj.Fields {
if f.Type == "int" && !f.SameField(obj) && regex.MatchString(n) { 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) sort.Strings(list)
if len(list) > 0 { if len(list) > 0 {
return strings.Join(list, " || ") l := strings.Join(list, " || ")
if init == "" {
return l
} else {
return init + "&& (" + l + ")"
}
} }
return "false" return "false"
} }
@ -511,6 +521,9 @@ func (f Field) SameField(obj Object) bool {
func (f Field) CorrectedName(obj Object) string { func (f Field) CorrectedName(obj Object) string {
if f.Legend != "plus" { if f.Legend != "plus" {
if f.Name == "LocalId" && obj.Id {
return "Id_"
}
return f.Name return f.Name
} }
n, ok := sameFields[obj.Name][f.Name] n, ok := sameFields[obj.Name][f.Name]

View File

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

View File

@ -9,6 +9,7 @@ type HistoricalEventDetails interface {
RelatedToHf(int) bool RelatedToHf(int) bool
RelatedToArtifact(int) bool RelatedToArtifact(int) bool
RelatedToSite(int) bool RelatedToSite(int) bool
RelatedToStructure(int, int) bool
RelatedToRegion(int) bool RelatedToRegion(int) bool
Html(*Context) string Html(*Context) string
Type() 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()) }) el.Events = world.EventsMatching(func(d HistoricalEventDetails) bool { return d.RelatedToArtifact(x.Id()) })
case *Site: case *Site:
el.Events = world.EventsMatching(func(d HistoricalEventDetails) bool { return d.RelatedToSite(x.Id()) }) 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: case *Region:
el.Events = world.EventsMatching(func(d HistoricalEventDetails) bool { return d.RelatedToRegion(x.Id()) }) el.Events = world.EventsMatching(func(d HistoricalEventDetails) bool { return d.RelatedToRegion(x.Id()) })
case []*HistoricalEvent: 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.HistoricalFigures, results, "/hf")
results = seachMap(term, h.server.context.world.Entities, results, "/entity") results = seachMap(term, h.server.context.world.Entities, results, "/entity")
results = seachMap(term, h.server.context.world.Sites, results, "/site") 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.Regions, results, "/region")
results = seachMap(term, h.server.context.world.Artifacts, results, "/artifavt") results = seachMap(term, h.server.context.world.Artifacts, results, "/artifavt")
results = seachMap(term, h.server.context.world.WorldConstructions, results, "/worldconstruction") results = seachMap(term, h.server.context.world.WorldConstructions, results, "/worldconstruction")