Minimize D&D NPC extraction contracts
This commit is contained in:
@@ -98,35 +98,14 @@ func canonicalNPCList(response extractionResponse, sourceID string) dnd.NPCList
|
||||
npcs := make([]dnd.NPC, len(response.NPCs))
|
||||
for index, npc := range response.NPCs {
|
||||
npcs[index] = dnd.NPC{
|
||||
ID: identity.DeriveID(npc.Name),
|
||||
Name: npc.Name,
|
||||
Aliases: cloneStrings(npc.Aliases),
|
||||
Description: npc.Description,
|
||||
Relationships: cloneRelationships(npc.Relationships),
|
||||
SourceRefs: canonicalSourceRefs(npc.SourceRefs, sourceID),
|
||||
ID: identity.DeriveID(npc.Name),
|
||||
Name: npc.Name,
|
||||
SourceRefs: canonicalSourceRefs(npc.SourceRefs, sourceID),
|
||||
}
|
||||
}
|
||||
return dnd.NPCList{NPCs: npcs}
|
||||
}
|
||||
|
||||
func cloneStrings(values []string) []string {
|
||||
if values == nil {
|
||||
return nil
|
||||
}
|
||||
return append([]string{}, values...)
|
||||
}
|
||||
|
||||
func cloneRelationships(values []npcRelationshipResponse) []dnd.NPCRelationship {
|
||||
if values == nil {
|
||||
return nil
|
||||
}
|
||||
out := make([]dnd.NPCRelationship, len(values))
|
||||
for index, value := range values {
|
||||
out[index] = dnd.NPCRelationship{Target: value.Target, Relationship: value.Relationship}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func canonicalSourceRefs(values []npcSourceRefResponse, sourceID string) []source.SourceRef {
|
||||
if values == nil {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user