-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheighball.go
42 lines (35 loc) · 924 Bytes
/
eighball.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
package eightball
import (
"math/rand"
"time"
)
func GetPositive() Response {
return PositiveResponses[rand.Intn(len(PositiveResponses))]
}
func GetNeutral() Response {
return NeutralResponses[rand.Intn(len(NeutralResponses))]
}
func GetNegative() Response {
return NegativeResponses[rand.Intn(len(NegativeResponses))]
}
func GetRandom() Response {
return Responses[rand.Intn(len(Responses))]
}
func AddMessage(message string, responseType ResponseType) {
response := Response{
Message: message,
ResponseType: responseType,
}
Responses = append(Responses, response)
switch responseType {
case ResponseTypePositive:
PositiveResponses = append(PositiveResponses, response)
case ResponseTypeNeutral:
NeutralResponses = append(NeutralResponses, response)
case ResponseTypeNegative:
NegativeResponses = append(NegativeResponses, response)
}
}
func init() {
rand.Seed(time.Now().UnixNano())
}