summaryrefslogtreecommitdiff
path: root/magic8/main.go
blob: 3936ef555000e0f23898a97d0f4c68cb8b5ab921 (plain)
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
package main

import (
	"fmt"
	"math/rand"
	"time"
)

type affirmative string

func (m affirmative) String() string { return "[+] " + string(m) }

type nonCommittal string

func (m nonCommittal) String() string { return "[?] " + string(m) }

type negative string

func (m negative) String() string { return "[-] " + string(m) }

type magic []fmt.Stringer

func (m magic) String() string {
	rand.Seed(time.Now().UnixNano())
	n := rand.Intn(len(m))
	return m[n].String()
}

var fortune = magic{
	// affirmative
	affirmative("It is certain."),
	affirmative("It is decidedly so."),
	affirmative("Without a doubt."),
	affirmative("Yes - definitely."),
	affirmative("You may rely on it."),

	affirmative("As I see it, yes."),
	affirmative("Most likely."),
	affirmative("Outlook good."),
	affirmative("Yes."),
	affirmative("Signs point to yes."),

	// non-committal
	nonCommittal("Reply hazy, try again."),
	nonCommittal("Ask again later."),
	nonCommittal("Better not tell you now."),
	nonCommittal("Cannot predict now."),
	nonCommittal("Concentrate and ask again."),

	// negative
	negative("Don't count on it."),
	negative("My reply is no."),
	negative("My sources say no."),
	negative("Outlook not so good."),
	negative("Very doubtful."),
}

func main() {
	fmt.Println(fortune)
}