generate data if no plus xml
This commit is contained in:
parent
b561de2d0f
commit
be3e612a86
|
@ -0,0 +1,114 @@
|
||||||
|
package model
|
||||||
|
|
||||||
|
var dwarfPositions = []*EntityPosition{
|
||||||
|
{
|
||||||
|
Name_: "king",
|
||||||
|
NameMale: "king",
|
||||||
|
NameFemale: "queen",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "general",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "lieutenant",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "captain",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "militia commander",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "militia captain",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "sheriff",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "captain of the guard",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "expedition leader",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "mayor",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "manager",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "chief medical dwarf",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "broker",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "bookkeeper",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "outpost liaison",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "diplomat",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "duke",
|
||||||
|
NameMale: "duke",
|
||||||
|
NameFemale: "duchess",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "count",
|
||||||
|
NameMale: "count",
|
||||||
|
NameFemale: "countess",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "baron",
|
||||||
|
NameMale: "baron",
|
||||||
|
NameFemale: "baroness",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "champion",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "hammerer",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "dungeon master",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "administrator",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var elfPositions = []*EntityPosition{
|
||||||
|
{
|
||||||
|
Name_: "druid",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "acolyte",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "princess",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "queen",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "diplomat",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name_: "ranger captain",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var humanPositions = []*EntityPosition{
|
||||||
|
{
|
||||||
|
Name_: "law-giver",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var goblinPositions = []*EntityPosition{
|
||||||
|
{
|
||||||
|
Name_: "master",
|
||||||
|
},
|
||||||
|
}
|
|
@ -51,8 +51,24 @@ func (w *DfWorld) process() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !w.Plus {
|
if !w.Plus {
|
||||||
|
trimRace := func(s string) string { return strings.Trim(strcase.ToDelimited(s, ' '), " 0123456789") }
|
||||||
for _, hf := range w.HistoricalFigures {
|
for _, hf := range w.HistoricalFigures {
|
||||||
hf.Race = strings.Trim(strcase.ToDelimited(hf.Race, ' '), " 0123456789")
|
hf.Race = trimRace(hf.Race)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, e := range w.Entities {
|
||||||
|
if len(e.Leaders) > 0 {
|
||||||
|
switch r := e.Leaders[0].Hf.Race; {
|
||||||
|
case r == "demon":
|
||||||
|
e.Race = "goblin"
|
||||||
|
default:
|
||||||
|
e.Race = r
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if !strings.Contains(e.Name_, " ") {
|
||||||
|
e.Race = "kobold"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, a := range w.DanceForms {
|
for _, a := range w.DanceForms {
|
||||||
|
@ -64,6 +80,117 @@ func (w *DfWorld) process() {
|
||||||
for _, a := range w.PoeticForms {
|
for _, a := range w.PoeticForms {
|
||||||
a.Name_ = a.Description[:strings.Index(a.Description, " is a ")]
|
a.Name_ = a.Description[:strings.Index(a.Description, " is a ")]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setEntityType := func(id int, t EntityType) {
|
||||||
|
if c, ok := w.Entities[id]; ok {
|
||||||
|
if c.Type_ == EntityType_Unknown {
|
||||||
|
c.Type_ = t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setParent := func(id, parent int) {
|
||||||
|
if id == -1 || parent == -1 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if c, ok := w.Entities[parent]; ok {
|
||||||
|
if c.Parent != -1 {
|
||||||
|
parent = c.Parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if c, ok := w.Entities[id]; ok {
|
||||||
|
c.Parent = parent
|
||||||
|
if p, ok := w.Entities[parent]; ok {
|
||||||
|
c.Race = p.Race
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if c, ok := w.Entities[parent]; ok {
|
||||||
|
c.Child = append(c.Child, id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list := maps.Values(w.HistoricalEvents)
|
||||||
|
sort.Slice(list, func(i, j int) bool { return list[i].Id_ < list[j].Id_ })
|
||||||
|
for _, e := range list {
|
||||||
|
switch d := e.Details.(type) {
|
||||||
|
case *HistoricalEventCreatedSite:
|
||||||
|
setParent(d.SiteCivId, d.CivId)
|
||||||
|
setEntityType(d.CivId, EntityType_Civilization)
|
||||||
|
setEntityType(d.SiteCivId, EntityType_Sitegovernment)
|
||||||
|
case *HistoricalEventDestroyedSite:
|
||||||
|
setParent(d.SiteCivId, d.DefenderCivId)
|
||||||
|
setEntityType(d.AttackerCivId, EntityType_Civilization)
|
||||||
|
setEntityType(d.DefenderCivId, EntityType_Civilization)
|
||||||
|
setEntityType(d.SiteCivId, EntityType_Sitegovernment)
|
||||||
|
case *HistoricalEventSiteTakenOver:
|
||||||
|
setParent(d.SiteCivId, d.DefenderCivId)
|
||||||
|
setParent(d.NewSiteCivId, d.AttackerCivId)
|
||||||
|
setEntityType(d.DefenderCivId, EntityType_Civilization)
|
||||||
|
setEntityType(d.SiteCivId, EntityType_Sitegovernment)
|
||||||
|
setEntityType(d.AttackerCivId, EntityType_Civilization)
|
||||||
|
setEntityType(d.NewSiteCivId, EntityType_Sitegovernment)
|
||||||
|
case *HistoricalEventHfDestroyedSite:
|
||||||
|
setParent(d.SiteCivId, d.DefenderCivId)
|
||||||
|
setEntityType(d.DefenderCivId, EntityType_Civilization)
|
||||||
|
setEntityType(d.SiteCivId, EntityType_Sitegovernment)
|
||||||
|
case *HistoricalEventReclaimSite:
|
||||||
|
setParent(d.SiteCivId, d.CivId)
|
||||||
|
setEntityType(d.CivId, EntityType_Civilization)
|
||||||
|
setEntityType(d.SiteCivId, EntityType_Sitegovernment)
|
||||||
|
case *HistoricalEventCreatedStructure:
|
||||||
|
setParent(d.SiteCivId, d.CivId)
|
||||||
|
setEntityType(d.CivId, EntityType_Civilization)
|
||||||
|
setEntityType(d.SiteCivId, EntityType_Sitegovernment)
|
||||||
|
if site, ok := w.Sites[d.SiteId]; ok {
|
||||||
|
if structure, ok := site.Structures[d.StructureId]; ok {
|
||||||
|
if structure.Type_ == StructureType_Guildhall {
|
||||||
|
setEntityType(d.SiteCivId, EntityType_Guild)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case *HistoricalEventChangedCreatureType:
|
||||||
|
d.NewRace = trimRace(d.NewRace)
|
||||||
|
d.OldRace = trimRace(d.OldRace)
|
||||||
|
case *HistoricalEventCreatureDevoured:
|
||||||
|
if col, ok := w.HistoricalEventCollections[e.Collection]; ok {
|
||||||
|
if cd, ok := col.Details.(*HistoricalEventCollectionBeastAttack); ok {
|
||||||
|
if len(cd.AttackerHfIds) > 0 {
|
||||||
|
d.Eater = cd.AttackerHfIds[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
d.Race = "creature"
|
||||||
|
case *HistoricalEventHfNewPet:
|
||||||
|
d.Pets = "creature" // TODO from hf pets?
|
||||||
|
case *HistoricalEventItemStolen:
|
||||||
|
if col, ok := w.HistoricalEventCollections[e.Collection]; ok {
|
||||||
|
if cd, ok := col.Details.(*HistoricalEventCollectionBeastAttack); ok {
|
||||||
|
if len(cd.AttackerHfIds) > 0 {
|
||||||
|
d.Histfig = cd.AttackerHfIds[0]
|
||||||
|
}
|
||||||
|
d.Site = cd.SiteId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
d.ItemType = "item"
|
||||||
|
case *HistoricalEventMasterpieceItem:
|
||||||
|
d.ItemType = "item"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, e := range w.Entities {
|
||||||
|
switch e.Race {
|
||||||
|
case "dwarf":
|
||||||
|
e.EntityPosition = dwarfPositions
|
||||||
|
case "elf":
|
||||||
|
e.EntityPosition = elfPositions
|
||||||
|
case "human":
|
||||||
|
e.EntityPosition = humanPositions
|
||||||
|
case "goblin":
|
||||||
|
e.EntityPosition = goblinPositions
|
||||||
|
}
|
||||||
|
for i, p := range e.EntityPosition {
|
||||||
|
p.Id_ = i
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check events texts
|
// check events texts
|
||||||
|
@ -83,18 +210,22 @@ func (w *DfWorld) processEvents() {
|
||||||
for _, e := range list {
|
for _, e := range list {
|
||||||
switch d := e.Details.(type) {
|
switch d := e.Details.(type) {
|
||||||
case *HistoricalEventHfDoesInteraction:
|
case *HistoricalEventHfDoesInteraction:
|
||||||
|
if hf, ok := w.HistoricalFigures[d.TargetHfid]; ok {
|
||||||
if strings.HasPrefix(d.Interaction, "DEITY_CURSE_WEREBEAST_") {
|
if strings.HasPrefix(d.Interaction, "DEITY_CURSE_WEREBEAST_") {
|
||||||
w.HistoricalFigures[d.TargetHfid].Werebeast = true
|
hf.Werebeast = true
|
||||||
w.HistoricalFigures[d.TargetHfid].WerebeastSince = e.Year
|
hf.WerebeastSince = e.Year
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(d.Interaction, "DEITY_CURSE_VAMPIRE_") {
|
if strings.HasPrefix(d.Interaction, "DEITY_CURSE_VAMPIRE_") {
|
||||||
w.HistoricalFigures[d.TargetHfid].Vampire = true
|
hf.Vampire = true
|
||||||
w.HistoricalFigures[d.TargetHfid].VampireSince = e.Year
|
hf.VampireSince = e.Year
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case *HistoricalEventHfLearnsSecret:
|
case *HistoricalEventHfLearnsSecret:
|
||||||
if strings.HasPrefix(d.Interaction, "SECRET_") {
|
if strings.HasPrefix(d.Interaction, "SECRET_") {
|
||||||
w.HistoricalFigures[d.StudentHfid].Necromancer = true
|
if hf, ok := w.HistoricalFigures[d.StudentHfid]; ok {
|
||||||
w.HistoricalFigures[d.StudentHfid].NecromancerSince = e.Year
|
hf.Necromancer = true
|
||||||
|
hf.NecromancerSince = e.Year
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case *HistoricalEventCreatedSite:
|
case *HistoricalEventCreatedSite:
|
||||||
w.addEntitySite(d.CivId, d.SiteId)
|
w.addEntitySite(d.CivId, d.SiteId)
|
||||||
|
|
|
@ -170,7 +170,9 @@ func StartServer(config *Config, world *model.DfWorld, static embed.FS) error {
|
||||||
Civilizations map[string][]*model.Entity
|
Civilizations map[string][]*model.Entity
|
||||||
}{
|
}{
|
||||||
Civilizations: groupBy(srv.context.world.Entities,
|
Civilizations: groupBy(srv.context.world.Entities,
|
||||||
func(e *model.Entity) string { return util.If(e.Necromancer, "necromancer", e.Race) },
|
func(e *model.Entity) string {
|
||||||
|
return util.If(e.Necromancer, "necromancer", util.If(e.Race == "", "unknown", e.Race))
|
||||||
|
},
|
||||||
func(e *model.Entity) bool {
|
func(e *model.Entity) bool {
|
||||||
return e.Name() != "" && (e.Type_ == model.EntityType_Civilization || e.Necromancer)
|
return e.Name() != "" && (e.Type_ == model.EntityType_Civilization || e.Necromancer)
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue