robertjanetzko/LegendsBrowser2

Knowledge discovered is shown as a colon-delimited string

Closed this issue · 2 comments

Knowledge events currently describe the type of knowledge discovered as a colon-delimited string, not the English phrase displayed in dwarf fortress:

Current:
Screen Shot 2022-04-29 at 1 46 53 PM
Preferred:
Screen Shot 2022-04-29 at 11 06 36 PM

So far I see two options:

Option 1: I could edit HistoricalEventKnowledgeDiscovered.Html(c *Context) in events.go to compare x.Knowledge against a bunch of raw strings and use the corresponding English phrase, ex:

func (x *HistoricalEventKnowledgeDiscovered) Html(c *Context) string {
	knowledge := x.Knowledge
	switch x.Knowledge {
	case "astronomy:daylight variation with solar year":
		knowledge = "the variation of daylight with the season"
	case "astronomy:geocentric model":
		knowledge = "the theory that the sun moves around the world"
	//...
	}
	return c.hf(x.Hfid) + util.If(x.First, " was the very first to discover ", " independently discovered ") + knowledge
}

Option 2: Edit the ForceEnums in overwrites.json to include the discovered knowledge type, regenerate models.go to create a list of Knowledge types, and compare these in evens.go (rather than comparing with raw strings).

    "ForceEnum": {
        "df_world|historical_events|historical_event+HfDied|cause": true,
        "df_world|historical_events|historical_event+HfDied|death_cause": true,
        "df_world|historical_events|historical_event+KnowledgeDiscovered|knowledge": true
    },
type HistoricalEventKnowledgeDiscoveredKnowledge int

const (
	HistoricalEventKnowledgeDiscoveredKnowledge_Unknown HistoricalEventKnowledgeDiscoveredKnowledge = iota
	HistoricalEventKnowledgeDiscoveredKnowledge_AstronomydaylightVariationWithSolarYear
	HistoricalEventKnowledgeDiscoveredKnowledge_AstronomygeocentricModel
	//...
)

Option 2 seems closer to the pattern used elsewhere in LegendsBrowser2, but without the original legends.xml files, I'm having trouble doing this myself without breaking model.go and analyze.json. (Or perhaps I'm misunderstanding something about how to generate these)

TLDR; Would you mind updating overrides.json and generating these HistoricalEventKnowledgeDiscoveredKnowledge enums yourself? Or is there a way I can do it?

I've changed it to an enum and added an option to regenerate the analyzed data without a need for all xml files:
go run analyze.go -l=true -a ../inputs
-l will load the existing analyze.json and only add new findings from your xml files in ../inputs
You can then use go run analyze.go -g=true to regenerate the model code

Perfect, thanks! I'll put up a PR when I've gotten phrases for all of these written out. There are more than I realized...