summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2019-01-14 17:49:51 +0100
committerDimitri Sokolyuk <demon@dim13.org>2019-01-14 17:49:51 +0100
commitfd5567d4a4f78d497b2705381aa87f782b399a19 (patch)
treea65671c430229a658d5b5038f4f12ad4fa26de14
parent30f4fc4a8e8e86a8813f5ebdee9f8384aa444a29 (diff)
add magic8
-rw-r--r--magic8/main.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/magic8/main.go b/magic8/main.go
new file mode 100644
index 0000000..3936ef5
--- /dev/null
+++ b/magic8/main.go
@@ -0,0 +1,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)
+}