Adopt registry-backed item occurrences
This commit is contained in:
@@ -91,22 +91,22 @@ func appendEnemyEventLists(values []dnd.EnemyEventList) (dnd.EnemyEventList, err
|
||||
return combined, nil
|
||||
}
|
||||
|
||||
func appendItemEventLists(values []dnd.ItemEventList) (dnd.ItemEventList, error) {
|
||||
func appendItemOccurrenceLists(values []dnd.ItemOccurrenceList) (dnd.ItemOccurrenceList, error) {
|
||||
count := 0
|
||||
present := false
|
||||
for _, value := range values {
|
||||
if value.Events != nil {
|
||||
if value.Occurrences != nil {
|
||||
present = true
|
||||
}
|
||||
count += len(value.Events)
|
||||
count += len(value.Occurrences)
|
||||
}
|
||||
if !present {
|
||||
return dnd.ItemEventList{}, nil
|
||||
return dnd.ItemOccurrenceList{}, nil
|
||||
}
|
||||
combined := dnd.ItemEventList{Events: make([]dnd.ItemEvent, 0, count)}
|
||||
combined := dnd.ItemOccurrenceList{Occurrences: make([]dnd.ItemOccurrence, 0, count)}
|
||||
for _, value := range values {
|
||||
for _, event := range value.Events {
|
||||
combined.Events = append(combined.Events, cloneItemEvent(event))
|
||||
for _, occurrence := range value.Occurrences {
|
||||
combined.Occurrences = append(combined.Occurrences, cloneItemOccurrence(occurrence))
|
||||
}
|
||||
}
|
||||
return combined, nil
|
||||
@@ -227,7 +227,7 @@ func cloneEnemyEvent(value dnd.EnemyEvent) dnd.EnemyEvent {
|
||||
return clone
|
||||
}
|
||||
|
||||
func cloneItemEvent(value dnd.ItemEvent) dnd.ItemEvent {
|
||||
func cloneItemOccurrence(value dnd.ItemOccurrence) dnd.ItemOccurrence {
|
||||
clone := value
|
||||
if value.Quantity != nil {
|
||||
quantity := *value.Quantity
|
||||
|
||||
Reference in New Issue
Block a user