-
Notifications
You must be signed in to change notification settings - Fork 2
/
chain.go
58 lines (47 loc) · 1.13 KB
/
chain.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package evtc
import (
"time"
"github.com/pkg/errors"
"golang.org/x/text/language"
)
type EventChain struct {
agents map[uint64]*Agent
skills map[uint32]string
serverTime time.Time
localTime time.Time
timeOffset time.Duration
ArcDPSVersion string
BuildID int
BossSpecies int
BossName string
PointOfView *Agent
Language language.Tag
Events []Event
WorldID uint16
MapID uint16
}
func makeEventChain(h header, agents map[uint64]*wrappedAgent, skills map[uint32]string, events []cbtevent1) (*EventChain, error) {
chain := &EventChain{
agents: make(map[uint64]*Agent),
skills: skills,
ArcDPSVersion: string(h.Date[:]),
}
chain.BossSpecies = int(h.Boss)
for addr, wrapped := range agents {
if wrapped.speciesID == h.Boss {
chain.BossName = wrapped.charName
}
chain.agents[addr] = &Agent{
wrapped: wrapped,
chain: chain,
}
}
for _, event := range events {
if e, err := parseEvent(chain, event); err != nil {
return nil, errors.Wrap(err, "evtc: failed to parse event")
} else if e != nil {
chain.Events = append(chain.Events, e)
}
}
return chain, nil
}