-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathportal.go
61 lines (50 loc) · 1.58 KB
/
portal.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
package portalmodel
// This module defines implementation neutral portal state information
// data structures
import (
"encoding/json"
)
type Resonator struct {
Position string `json:"position"`
Level float32 `json:"level"`
Health float32 `json:"health"`
Owner string `json:"owner"`
}
type Mod struct {
Owner string `json:"owner"`
Slot float32 `json:"slot"`
Type string `json:"type"` // 'FA'mp, 'HS'ink, 'LA'mp, 'SBUL'ink, 'MH'ack, 'PS'hield, 'AXA' Aegis Shield, 'T'urret
Rarity string `json:"rarity"` // 'C'ommon, 'R'are, 'VR' Very Rare
}
type Status struct {
Title string `json:"Title"`
Description string `json:"description"`
CoverImageURL string `json:"coverImageUrl"`
Owner string `json:"owner"`
Level float32 `json:"level"`
Health float32 `json:"health"`
Faction string `json:"controllingFaction"` // Will be 'E'nlightened, 'R'esistance, or 'N'eutral
Mods []Mod `json:"mods"`
Resonators []Resonator `json:"resonators"`
}
type portalStatus struct {
Status Status `json:"externalApiPortal"`
}
type PortalMsg struct {
Home bool `json:"home"`
Status Status `json:"externalApiPortal"`
}
// DeepCopy deepcopies a to b using json marshaling
func (msg *PortalMsg) DeepCopy() (cpy *PortalMsg) {
cpy = &PortalMsg{}
byt, _ := json.Marshal(msg)
json.Unmarshal(byt, cpy)
return cpy
}
// DeepCopy deepcopies a to b using json marshaling
func (status *Status) DeepCopy() (cpy *Status) {
cpy = &Status{}
byt, _ := json.Marshal(status)
json.Unmarshal(byt, cpy)
return cpy
}