-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocations.go
32 lines (27 loc) · 839 Bytes
/
locations.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
package d2editor
import (
"github.com/vitalick/go-d2editor/bitworker"
)
const locationsCount = 3
//Locations struct shown opened acts and difficulties information
type Locations struct {
Normal Location `json:"normal"`
Nightmare Location `json:"nightmare"`
Hell Location `json:"hell"`
}
//NewLocations returns Locations from io.Reader
func NewLocations(br *bitworker.BitReader) (*Locations, error) {
packedLocations, err := br.ReadNextBitsByteSlice(locationsCount)
if err != nil {
return nil, err
}
return &Locations{
*UnpackLocation(packedLocations[0]),
*UnpackLocation(packedLocations[1]),
*UnpackLocation(packedLocations[2]),
}, nil
}
//GetPacked returns packed locations to bytes
func (l *Locations) GetPacked() []byte {
return []byte{l.Normal.GetPacked(), l.Nightmare.GetPacked(), l.Hell.GetPacked()}
}