-
Notifications
You must be signed in to change notification settings - Fork 0
/
manifestActivityMode.go
65 lines (54 loc) · 1.76 KB
/
manifestActivityMode.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
59
60
61
62
63
64
65
package goBungieNet
import (
"fmt"
"errors"
"encoding/json"
)
type DestinyActivityModeCategory int32
const (
DestinyActivityModeCategoryNone DestinyActivityModeCategory = 0
DestinyActivityModeCategoryPvE = 1
DestinyActivityModeCategoryPvP = 2
)
func (atype *DestinyActivityModeCategory)String() string {
switch (*atype) {
case DestinyActivityModeCategoryNone: return "None"
case DestinyActivityModeCategoryPvE: return "PvE"
case DestinyActivityModeCategoryPvP: return "PvP"
}
return "Unknown"
}
type DestinyActivityModeDefinition struct {
ActivityModeCategory DestinyActivityModeCategory
ActivityModeMappings map[uint32]DestinyActivityMode
Display bool
DisplayProperties DestinyDisplayProperties
FriendlyName string
IsTeamBased bool
IsAggregateMode bool
Index int32
ModeType DestinyActivityMode
Order int32
ParentHashes []uint32
PGCRImage string
Redacted bool
}
func manifestActivityModeDefinition(languageCode string, hash uint32) (*DestinyActivityModeDefinition, error) {
dataFile := fmt.Sprintf("%s-%s", manifestWorld, languageCode)
db, err := manifestOpenData(dataFile)
if err != nil { return nil, err }
rows, err := db.Query("SELECT json FROM DestinyActivityModeDefinition WHERE id = $1", int32(hash))
if err != nil { return nil, err }
defer rows.Close()
if !rows.Next() { return nil, errors.New("No Results!") }
var jsonData string
err = rows.Scan(&jsonData)
if err != nil { return nil, err }
result := DestinyActivityModeDefinition{}
err = json.Unmarshal([]byte(jsonData), &result)
if err != nil { return nil, err }
return &result, nil
}
func (base *CharacterActivities)ActivityModeDefinition(languageCode string) (*DestinyActivityModeDefinition, error) {
return manifestActivityModeDefinition(languageCode, base.CurrentActivityModeHash)
}