fixes if no plus xml
This commit is contained in:
parent
3b15a952ac
commit
b561de2d0f
|
@ -41,6 +41,10 @@
|
|||
{
|
||||
"Name": "EndYear",
|
||||
"Type": "int"
|
||||
},
|
||||
{
|
||||
"Name": "Plus",
|
||||
"Type": "bool"
|
||||
}
|
||||
],
|
||||
"Structure": [
|
||||
|
|
|
@ -81,15 +81,17 @@ func (x *HistoricalEventCollectionCeremony) Html(e *HistoricalEventCollection, c
|
|||
if event, ok := c.World.HistoricalEvents[e.Event[0]]; ok {
|
||||
if d, ok := event.Details.(*HistoricalEventCeremony); ok {
|
||||
if entity, ok := c.World.Entities[d.CivId]; ok {
|
||||
occ := entity.Occasion[d.OccasionId]
|
||||
if len(occ.Schedule) > 1 {
|
||||
switch d.ScheduleId {
|
||||
case 0:
|
||||
r = "opening ceremony"
|
||||
case len(occ.Schedule) - 1:
|
||||
r = "closing ceremony"
|
||||
default:
|
||||
r = "main ceremony"
|
||||
if d.OccasionId < len(entity.Occasion) {
|
||||
occ := entity.Occasion[d.OccasionId]
|
||||
if len(occ.Schedule) > 1 {
|
||||
switch d.ScheduleId {
|
||||
case 0:
|
||||
r = "opening ceremony"
|
||||
case len(occ.Schedule) - 1:
|
||||
r = "closing ceremony"
|
||||
default:
|
||||
r = "main ceremony"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,8 +107,12 @@ func (x *HistoricalEventCollectionCompetition) Html(e *HistoricalEventCollection
|
|||
if event, ok := c.World.HistoricalEvents[e.Event[0]]; ok {
|
||||
if d, ok := event.Details.(*HistoricalEventCompetition); ok {
|
||||
if entity, ok := c.World.Entities[d.CivId]; ok {
|
||||
occ := entity.Occasion[d.OccasionId]
|
||||
r = occ.Schedule[d.ScheduleId].Type_.String()
|
||||
if d.OccasionId < len(entity.Occasion) {
|
||||
occ := entity.Occasion[d.OccasionId]
|
||||
if d.ScheduleId < len(occ.Schedule) {
|
||||
r = occ.Schedule[d.ScheduleId].Type_.String()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,8 +143,10 @@ func (x *HistoricalEventCollectionJourney) Html(e *HistoricalEventCollection, c
|
|||
|
||||
func (x *HistoricalEventCollectionOccasion) Html(e *HistoricalEventCollection, c *Context) string {
|
||||
if civ, ok := c.World.Entities[x.CivId]; ok {
|
||||
occ := civ.Occasion[x.OccasionId]
|
||||
return util.If(x.Ordinal > 1, "the "+ord(x.Ordinal)+"occasion of ", "") + e.Link(occ.Name_)
|
||||
if x.OccasionId < len(civ.Occasion) {
|
||||
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("UNKNOWN OCCASION")
|
||||
}
|
||||
|
@ -149,8 +157,12 @@ func (x *HistoricalEventCollectionPerformance) Html(e *HistoricalEventCollection
|
|||
if event, ok := c.World.HistoricalEvents[e.Event[0]]; ok {
|
||||
if d, ok := event.Details.(*HistoricalEventPerformance); ok {
|
||||
if entity, ok := c.World.Entities[d.CivId]; ok {
|
||||
occ := entity.Occasion[d.OccasionId]
|
||||
r = occ.Schedule[d.ScheduleId].Type_.String()
|
||||
if d.OccasionId < len(entity.Occasion) {
|
||||
occ := entity.Occasion[d.OccasionId]
|
||||
if d.ScheduleId < len(occ.Schedule) {
|
||||
r = occ.Schedule[d.ScheduleId].Type_.String()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -425,11 +425,13 @@ func (x *HistoricalEventBuildingProfileAcquired) Html(c *Context) string {
|
|||
func (x *HistoricalEventCeremony) Html(c *Context) string {
|
||||
r := c.entity(x.CivId) + " held a ceremony in " + c.site(x.SiteId, "")
|
||||
if e, ok := c.World.Entities[x.CivId]; ok {
|
||||
o := e.Occasion[x.OccasionId]
|
||||
r += " as part of " + o.Name()
|
||||
s := o.Schedule[x.ScheduleId]
|
||||
if len(s.Feature) > 0 {
|
||||
r += ". The event featured " + andList(util.Map(s.Feature, c.feature))
|
||||
if x.OccasionId < len(e.Occasion) {
|
||||
o := e.Occasion[x.OccasionId]
|
||||
r += " as part of " + o.Name()
|
||||
s := o.Schedule[x.ScheduleId]
|
||||
if len(s.Feature) > 0 {
|
||||
r += ". The event featured " + andList(util.Map(s.Feature, c.feature))
|
||||
}
|
||||
}
|
||||
}
|
||||
return r
|
||||
|
@ -449,16 +451,12 @@ func (x *HistoricalEventChangeHfBodyState) Html(c *Context) string {
|
|||
}
|
||||
|
||||
func (x *HistoricalEventChangeHfJob) Html(c *Context) string {
|
||||
w := ""
|
||||
if x.SubregionId != -1 {
|
||||
w = " in " + c.region(x.SubregionId)
|
||||
}
|
||||
if x.SiteId != -1 {
|
||||
w = " in " + c.site(x.SiteId, "")
|
||||
}
|
||||
w := c.location(x.SiteId, " in", x.SubregionId, " in")
|
||||
old := articled(strcase.ToDelimited(x.OldJob, ' '))
|
||||
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
|
||||
} else if x.NewJob == "standard" {
|
||||
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")
|
||||
case HistoricalEventChangeHfStateReason_ConvictionExile, HistoricalEventChangeHfStateReason_ExiledAfterConviction:
|
||||
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")
|
||||
}
|
||||
case HistoricalEventChangeHfStateState_Visiting:
|
||||
|
@ -543,10 +541,19 @@ func (x *HistoricalEventChangedCreatureType) Html(c *Context) string {
|
|||
}
|
||||
|
||||
func (x *HistoricalEventCompetition) Html(c *Context) string {
|
||||
e := c.World.Entities[x.CivId]
|
||||
o := e.Occasion[x.OccasionId]
|
||||
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() +
|
||||
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]
|
||||
oName = o.Name_
|
||||
if x.ScheduleId < len(o.Schedule) {
|
||||
s := o.Schedule[x.ScheduleId]
|
||||
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) + ". " +
|
||||
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 {
|
||||
r := c.entity(x.CivId) + " held "
|
||||
oName := "UNKNOWN OCCASION"
|
||||
sType := "a performance"
|
||||
if e, ok := c.World.Entities[x.CivId]; ok {
|
||||
o := e.Occasion[x.OccasionId]
|
||||
s := o.Schedule[x.ScheduleId]
|
||||
r += c.schedule(s)
|
||||
r += " as part of " + o.Name()
|
||||
r += c.site(x.SiteId, " in")
|
||||
r += string(util.Json(s))
|
||||
if x.OccasionId < len(e.Occasion) {
|
||||
o := e.Occasion[x.OccasionId]
|
||||
oName = o.Name_
|
||||
if x.ScheduleId < len(o.Schedule) {
|
||||
s := o.Schedule[x.ScheduleId]
|
||||
sType = c.schedule(s)
|
||||
}
|
||||
}
|
||||
}
|
||||
r += sType
|
||||
r += " as part of " + oName
|
||||
r += c.site(x.SiteId, " in")
|
||||
return r
|
||||
}
|
||||
|
||||
|
@ -2005,21 +2019,23 @@ func (x *HistoricalEventPoeticFormCreated) Html(c *Context) string {
|
|||
func (x *HistoricalEventProcession) Html(c *Context) string {
|
||||
r := c.entity(x.CivId) + " held a procession in " + c.site(x.SiteId, "")
|
||||
if e, ok := c.World.Entities[x.CivId]; ok {
|
||||
o := e.Occasion[x.OccasionId]
|
||||
r += " as part of " + o.Name()
|
||||
s := o.Schedule[x.ScheduleId]
|
||||
if s.Reference != -1 {
|
||||
r += ". It started at " + c.structure(x.SiteId, s.Reference)
|
||||
if s.Reference2 != -1 && s.Reference2 != s.Reference {
|
||||
r += " and ended at " + c.structure(x.SiteId, s.Reference2)
|
||||
} else {
|
||||
r += " and returned there after following its route"
|
||||
if x.OccasionId < len(e.Occasion) {
|
||||
o := e.Occasion[x.OccasionId]
|
||||
r += " as part of " + o.Name()
|
||||
s := o.Schedule[x.ScheduleId]
|
||||
if s.Reference != -1 {
|
||||
r += ". It started at " + c.structure(x.SiteId, s.Reference)
|
||||
if s.Reference2 != -1 && s.Reference2 != s.Reference {
|
||||
r += " and ended at " + c.structure(x.SiteId, s.Reference2)
|
||||
} else {
|
||||
r += " and returned there after following its route"
|
||||
}
|
||||
}
|
||||
if len(s.Feature) > 0 {
|
||||
r += ". The event featured " + andList(util.Map(s.Feature, c.feature))
|
||||
}
|
||||
r += string(util.Json(s))
|
||||
}
|
||||
if len(s.Feature) > 0 {
|
||||
r += ". The event featured " + andList(util.Map(s.Feature, c.feature))
|
||||
}
|
||||
r += string(util.Json(s))
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
|
|
@ -49,14 +49,16 @@ var AddMapLandmass = func(w *DfWorld, id int) template.HTML {
|
|||
var AddMapRegion = func(w *DfWorld, id int) template.HTML {
|
||||
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) }), ",")
|
||||
fillColor := "transparent"
|
||||
switch x.Evilness {
|
||||
case RegionEvilness_Evil:
|
||||
fillColor = "fuchsia"
|
||||
case RegionEvilness_Good:
|
||||
fillColor = "aqua"
|
||||
if len(coords) > 0 {
|
||||
fillColor := "transparent"
|
||||
switch x.Evilness {
|
||||
case RegionEvilness_Evil:
|
||||
fillColor = "fuchsia"
|
||||
case RegionEvilness_Good:
|
||||
fillColor = "aqua"
|
||||
}
|
||||
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 ""
|
||||
}
|
||||
|
|
|
@ -121,6 +121,10 @@ func maxCoords(coords []Coord) Coord {
|
|||
|
||||
func (r *Region) Outline() []Coord {
|
||||
var outline []Coord
|
||||
|
||||
if r.Coords == "" {
|
||||
return outline
|
||||
}
|
||||
// if (cacheOutline != null)
|
||||
// return cacheOutline;
|
||||
|
||||
|
|
|
@ -1548,6 +1548,7 @@ type DfWorld struct {
|
|||
Height int `json:"height" legend:"add" related:""` // Height
|
||||
MapData []byte `json:"mapData" legend:"add" related:""` // MapData
|
||||
MapReady bool `json:"mapReady" legend:"add" related:""` // MapReady
|
||||
Plus bool `json:"plus" legend:"add" related:""` // Plus
|
||||
PlusFilePath string `json:"plusFilePath" legend:"add" related:""` // PlusFilePath
|
||||
Width int `json:"width" legend:"add" related:""` // Width
|
||||
}
|
||||
|
@ -1616,6 +1617,7 @@ func (x *DfWorld) MarshalJSON() ([]byte, error) {
|
|||
}
|
||||
d["mapData"] = x.MapData
|
||||
d["mapReady"] = x.MapReady
|
||||
d["plus"] = x.Plus
|
||||
d["plusFilePath"] = x.PlusFilePath
|
||||
if x.Width != -1 {
|
||||
d["width"] = x.Width
|
||||
|
|
|
@ -99,7 +99,7 @@ BaseLoop:
|
|||
|
||||
bar.Finish()
|
||||
|
||||
plus := true
|
||||
plus := false
|
||||
|
||||
if plus {
|
||||
file = strings.Replace(file, "-legends.xml", "-legends_plus.xml", 1)
|
||||
|
@ -131,6 +131,7 @@ BaseLoop:
|
|||
}
|
||||
}
|
||||
}
|
||||
world.Plus = true
|
||||
world.PlusFilePath = file
|
||||
|
||||
bar.Finish()
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/iancoleman/strcase"
|
||||
"github.com/robertjanetzko/LegendsBrowser2/backend/util"
|
||||
"golang.org/x/exp/maps"
|
||||
"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_ })
|
||||
}
|
||||
|
||||
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
|
||||
// for _, e := range w.HistoricalEvents {
|
||||
// e.Details.Html(&Context{World: w})
|
||||
// }
|
||||
for _, e := range w.HistoricalEvents {
|
||||
e.Details.Html(&Context{World: w})
|
||||
}
|
||||
for _, e := range w.HistoricalEventCollections {
|
||||
e.Details.Html(e, &Context{World: w})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue