Add NPC interaction normalization

This commit is contained in:
2026-07-23 13:42:37 +00:00
parent cb7f145c76
commit ed2b6f4580
6 changed files with 700 additions and 9 deletions

View File

@@ -57,6 +57,27 @@ func appendCombatTurnLists(values []dnd.CombatTurnList) (dnd.CombatTurnList, err
return combined, nil
}
func appendNPCInteractionLists(values []dnd.NPCInteractionList) (dnd.NPCInteractionList, error) {
count := 0
present := false
for _, value := range values {
if value.Interactions != nil {
present = true
}
count += len(value.Interactions)
}
if !present {
return dnd.NPCInteractionList{}, nil
}
combined := dnd.NPCInteractionList{Interactions: make([]dnd.NPCInteraction, 0, count)}
for _, value := range values {
for _, interaction := range value.Interactions {
combined.Interactions = append(combined.Interactions, cloneNPCInteraction(interaction))
}
}
return combined, nil
}
func cloneCombatTurn(value dnd.CombatTurn) dnd.CombatTurn {
clone := value
if value.SourceRefs != nil {
@@ -64,3 +85,11 @@ func cloneCombatTurn(value dnd.CombatTurn) dnd.CombatTurn {
}
return clone
}
func cloneNPCInteraction(value dnd.NPCInteraction) dnd.NPCInteraction {
clone := value
if value.SourceRefs != nil {
clone.SourceRefs = append([]source.SourceRef(nil), value.SourceRefs...)
}
return clone
}