This commit is contained in:
Robert Janetzko 2022-04-24 13:53:25 +00:00
parent 2748fc13a7
commit 1c0239b06e
4 changed files with 130 additions and 71 deletions

View File

@ -435,7 +435,7 @@ func (f Field) EndAction(obj Object) string {
return ""
}
var entityRegex, _ = regexp.Compile("(civ|civ_id|enid|[^d]*entity(_id)?|^entity(_id)?|^source|^destination)(_?[0-9])?$")
var entityRegex, _ = regexp.Compile("(civ|civ_id|enid|[^d]*entity(_id)?|^entity(_id)?|^source|^destination|^involved)(_?[0-9])?$")
var hfRegex, _ = regexp.Compile("(hfid|hf_id|hist_figure_id|histfig_id|histfig|bodies|_hf)")
var artifactRegex, _ = regexp.Compile("(item|artifact_id)$")
var siteRegex, _ = regexp.Compile("(site_id|site)[0-9]?$")

View File

@ -104,6 +104,11 @@
"Woundee": "WoundeeHfid",
"Wounder": "WounderHfid"
},
"HistoricalEventMasterpieceArchConstructed": {
"Maker": "Hfid",
"MakerEntity": "EntityId",
"Site": "SiteId"
},
"HistoricalEventMasterpieceEngraving": {
"Maker": "Hfid",
"MakerEntity": "EntityId",

View File

@ -607,8 +607,8 @@ func (x *HistoricalEventDestroyedSite) Html(c *context) string {
return entity(x.AttackerCivId) + " defeated " + siteCiv(x.SiteCivId, x.DefenderCivId) + " and destroyed " + site(x.SiteId, "")
}
func (x *HistoricalEventDiplomatLost) Html(c *context) string { // TODO
return "UNKNWON HistoricalEventDiplomatLost"
func (x *HistoricalEventDiplomatLost) Html(c *context) string {
return entity(x.Entity) + " lost a diplomant in " + site(x.SiteId, "") + ". They suspected the involvement of " + entity(x.Involved)
}
func (x *HistoricalEventEntityAllianceFormed) Html(c *context) string {
@ -756,7 +756,7 @@ func (x *HistoricalEventFailedIntrigueCorruption) Html(c *context) string {
case HistoricalEventFailedIntrigueCorruptionTopFacet_Pride:
case HistoricalEventFailedIntrigueCorruptionTopFacet_StressVulnerability:
case HistoricalEventFailedIntrigueCorruptionTopFacet_Swayable:
fail += ", despite being swayed by the emotional appeal" // TODO
fail += ", despite being swayed by the emotional appeal" // TODO relationship values
case HistoricalEventFailedIntrigueCorruptionTopFacet_Vanity:
case HistoricalEventFailedIntrigueCorruptionTopFacet_Vengeful:
}
@ -1133,7 +1133,7 @@ func (x *HistoricalEventHfsFormedIntrigueRelationship) Html(c *context) string {
case HistoricalEventHfsFormedIntrigueRelationshipTopFacet_Pride:
case HistoricalEventHfsFormedIntrigueRelationshipTopFacet_StressVulnerability:
case HistoricalEventHfsFormedIntrigueRelationshipTopFacet_Swayable:
// success += ", despite being swayed by the emotional appeal" // TODO
// success += ", despite being swayed by the emotional appeal" // TODO relationship values
case HistoricalEventHfsFormedIntrigueRelationshipTopFacet_Vanity:
case HistoricalEventHfsFormedIntrigueRelationshipTopFacet_Vengeful:
}
@ -1202,26 +1202,74 @@ func (x *HistoricalEventKnowledgeDiscovered) Html(c *context) string {
}
func (x *HistoricalEventMasterpieceArchConstructed) Html(c *context) string {
return "UNKNWON HistoricalEventMasterpieceArchConstructed"
return c.hf(x.Hfid) + " constructed a masterful " +
util.If(x.BuildingSubtype != HistoricalEventMasterpieceArchConstructedBuildingSubtype_Unknown, x.BuildingSubtype.String(), x.BuildingType.String()) +
" for " + entity(x.EntityId) + site(x.SiteId, " in")
}
func (x *HistoricalEventMasterpieceDye) Html(c *context) string { // TODO
return "UNKNWON HistoricalEventMasterpieceDye"
func (x *HistoricalEventMasterpieceDye) Html(c *context) string {
return c.hf(x.Hfid) + " masterfully dyed a " + x.Mat.String() + " " + x.ItemType.String() + " with " + x.DyeMat +
" for " + entity(x.EntityId) + site(x.SiteId, " in")
}
func (x *HistoricalEventMasterpieceEngraving) Html(c *context) string {
return "UNKNWON HistoricalEventMasterpieceEngraving"
return c.hf(x.Hfid) + " created a masterful " +
"engraving" +
" for " + entity(x.EntityId) + site(x.SiteId, " in")
}
func (x *HistoricalEventMasterpieceFood) Html(c *context) string {
return "UNKNWON HistoricalEventMasterpieceFood"
return c.hf(x.Hfid) + " prepared a masterful " +
x.ItemSubtype.String() +
" for " + entity(x.EntityId) + site(x.SiteId, " in")
}
func (x *HistoricalEventMasterpieceItem) Html(c *context) string {
return "UNKNWON HistoricalEventMasterpieceItem"
return c.hf(x.Hfid) + " created a masterful " +
x.Mat + " " + util.If(x.ItemSubtype != "", x.ItemSubtype, x.ItemType) +
" for " + entity(x.EntityId) + site(x.SiteId, " in")
}
func (x *HistoricalEventMasterpieceItemImprovement) Html(c *context) string {
return "UNKNWON HistoricalEventMasterpieceItemImprovement"
i := ""
switch x.ImprovementType {
case HistoricalEventMasterpieceItemImprovementImprovementType_ArtImage:
i = "a masterful image in " + x.ImpMat
case HistoricalEventMasterpieceItemImprovementImprovementType_Bands:
i = "masterful bands in " + x.ImpMat
case HistoricalEventMasterpieceItemImprovementImprovementType_Covered:
i = "a masterful covering in " + x.ImpMat
case HistoricalEventMasterpieceItemImprovementImprovementType_Itemspecific: // TODO check subtypes
i = "a masterful handle in " + x.ImpMat
case HistoricalEventMasterpieceItemImprovementImprovementType_RingsHanging:
i = "masterful rings in " + x.ImpMat
case HistoricalEventMasterpieceItemImprovementImprovementType_Spikes:
i = "masterful spikes in " + x.ImpMat
}
return c.hf(x.Hfid) + " added " + i + " to " +
articled(x.Mat+" "+util.If(x.ItemSubtype != "", x.ItemSubtype, x.ItemType)) +
" for " + entity(x.EntityId) + site(x.SiteId, " in")
}
func (x *HistoricalEventMasterpieceLost) Html(c *context) string {
return "UNKNWON HistoricalEventMasterpieceLost"
if e, ok := world.HistoricalEvents[x.CreationEvent]; ok {
switch y := e.Details.(type) {
case *HistoricalEventMasterpieceArchConstructed:
return "the " + util.If(y.BuildingSubtype != HistoricalEventMasterpieceArchConstructedBuildingSubtype_Unknown, y.BuildingSubtype.String(), y.BuildingType.String()) +
" masterfully constructed by " + c.hf(y.Hfid) + " for " + entity(y.EntityId) + site(x.Site, " at") + " in " + Time(e.Year, e.Seconds72) +
" was destroyed" + util.If(x.Histfig != -1, " by "+c.hfRelated(x.Histfig, y.Hfid), "") +
" by " + x.Method + site(x.Site, " at")
case *HistoricalEventMasterpieceEngraving:
return "a masterful engraving created by " + c.hf(y.Hfid) + " for " + entity(y.EntityId) + site(x.Site, " at") + " in " + Time(e.Year, e.Seconds72) +
" was destroyed" + util.If(x.Histfig != -1, " by "+c.hfRelated(x.Histfig, y.Hfid), "") +
" by " + x.Method + site(x.Site, " at")
case *HistoricalEventMasterpieceItem:
return "the masterful " +
y.Mat + " " + util.If(y.ItemSubtype != "", y.ItemSubtype, y.ItemType) +
" created by " + c.hf(y.Hfid) + " for " + entity(y.EntityId) + site(x.Site, " at") + " in " + Time(e.Year, e.Seconds72) +
" was destroyed" + util.If(x.Histfig != -1, " by "+c.hfRelated(x.Histfig, y.Hfid), "") +
" by " + x.Method + site(x.Site, " at")
default:
return c.hf(x.Histfig) + " destroyed a masterful item" + site(x.Site, " in") + " -- " + fmt.Sprintf("%T", e.Details)
}
}
return c.hf(x.Histfig) + " destroyed a masterful item" + site(x.Site, " in")
}
func (x *HistoricalEventMerchant) Html(c *context) string {
return "merchants from " + entity(x.TraderEntityId) + " visited " + entity(x.DepotEntityId) + site(x.SiteId, " at") +
util.If(x.Hardship, " and suffered great hardship", "") +
@ -1366,7 +1414,9 @@ func (x *HistoricalEventReplacedStructure) Html(c *context) string {
return siteCiv(x.SiteCivId, x.CivId) + " replaced " + siteStructure(x.SiteId, x.OldAbId, "") + " with " + structure(x.SiteId, x.NewAbId)
}
func (x *HistoricalEventSiteDied) Html(c *context) string { return "UNKNWON HistoricalEventSiteDied" } // TODO
func (x *HistoricalEventSiteDied) Html(c *context) string {
return siteCiv(x.SiteCivId, x.CivId) + " abandonned the settlement of " + site(x.SiteId, "")
}
func (x *HistoricalEventSiteDispute) Html(c *context) string {
return entity(x.EntityId1) + " of " + site(x.SiteId1, "") + " and " + entity(x.EntityId2) + " of " + site(x.SiteId2, "") + " became embroiled in a dispute over " + x.Dispute.String()
@ -1384,11 +1434,13 @@ func (x *HistoricalEventSiteTakenOver) Html(c *context) string {
return entity(x.AttackerCivId) + " defeated " + siteCiv(x.SiteCivId, x.DefenderCivId) + " and took over " + site(x.SiteId, "") + ". The new government was called " + entity(x.NewSiteCivId)
}
func (x *HistoricalEventSiteTributeForced) Html(c *context) string { // TODO
return "UNKNWON HistoricalEventSiteTributeForced"
func (x *HistoricalEventSiteTributeForced) Html(c *context) string {
return entity(x.AttackerCivId) + " secured tribute from " + siteCiv(x.SiteCivId, x.DefenderCivId) +
util.If(x.SiteId != -1, ", to be delivered"+site(x.SiteId, " from"), "") +
util.If(x.Season != HistoricalEventSiteTributeForcedSeason_Unknown, " every "+x.Season.String(), "")
}
func (x *HistoricalEventSneakIntoSite) Html(c *context) string { // TODO
func (x *HistoricalEventSneakIntoSite) Html(c *context) string {
return util.If(x.AttackerCivId != -1, entity(x.AttackerCivId), "an unknown civilization") + " slipped " + site(x.SiteId, "into") +
util.If(x.SiteCivId != -1 || x.DefenderCivId != -1, ", undetected by "+siteCiv(x.SiteCivId, x.DefenderCivId), "")
}
@ -1404,8 +1456,52 @@ func (x *HistoricalEventSquadVsSquad) Html(c *context) string { // TODO a_leader
util.If(x.DSlain > 0, fmt.Sprintf(", slaying %d", x.DSlain), "")
}
func (x *HistoricalEventTacticalSituation) Html(c *context) string { // TODO
return "UNKNWON HistoricalEventTacticalSituation"
func plan(diff int) string { // TODO not exact
switch {
case diff > 100:
return "unrolled a brilliant tactical plan"
case diff > 30:
return "put forth a sound plan"
case diff > 0:
return "used good tactics"
case diff > -20:
return "made a poor plan"
case diff > -60:
return "blundered terribly"
default:
return "made an outright foolish plan"
}
}
func (x *HistoricalEventTacticalSituation) Html(c *context) string {
r := ""
if x.ATacticianHfid == -1 && x.DTacticianHfid == -1 {
r = "the forces shifted"
} else if x.ATacticianHfid != -1 && x.DTacticianHfid == -1 {
r += c.hf(x.ATacticianHfid) + " " + plan(x.ATacticsRoll-x.DTacticsRoll)
} else if x.ATacticianHfid == -1 && x.DTacticianHfid != -1 {
r += c.hf(x.DTacticianHfid) + " " + plan(x.DTacticsRoll-x.ATacticsRoll)
} else {
if x.ATacticsRoll < x.DTacticsRoll {
r = c.hf(x.DTacticianHfid) + "'s tactical planning was superior to " + c.hf(x.ATacticianHfid) + "'s"
} else {
r = c.hf(x.ATacticianHfid) + " outmatched " + c.hf(x.DTacticianHfid) + " with a cunning plan"
}
}
switch x.Situation {
case HistoricalEventTacticalSituationSituation_AFavored: // TODO wording
case HistoricalEventTacticalSituationSituation_ASlightlyFavored:
r += ", " + util.If(x.DTacticsRoll > x.ATacticsRoll, "but", "and") + " the attackers had a slight positional advantage"
case HistoricalEventTacticalSituationSituation_AStronglyFavored:
r += ", " + util.If(x.DTacticsRoll > x.ATacticsRoll, "but", "and") + " the attackers had a strong positional advantage"
case HistoricalEventTacticalSituationSituation_DSlightlyFavored:
r += ", " + util.If(x.ATacticsRoll > x.DTacticsRoll, "but", "and") + " the defenders had a slight positional advantage"
case HistoricalEventTacticalSituationSituation_DStronglyFavored:
r += ", " + util.If(x.ATacticsRoll > x.DTacticsRoll, "but", "and") + " the defenders had a strong positional advantage"
case HistoricalEventTacticalSituationSituation_NeitherFavored:
r += ", but neither side had a positional advantage"
}
return r + site(x.SiteId, " in")
}
func (x *HistoricalEventTrade) Html(c *context) string {

View File

@ -7339,8 +7339,10 @@ func NewHistoricalEventDiplomatLost() *HistoricalEventDiplomatLost {
SiteId: -1,
}
}
func (x *HistoricalEventDiplomatLost) Type() string { return "diplomat lost" }
func (x *HistoricalEventDiplomatLost) RelatedToEntity(id int) bool { return x.Entity == id }
func (x *HistoricalEventDiplomatLost) Type() string { return "diplomat lost" }
func (x *HistoricalEventDiplomatLost) RelatedToEntity(id int) bool {
return x.Entity == id || x.Involved == id
}
func (x *HistoricalEventDiplomatLost) RelatedToHf(id int) bool { return false }
func (x *HistoricalEventDiplomatLost) RelatedToArtifact(id int) bool { return false }
func (x *HistoricalEventDiplomatLost) RelatedToSite(id int) bool { return x.SiteId == id }
@ -12335,9 +12337,6 @@ type HistoricalEventMasterpieceArchConstructed struct {
BuildingType HistoricalEventMasterpieceArchConstructedBuildingType `json:"buildingType" legend:"plus"` // building_type
EntityId int `json:"entityId" legend:"base"` // entity_id
Hfid int `json:"hfid" legend:"base"` // hfid
Maker int `json:"maker" legend:"plus"` // maker
MakerEntity int `json:"makerEntity" legend:"plus"` // maker_entity
Site int `json:"site" legend:"plus"` // site
SiteId int `json:"siteId" legend:"base"` // site_id
SkillAtTime HistoricalEventMasterpieceArchConstructedSkillAtTime `json:"skillAtTime" legend:"both"` // skill_at_time
Unk2 int `json:"unk2" legend:"plus"` // unk_2
@ -12348,9 +12347,6 @@ func NewHistoricalEventMasterpieceArchConstructed() *HistoricalEventMasterpieceA
BuildingCustom: -1,
EntityId: -1,
Hfid: -1,
Maker: -1,
MakerEntity: -1,
Site: -1,
SiteId: -1,
Unk2: -1,
}
@ -12359,14 +12355,12 @@ func (x *HistoricalEventMasterpieceArchConstructed) Type() string {
return "masterpiece arch constructed"
}
func (x *HistoricalEventMasterpieceArchConstructed) RelatedToEntity(id int) bool {
return x.EntityId == id || x.MakerEntity == id
return x.EntityId == id
}
func (x *HistoricalEventMasterpieceArchConstructed) RelatedToHf(id int) bool { return x.Hfid == id }
func (x *HistoricalEventMasterpieceArchConstructed) RelatedToArtifact(id int) bool { return false }
func (x *HistoricalEventMasterpieceArchConstructed) RelatedToSite(id int) bool {
return x.Site == id || x.SiteId == id
}
func (x *HistoricalEventMasterpieceArchConstructed) RelatedToRegion(id int) bool { return false }
func (x *HistoricalEventMasterpieceArchConstructed) RelatedToSite(id int) bool { return x.SiteId == id }
func (x *HistoricalEventMasterpieceArchConstructed) RelatedToRegion(id int) bool { return false }
func (x *HistoricalEventMasterpieceArchConstructed) CheckFields() {
if x.BuildingCustom != x.EntityId {
@ -12378,33 +12372,6 @@ func (x *HistoricalEventMasterpieceArchConstructed) CheckFields() {
if x.BuildingCustom != x.SiteId {
sameFields["HistoricalEventMasterpieceArchConstructed"]["BuildingCustom"]["SiteId"] = false
}
if x.Maker != x.EntityId {
sameFields["HistoricalEventMasterpieceArchConstructed"]["Maker"]["EntityId"] = false
}
if x.Maker != x.Hfid {
sameFields["HistoricalEventMasterpieceArchConstructed"]["Maker"]["Hfid"] = false
}
if x.Maker != x.SiteId {
sameFields["HistoricalEventMasterpieceArchConstructed"]["Maker"]["SiteId"] = false
}
if x.MakerEntity != x.EntityId {
sameFields["HistoricalEventMasterpieceArchConstructed"]["MakerEntity"]["EntityId"] = false
}
if x.MakerEntity != x.Hfid {
sameFields["HistoricalEventMasterpieceArchConstructed"]["MakerEntity"]["Hfid"] = false
}
if x.MakerEntity != x.SiteId {
sameFields["HistoricalEventMasterpieceArchConstructed"]["MakerEntity"]["SiteId"] = false
}
if x.Site != x.EntityId {
sameFields["HistoricalEventMasterpieceArchConstructed"]["Site"]["EntityId"] = false
}
if x.Site != x.Hfid {
sameFields["HistoricalEventMasterpieceArchConstructed"]["Site"]["Hfid"] = false
}
if x.Site != x.SiteId {
sameFields["HistoricalEventMasterpieceArchConstructed"]["Site"]["SiteId"] = false
}
if x.Unk2 != x.EntityId {
sameFields["HistoricalEventMasterpieceArchConstructed"]["Unk2"]["EntityId"] = false
}
@ -12433,15 +12400,6 @@ func (x *HistoricalEventMasterpieceArchConstructed) MarshalJSON() ([]byte, error
if x.Hfid != -1 {
d["hfid"] = x.Hfid
}
if x.Maker != -1 {
d["maker"] = x.Maker
}
if x.MakerEntity != -1 {
d["makerEntity"] = x.MakerEntity
}
if x.Site != -1 {
d["site"] = x.Site
}
if x.SiteId != -1 {
d["siteId"] = x.SiteId
}
@ -31914,19 +31872,19 @@ func parseHistoricalEventMasterpieceArchConstructedPlus(p *util.XMLParser, obj *
if err != nil {
return nil, err
}
obj.Maker = num(data)
obj.Hfid = num(data)
case "maker_entity":
data, err := p.Value()
if err != nil {
return nil, err
}
obj.MakerEntity = num(data)
obj.EntityId = num(data)
case "site":
data, err := p.Value()
if err != nil {
return nil, err
}
obj.Site = num(data)
obj.SiteId = num(data)
case "skill_at_time":
data, err := p.Value()
if err != nil {