fixes if no plus xml
This commit is contained in:
parent
3b15a952ac
commit
b561de2d0f
|
@ -41,6 +41,10 @@
|
||||||
{
|
{
|
||||||
"Name": "EndYear",
|
"Name": "EndYear",
|
||||||
"Type": "int"
|
"Type": "int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Plus",
|
||||||
|
"Type": "bool"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Structure": [
|
"Structure": [
|
||||||
|
|
|
@ -81,6 +81,7 @@ func (x *HistoricalEventCollectionCeremony) Html(e *HistoricalEventCollection, c
|
||||||
if event, ok := c.World.HistoricalEvents[e.Event[0]]; ok {
|
if event, ok := c.World.HistoricalEvents[e.Event[0]]; ok {
|
||||||
if d, ok := event.Details.(*HistoricalEventCeremony); ok {
|
if d, ok := event.Details.(*HistoricalEventCeremony); ok {
|
||||||
if entity, ok := c.World.Entities[d.CivId]; ok {
|
if entity, ok := c.World.Entities[d.CivId]; ok {
|
||||||
|
if d.OccasionId < len(entity.Occasion) {
|
||||||
occ := entity.Occasion[d.OccasionId]
|
occ := entity.Occasion[d.OccasionId]
|
||||||
if len(occ.Schedule) > 1 {
|
if len(occ.Schedule) > 1 {
|
||||||
switch d.ScheduleId {
|
switch d.ScheduleId {
|
||||||
|
@ -96,6 +97,7 @@ func (x *HistoricalEventCollectionCeremony) Html(e *HistoricalEventCollection, c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return "the " + e.Link(ord(x.Ordinal)+r) + " of " + c.collection(x.OccasionEventcol)
|
return "the " + e.Link(ord(x.Ordinal)+r) + " of " + c.collection(x.OccasionEventcol)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,12 +107,16 @@ func (x *HistoricalEventCollectionCompetition) Html(e *HistoricalEventCollection
|
||||||
if event, ok := c.World.HistoricalEvents[e.Event[0]]; ok {
|
if event, ok := c.World.HistoricalEvents[e.Event[0]]; ok {
|
||||||
if d, ok := event.Details.(*HistoricalEventCompetition); ok {
|
if d, ok := event.Details.(*HistoricalEventCompetition); ok {
|
||||||
if entity, ok := c.World.Entities[d.CivId]; ok {
|
if entity, ok := c.World.Entities[d.CivId]; ok {
|
||||||
|
if d.OccasionId < len(entity.Occasion) {
|
||||||
occ := entity.Occasion[d.OccasionId]
|
occ := entity.Occasion[d.OccasionId]
|
||||||
|
if d.ScheduleId < len(occ.Schedule) {
|
||||||
r = occ.Schedule[d.ScheduleId].Type_.String()
|
r = occ.Schedule[d.ScheduleId].Type_.String()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return "the " + e.Link(ord(x.Ordinal)+r) + " of " + c.collection(x.OccasionEventcol)
|
return "the " + e.Link(ord(x.Ordinal)+r) + " of " + c.collection(x.OccasionEventcol)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,9 +143,11 @@ func (x *HistoricalEventCollectionJourney) Html(e *HistoricalEventCollection, c
|
||||||
|
|
||||||
func (x *HistoricalEventCollectionOccasion) Html(e *HistoricalEventCollection, c *Context) string {
|
func (x *HistoricalEventCollectionOccasion) Html(e *HistoricalEventCollection, c *Context) string {
|
||||||
if civ, ok := c.World.Entities[x.CivId]; ok {
|
if civ, ok := c.World.Entities[x.CivId]; ok {
|
||||||
|
if x.OccasionId < len(civ.Occasion) {
|
||||||
occ := civ.Occasion[x.OccasionId]
|
occ := civ.Occasion[x.OccasionId]
|
||||||
return util.If(x.Ordinal > 1, "the "+ord(x.Ordinal)+"occasion of ", "") + e.Link(occ.Name_)
|
return util.If(x.Ordinal > 1, "the "+ord(x.Ordinal)+"occasion of ", "") + e.Link(occ.Name_)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return util.If(x.Ordinal > 1, "the "+ord(x.Ordinal)+"occasion of ", "") + e.Link("UNKNOWN OCCASION")
|
return util.If(x.Ordinal > 1, "the "+ord(x.Ordinal)+"occasion of ", "") + e.Link("UNKNOWN OCCASION")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,12 +157,16 @@ func (x *HistoricalEventCollectionPerformance) Html(e *HistoricalEventCollection
|
||||||
if event, ok := c.World.HistoricalEvents[e.Event[0]]; ok {
|
if event, ok := c.World.HistoricalEvents[e.Event[0]]; ok {
|
||||||
if d, ok := event.Details.(*HistoricalEventPerformance); ok {
|
if d, ok := event.Details.(*HistoricalEventPerformance); ok {
|
||||||
if entity, ok := c.World.Entities[d.CivId]; ok {
|
if entity, ok := c.World.Entities[d.CivId]; ok {
|
||||||
|
if d.OccasionId < len(entity.Occasion) {
|
||||||
occ := entity.Occasion[d.OccasionId]
|
occ := entity.Occasion[d.OccasionId]
|
||||||
|
if d.ScheduleId < len(occ.Schedule) {
|
||||||
r = occ.Schedule[d.ScheduleId].Type_.String()
|
r = occ.Schedule[d.ScheduleId].Type_.String()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return "the " + e.Link(ord(x.Ordinal)+r) + " of " + c.collection(x.OccasionEventcol)
|
return "the " + e.Link(ord(x.Ordinal)+r) + " of " + c.collection(x.OccasionEventcol)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -425,6 +425,7 @@ func (x *HistoricalEventBuildingProfileAcquired) Html(c *Context) string {
|
||||||
func (x *HistoricalEventCeremony) Html(c *Context) string {
|
func (x *HistoricalEventCeremony) Html(c *Context) string {
|
||||||
r := c.entity(x.CivId) + " held a ceremony in " + c.site(x.SiteId, "")
|
r := c.entity(x.CivId) + " held a ceremony in " + c.site(x.SiteId, "")
|
||||||
if e, ok := c.World.Entities[x.CivId]; ok {
|
if e, ok := c.World.Entities[x.CivId]; ok {
|
||||||
|
if x.OccasionId < len(e.Occasion) {
|
||||||
o := e.Occasion[x.OccasionId]
|
o := e.Occasion[x.OccasionId]
|
||||||
r += " as part of " + o.Name()
|
r += " as part of " + o.Name()
|
||||||
s := o.Schedule[x.ScheduleId]
|
s := o.Schedule[x.ScheduleId]
|
||||||
|
@ -432,6 +433,7 @@ func (x *HistoricalEventCeremony) Html(c *Context) string {
|
||||||
r += ". The event featured " + andList(util.Map(s.Feature, c.feature))
|
r += ". The event featured " + andList(util.Map(s.Feature, c.feature))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,16 +451,12 @@ func (x *HistoricalEventChangeHfBodyState) Html(c *Context) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *HistoricalEventChangeHfJob) Html(c *Context) string {
|
func (x *HistoricalEventChangeHfJob) Html(c *Context) string {
|
||||||
w := ""
|
w := c.location(x.SiteId, " in", x.SubregionId, " in")
|
||||||
if x.SubregionId != -1 {
|
|
||||||
w = " in " + c.region(x.SubregionId)
|
|
||||||
}
|
|
||||||
if x.SiteId != -1 {
|
|
||||||
w = " in " + c.site(x.SiteId, "")
|
|
||||||
}
|
|
||||||
old := articled(strcase.ToDelimited(x.OldJob, ' '))
|
old := articled(strcase.ToDelimited(x.OldJob, ' '))
|
||||||
new := articled(strcase.ToDelimited(x.NewJob, ' '))
|
new := articled(strcase.ToDelimited(x.NewJob, ' '))
|
||||||
if x.OldJob == "standard" {
|
if x.OldJob == "" && x.NewJob == "" {
|
||||||
|
return c.hf(x.Hfid) + " became a UNKNOWN JOB" + w
|
||||||
|
} else if x.OldJob == "standard" {
|
||||||
return c.hf(x.Hfid) + " became " + new + w
|
return c.hf(x.Hfid) + " became " + new + w
|
||||||
} else if x.NewJob == "standard" {
|
} else if x.NewJob == "standard" {
|
||||||
return c.hf(x.Hfid) + " stopped being " + old + w
|
return c.hf(x.Hfid) + " stopped being " + old + w
|
||||||
|
@ -502,7 +500,7 @@ func (x *HistoricalEventChangeHfState) Html(c *Context) string {
|
||||||
return c.hf(x.Hfid) + " fled " + c.site(x.SiteId, "to")
|
return c.hf(x.Hfid) + " fled " + c.site(x.SiteId, "to")
|
||||||
case HistoricalEventChangeHfStateReason_ConvictionExile, HistoricalEventChangeHfStateReason_ExiledAfterConviction:
|
case HistoricalEventChangeHfStateReason_ConvictionExile, HistoricalEventChangeHfStateReason_ExiledAfterConviction:
|
||||||
return c.hf(x.Hfid) + " departed " + c.site(x.SiteId, "to") + r
|
return c.hf(x.Hfid) + " departed " + c.site(x.SiteId, "to") + r
|
||||||
case HistoricalEventChangeHfStateReason_None:
|
default:
|
||||||
return c.hf(x.Hfid) + " settled " + c.location(x.SiteId, "in", x.SubregionId, "in")
|
return c.hf(x.Hfid) + " settled " + c.location(x.SiteId, "in", x.SubregionId, "in")
|
||||||
}
|
}
|
||||||
case HistoricalEventChangeHfStateState_Visiting:
|
case HistoricalEventChangeHfStateState_Visiting:
|
||||||
|
@ -543,10 +541,19 @@ func (x *HistoricalEventChangedCreatureType) Html(c *Context) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *HistoricalEventCompetition) Html(c *Context) string {
|
func (x *HistoricalEventCompetition) Html(c *Context) string {
|
||||||
e := c.World.Entities[x.CivId]
|
oName := "UNKNOWN OCCASION"
|
||||||
|
sType := "competition"
|
||||||
|
if e, ok := c.World.Entities[x.CivId]; ok {
|
||||||
|
if x.OccasionId < len(e.Occasion) {
|
||||||
o := e.Occasion[x.OccasionId]
|
o := e.Occasion[x.OccasionId]
|
||||||
|
oName = o.Name_
|
||||||
|
if x.ScheduleId < len(o.Schedule) {
|
||||||
s := o.Schedule[x.ScheduleId]
|
s := o.Schedule[x.ScheduleId]
|
||||||
return c.entity(x.CivId) + " held a " + strcase.ToDelimited(s.Type_.String(), ' ') + c.site(x.SiteId, " in") + " as part of the " + o.Name() +
|
sType = strcase.ToDelimited(s.Type_.String(), ' ')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return c.entity(x.CivId) + " held a " + sType + c.site(x.SiteId, " in") + " as part of the " + oName +
|
||||||
". Competing " + util.If(len(x.CompetitorHfid) > 1, "were ", "was ") + c.hfList(x.CompetitorHfid) + ". " +
|
". Competing " + util.If(len(x.CompetitorHfid) > 1, "were ", "was ") + c.hfList(x.CompetitorHfid) + ". " +
|
||||||
util.Capitalize(c.hf(x.WinnerHfid)) + " was the victor"
|
util.Capitalize(c.hf(x.WinnerHfid)) + " was the victor"
|
||||||
}
|
}
|
||||||
|
@ -1976,14 +1983,21 @@ func (x *HistoricalEventPeaceRejected) Html(c *Context) string {
|
||||||
|
|
||||||
func (x *HistoricalEventPerformance) Html(c *Context) string {
|
func (x *HistoricalEventPerformance) Html(c *Context) string {
|
||||||
r := c.entity(x.CivId) + " held "
|
r := c.entity(x.CivId) + " held "
|
||||||
|
oName := "UNKNOWN OCCASION"
|
||||||
|
sType := "a performance"
|
||||||
if e, ok := c.World.Entities[x.CivId]; ok {
|
if e, ok := c.World.Entities[x.CivId]; ok {
|
||||||
|
if x.OccasionId < len(e.Occasion) {
|
||||||
o := e.Occasion[x.OccasionId]
|
o := e.Occasion[x.OccasionId]
|
||||||
|
oName = o.Name_
|
||||||
|
if x.ScheduleId < len(o.Schedule) {
|
||||||
s := o.Schedule[x.ScheduleId]
|
s := o.Schedule[x.ScheduleId]
|
||||||
r += c.schedule(s)
|
sType = c.schedule(s)
|
||||||
r += " as part of " + o.Name()
|
|
||||||
r += c.site(x.SiteId, " in")
|
|
||||||
r += string(util.Json(s))
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
r += sType
|
||||||
|
r += " as part of " + oName
|
||||||
|
r += c.site(x.SiteId, " in")
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2005,6 +2019,7 @@ func (x *HistoricalEventPoeticFormCreated) Html(c *Context) string {
|
||||||
func (x *HistoricalEventProcession) Html(c *Context) string {
|
func (x *HistoricalEventProcession) Html(c *Context) string {
|
||||||
r := c.entity(x.CivId) + " held a procession in " + c.site(x.SiteId, "")
|
r := c.entity(x.CivId) + " held a procession in " + c.site(x.SiteId, "")
|
||||||
if e, ok := c.World.Entities[x.CivId]; ok {
|
if e, ok := c.World.Entities[x.CivId]; ok {
|
||||||
|
if x.OccasionId < len(e.Occasion) {
|
||||||
o := e.Occasion[x.OccasionId]
|
o := e.Occasion[x.OccasionId]
|
||||||
r += " as part of " + o.Name()
|
r += " as part of " + o.Name()
|
||||||
s := o.Schedule[x.ScheduleId]
|
s := o.Schedule[x.ScheduleId]
|
||||||
|
@ -2021,6 +2036,7 @@ func (x *HistoricalEventProcession) Html(c *Context) string {
|
||||||
}
|
}
|
||||||
r += string(util.Json(s))
|
r += string(util.Json(s))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ var AddMapLandmass = func(w *DfWorld, id int) template.HTML {
|
||||||
var AddMapRegion = func(w *DfWorld, id int) template.HTML {
|
var AddMapRegion = func(w *DfWorld, id int) template.HTML {
|
||||||
if x, ok := w.Regions[id]; ok {
|
if x, ok := w.Regions[id]; ok {
|
||||||
coords := strings.Join(util.Map(x.Outline(), func(c Coord) string { return fmt.Sprintf(`coord(%d,%d)`, c.X, c.Y-1) }), ",")
|
coords := strings.Join(util.Map(x.Outline(), func(c Coord) string { return fmt.Sprintf(`coord(%d,%d)`, c.X, c.Y-1) }), ",")
|
||||||
|
if len(coords) > 0 {
|
||||||
fillColor := "transparent"
|
fillColor := "transparent"
|
||||||
switch x.Evilness {
|
switch x.Evilness {
|
||||||
case RegionEvilness_Evil:
|
case RegionEvilness_Evil:
|
||||||
|
@ -58,6 +59,7 @@ var AddMapRegion = func(w *DfWorld, id int) template.HTML {
|
||||||
}
|
}
|
||||||
return template.HTML(fmt.Sprintf(`<script>addRegion(%d, [%s], '%s')</script>`, x.Id_, coords, fillColor))
|
return template.HTML(fmt.Sprintf(`<script>addRegion(%d, [%s], '%s')</script>`, x.Id_, coords, fillColor))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,10 @@ func maxCoords(coords []Coord) Coord {
|
||||||
|
|
||||||
func (r *Region) Outline() []Coord {
|
func (r *Region) Outline() []Coord {
|
||||||
var outline []Coord
|
var outline []Coord
|
||||||
|
|
||||||
|
if r.Coords == "" {
|
||||||
|
return outline
|
||||||
|
}
|
||||||
// if (cacheOutline != null)
|
// if (cacheOutline != null)
|
||||||
// return cacheOutline;
|
// return cacheOutline;
|
||||||
|
|
||||||
|
|
|
@ -1548,6 +1548,7 @@ type DfWorld struct {
|
||||||
Height int `json:"height" legend:"add" related:""` // Height
|
Height int `json:"height" legend:"add" related:""` // Height
|
||||||
MapData []byte `json:"mapData" legend:"add" related:""` // MapData
|
MapData []byte `json:"mapData" legend:"add" related:""` // MapData
|
||||||
MapReady bool `json:"mapReady" legend:"add" related:""` // MapReady
|
MapReady bool `json:"mapReady" legend:"add" related:""` // MapReady
|
||||||
|
Plus bool `json:"plus" legend:"add" related:""` // Plus
|
||||||
PlusFilePath string `json:"plusFilePath" legend:"add" related:""` // PlusFilePath
|
PlusFilePath string `json:"plusFilePath" legend:"add" related:""` // PlusFilePath
|
||||||
Width int `json:"width" legend:"add" related:""` // Width
|
Width int `json:"width" legend:"add" related:""` // Width
|
||||||
}
|
}
|
||||||
|
@ -1616,6 +1617,7 @@ func (x *DfWorld) MarshalJSON() ([]byte, error) {
|
||||||
}
|
}
|
||||||
d["mapData"] = x.MapData
|
d["mapData"] = x.MapData
|
||||||
d["mapReady"] = x.MapReady
|
d["mapReady"] = x.MapReady
|
||||||
|
d["plus"] = x.Plus
|
||||||
d["plusFilePath"] = x.PlusFilePath
|
d["plusFilePath"] = x.PlusFilePath
|
||||||
if x.Width != -1 {
|
if x.Width != -1 {
|
||||||
d["width"] = x.Width
|
d["width"] = x.Width
|
||||||
|
|
|
@ -99,7 +99,7 @@ BaseLoop:
|
||||||
|
|
||||||
bar.Finish()
|
bar.Finish()
|
||||||
|
|
||||||
plus := true
|
plus := false
|
||||||
|
|
||||||
if plus {
|
if plus {
|
||||||
file = strings.Replace(file, "-legends.xml", "-legends_plus.xml", 1)
|
file = strings.Replace(file, "-legends.xml", "-legends_plus.xml", 1)
|
||||||
|
@ -131,6 +131,7 @@ BaseLoop:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
world.Plus = true
|
||||||
world.PlusFilePath = file
|
world.PlusFilePath = file
|
||||||
|
|
||||||
bar.Finish()
|
bar.Finish()
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/iancoleman/strcase"
|
||||||
"github.com/robertjanetzko/LegendsBrowser2/backend/util"
|
"github.com/robertjanetzko/LegendsBrowser2/backend/util"
|
||||||
"golang.org/x/exp/maps"
|
"golang.org/x/exp/maps"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
|
@ -49,10 +50,29 @@ func (w *DfWorld) process() {
|
||||||
sort.Slice(e.Wars, func(i, j int) bool { return e.Wars[i].Id_ < e.Wars[j].Id_ })
|
sort.Slice(e.Wars, func(i, j int) bool { return e.Wars[i].Id_ < e.Wars[j].Id_ })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !w.Plus {
|
||||||
|
for _, hf := range w.HistoricalFigures {
|
||||||
|
hf.Race = strings.Trim(strcase.ToDelimited(hf.Race, ' '), " 0123456789")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, a := range w.DanceForms {
|
||||||
|
a.Name_ = a.Description[:strings.Index(a.Description, " is a ")]
|
||||||
|
}
|
||||||
|
for _, a := range w.MusicalForms {
|
||||||
|
a.Name_ = a.Description[:strings.Index(a.Description, " is a ")]
|
||||||
|
}
|
||||||
|
for _, a := range w.PoeticForms {
|
||||||
|
a.Name_ = a.Description[:strings.Index(a.Description, " is a ")]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check events texts
|
// check events texts
|
||||||
// for _, e := range w.HistoricalEvents {
|
for _, e := range w.HistoricalEvents {
|
||||||
// e.Details.Html(&Context{World: w})
|
e.Details.Html(&Context{World: w})
|
||||||
// }
|
}
|
||||||
|
for _, e := range w.HistoricalEventCollections {
|
||||||
|
e.Details.Html(e, &Context{World: w})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue