-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmember.go
59 lines (46 loc) · 1.41 KB
/
member.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
package vrmlgo
import "slices"
type Member struct {
User *User `json:"user"`
Games []UserGame `json:"allGames"`
AllPlayersSameDiscord interface{} `json:"allPlayersSameDiscord"`
AllPlayersSameIP interface{} `json:"allPlayersSameIP"`
PenaltyPoints interface{} `json:"penaltyPoints"`
BanInfo interface{} `json:"banInfo"`
LocationFromIP interface{} `json:"locationFromIP"`
CurrentUserIsModInRelatedGame bool `json:"currentUserIsModInRelatedGame"`
}
// PlayerID returns the player ID of the user for a given game.
func (a *Member) PlayerID(gameName string) string {
for _, g := range a.Games {
if g.Game.ShortName != gameName {
continue
}
if g.BioCurrent.PlayerID != "" {
return g.BioCurrent.PlayerID
}
for _, t := range g.BioCurrentSeasonPastTeams {
if t.PlayerID != "" {
return t.PlayerID
}
}
for _, t := range g.BioPastSeasons {
if t.PlayerID != "" {
return t.PlayerID
}
}
}
return ""
}
// Teams returns a list of team IDs that the user is a member of for a given game.
func (a *Member) TeamIDs(gameName string) []string {
teamIDs := make([]string, 0)
for _, g := range a.Games {
if g.Game.ShortName == gameName {
teamIDs = append(teamIDs, g.TeamIDs()...)
}
}
slices.Sort(teamIDs)
teamIDs = slices.Compact(teamIDs)
return teamIDs
}