This repository has been archived by the owner on Sep 8, 2023. It is now read-only.
/
departments.go
92 lines (77 loc) · 1.66 KB
/
departments.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
package cavDiscord
import (
"fmt"
"github.com/7cav/api/milpacs"
)
type discordRoleDepartmentLevel int
const (
STAFF_ROLE = 0
LEADS_ROLE = 1
HQ_ROLE = 2
)
type Department interface {
GetRolesForBillet(billet *milpacs.Position) *[]string
}
type departmentGrouping struct {
hqRoleId string
snrLeadRoleId string
staffRoleId string
}
type S1Department struct {
departmentGrouping
}
type S6Department struct {
departmentGrouping
}
func S6() *S6Department {
return &S6Department{
departmentGrouping{
hqRoleId: "asd",
snrLeadRoleId: "asd",
staffRoleId: "asd",
},
}
}
func (dept S6Department) GetRolesForBillet(billet *milpacs.Position) *[]string {
var roles []string
tier := func() discordRoleDepartmentLevel {
switch billet.PositionId {
case 50, 51:
return HQ_ROLE // 1IC, 2IC
case 52, 53, 56, 57:
return LEADS_ROLE // Lead Dev, Snr Dev, Lead Games, Snr Games
default:
return STAFF_ROLE
}
}()
switch tier {
case HQ_ROLE:
roles = append(roles, dept.hqRoleId, dept.staffRoleId);
break
case LEADS_ROLE:
roles = append(roles, dept.snrLeadRoleId, dept.staffRoleId);
break
default:
roles = append(roles, dept.staffRoleId);
break
}
return &roles
}
var positionIdsToDepartment = map[uint64]Department{
50: S6(),
51: S6(),
52: S6(),
53: S6(),
54: S6(),
55: S6(),
56: S6(),
57: S6(),
58: S6(),
59: S6(),
}
func GetDepartment(billet *milpacs.Position) (Department, error) {
if _, found := positionIdsToDepartment[billet.PositionId]; !found {
return nil, fmt.Errorf("could not find matching department for position ID %d", billet.PositionId)
}
return positionIdsToDepartment[billet.PositionId], nil
}