Simplify D&D combat turn extraction contract
This commit is contained in:
@@ -96,9 +96,6 @@ func canonicalCombatTurnList(response extractionResponse, sourceID string) dnd.C
|
||||
turns[index] = dnd.CombatTurn{
|
||||
Actor: turn.Actor,
|
||||
TurnKind: dnd.CombatTurnKind(turn.TurnKind),
|
||||
Round: cloneIntPointer(turn.Round),
|
||||
Actions: canonicalActions(turn.Actions),
|
||||
Summary: turn.Summary,
|
||||
SourceRefs: canonicalSourceRefs(turn.SourceRefs, sourceID),
|
||||
}
|
||||
}
|
||||
@@ -108,22 +105,6 @@ func canonicalCombatTurnList(response extractionResponse, sourceID string) dnd.C
|
||||
return dnd.CombatTurnList{CombatTurns: turns}
|
||||
}
|
||||
|
||||
func canonicalActions(actions []combatActionResponse) []dnd.CombatAction {
|
||||
if actions == nil {
|
||||
return nil
|
||||
}
|
||||
out := make([]dnd.CombatAction, len(actions))
|
||||
for index, action := range actions {
|
||||
out[index] = dnd.CombatAction{
|
||||
Category: dnd.CombatActionCategory(action.Category),
|
||||
Declaration: action.Declaration,
|
||||
Targets: append([]string(nil), action.Targets...),
|
||||
Resolution: cloneStringPointer(action.Resolution),
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func canonicalSourceRefs(refs []combatSourceRefResponse, sourceID string) []source.SourceRef {
|
||||
if refs == nil {
|
||||
return nil
|
||||
@@ -134,19 +115,3 @@ func canonicalSourceRefs(refs []combatSourceRefResponse, sourceID string) []sour
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func cloneIntPointer(value *int) *int {
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
out := *value
|
||||
return &out
|
||||
}
|
||||
|
||||
func cloneStringPointer(value *string) *string {
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
out := *value
|
||||
return &out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user