-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatform.go
More file actions
77 lines (62 loc) · 1.57 KB
/
platform.go
File metadata and controls
77 lines (62 loc) · 1.57 KB
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
package pubg
import "errors"
const (
// EmptyPlatform the platform is not specified
EmptyPlatform = ""
// SteamPlatform - Steam
SteamPlatform = "steam"
// PsnPlatform - PS4
PsnPlatform = "psn"
// XboxPlatform - Xbox
XboxPlatform = "xbox"
// KakaoPlatform - Kakao
KakaoPlatform = "kakao"
// ConsolePlatform - Console
ConsolePlatform = "console"
// TournamentPlatform - Tournament
TournamentPlatform = "tournament"
// StadiaPlatform - Stadia
StadiaPlatform = "stadia"
)
// Platform as string
type Platform string
// IsEmpty returns true if the platform is empty.
func (p Platform) IsEmpty() bool {
return p == EmptyPlatform
}
// IsValid returns true if the platform is valid.
func (p Platform) IsValid() bool {
return p == EmptyPlatform || p == SteamPlatform || p == PsnPlatform || p == XboxPlatform ||
p == KakaoPlatform || p == ConsolePlatform || p == TournamentPlatform || p == StadiaPlatform
}
// TransformToPlatform transforms a string into a Platform structure.
func TransformToPlatform(name string) (platform Platform, err error) {
platform = EmptyPlatform
switch name {
case EmptyPlatform:
return
case SteamPlatform:
platform = SteamPlatform
return
case PsnPlatform:
platform = PsnPlatform
return
case XboxPlatform:
platform = XboxPlatform
return
case KakaoPlatform:
platform = KakaoPlatform
return
case ConsolePlatform:
platform = ConsolePlatform
return
case TournamentPlatform:
platform = TournamentPlatform
return
case StadiaPlatform:
platform = StadiaPlatform
return
}
err = errors.New("Platform not found. ")
return
}