-
Notifications
You must be signed in to change notification settings - Fork 4
/
structs.go
138 lines (115 loc) · 3.99 KB
/
structs.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package main
// These structs are for supplying page data to .tmpl files
// VuePageData is the input to the Vue shell template.
type VuePageData struct {
UserJSON string
}
// These structs are for replaying the draft on the client.
// Perspective tells the client from which user's perspective the replay data is from.
type Perspective struct {
User int64 `json:"user"`
Draft DraftJSON `json:"draft"`
}
// DraftJSON describes the draft to the replay viewer.
type DraftJSON struct {
DraftID int64 `json:"draftId"`
DraftName string `json:"draftName"`
Seats [8]Seat `json:"seats"`
Events []DraftEvent `json:"events"`
PickXsrf string `json:"pickXsrf"`
}
// Seat is part of DraftJSON.
type Seat struct {
Packs [3][15]interface{} `json:"packs"`
PlayerName string `json:"playerName"`
MtgoName string `json:"mtgoName"`
PlayerID int64 `json:"playerId"`
PlayerImage string `json:"playerImage"`
}
// DraftEvent is part of DraftJSON.
type DraftEvent struct {
Position int64 `json:"position"`
Announcements []string `json:"announcements"`
Cards []int64 `json:"cards"`
PlayerModified int64 `json:"playerModified"`
DraftModified int64 `json:"draftModified"`
Round int64 `json:"round"`
Librarian bool `json:"librarian"`
Type string `json:"type"`
}
// These structs are for sending other data to the client.
// JSONError helps to pass an error to the client when something breaks.
type JSONError struct {
Error string `json:"error"`
}
// DraftList is turned into JSON and used for the REST API.
type DraftList struct {
Drafts []DraftListEntry `json:"drafts"`
}
// DraftListEntry is turned into JSON and used for the REST API.
type DraftListEntry struct {
AvailableSeats int64 `json:"availableSeats"`
ReservedSeats int64 `json:"reservedSeats"`
Finished bool `json:"finished"`
ID int64 `json:"id"`
Joined bool `json:"joined"`
Reserved bool `json:"reserved"`
Skipped bool `json:"skipped"`
Name string `json:"name"`
Status string `json:"status"`
}
// UserInfo is JSON passed to the client.
type UserInfo struct {
Name string `json:"name"`
Picture string `json:"picture"`
ID int64 `json:"userId"`
MtgoName string `json:"mtgoName"`
}
// UserFormatPrefs is turned into JSON and used for the REST API.
type UserFormatPrefs struct {
Prefs []UserFormatPref `json:"prefs"`
}
// UserFormatPref is turned into JSON and used for the REST API.
type UserFormatPref struct {
Format string `json:"format"`
Elig bool `json:"elig"`
}
// These structs are for receiving data from the client.
// PostedPick is JSON accepted from the client when a user makes a pick.
type PostedPick struct {
CardIds []int64 `json:"cards"`
XsrfToken string `json:"xsrfToken"`
}
// PostedJoin is JSON accepted from the client when a user joins a draft.
type PostedJoin struct {
ID int64 `json:"id"`
}
// PostedJoin is JSON accepted from the client when a user changes their preferences.
type PostedPref struct {
MtgoName string `json:"mtgoName"`
FormatPref UserFormatPref `json:"pref"`
}
// These structs are for exporting in bulk to .dek files.
// BulkMTGOExport is used to bulk export .dek files for the admin.
type BulkMTGOExport struct {
PlayerID int64
Username string
Deck string
}
// NameAndQuantity is used in MTGO .dek exports.
type NameAndQuantity struct {
Name string
MTGO string
Quantity int64
}
// R38CardData is the JSON passed to the client for card data.
// Note that this does not describe everything that is in the data, just what we need
type R38CardData struct {
MTGO int64 `json:"mtgo_id"`
Scryfall ScryfallCardData `json:"scryfall"`
}
// ScryfallCardData is more JSON passed to the client for card data.
// Note that this does not describe everything that is in the data, just what we need
type ScryfallCardData struct {
Name string `json:"name"`
}