LoginSignup
12
3

More than 5 years have passed since last update.

そういえばそういうのもあったなあと思い出すGetWild.

Last updated at Posted at 2016-12-16

はい

https://github.com/yu81/getwild-zundoko-go
https://github.com/yu81/getwild-zundoko-go/blob/master/main.go

リポジトリ名オチ。
以前局所的な時空で流行った http://qiita.com/shunsugai@github/items/971a15461de29563bf90 周辺のネタを地獄の底から甦らせた感じです。

はい。


package main

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

func main() {
    counter := 0
    for {
        counter++
        getWild := getWildAndTough()
        fmt.Println(getWild)
        if isGetWildAndTough(getWild) {
            printWithDuration(hugeGet, 200*time.Millisecond)
            printWithDuration(hugeWild, 400*time.Millisecond)
            printWithDuration(hugeAnd, 300*time.Millisecond)
            printWithDuration(hugeTough, 1000*time.Millisecond)
            fmt.Printf("%d 回目のチャレンジでGet Wild And Tough\n", counter)
            os.Exit(0)
        }
        if isGetChanceAndLuck(getWild) {
            printWithDuration(hugeGet, 200*time.Millisecond)
            printWithDuration(hugeChance, 400*time.Millisecond)
            printWithDuration(hugeAnd, 300*time.Millisecond)
            printWithDuration(hugeLuck, 1000*time.Millisecond)
            fmt.Printf("%d 回目のチャレンジでGet Chance And Luck\n", counter)
            os.Exit(0)
        }
    }
}

func getRandomIndex() int64 {
    rand.Seed(time.Now().UnixNano())
    return rand.Int63n(int64(len(words)))
}

func getWordFromIndex(w []string, n int) string {
    if n < 0 || n > len(w) {
        return ""
    }
    return w[n]
}

func getWildAndTough() string {
    const l = 4
    result := make([]string, l)
    for i := 0; i < l; i++ {
        result[i] += getWordFromIndex(words, int(getRandomIndex()))
    }
    return strings.Join(result, " ")
}

func printWithDuration(s string, d time.Duration) {
    fmt.Println(s)
    time.Sleep(d)
}

func isGetWildAndTough(s string) bool {
    return s == "Get Wild And Tough"
}

func isGetChanceAndLuck(s string) bool {
    return s == "Get Chance And Luck"
}

var words = []string{"Get", "Wild", "And", "Tough", "Chance", "Luck"}

// generated with figlet
// https://github.com/cmatsuoka/figlet
const (
    hugeGet = `  ____      _
 / ___| ___| |_
| |  _ / _ \ __|
| |_| |  __/ |_
 \____|\___|\__|
`

    hugeWild = `__        ___ _     _
\ \      / (_) | __| |
 \ \ /\ / /| | |/ _` + "`" + "|" + `
  \ V  V / | | | (_| |
   \_/\_/  |_|_|\__,_|
`

    hugeAnd = `    _              _
   / \   _ __   __| |
  / _ \ | '_ \ / _` + "`" + "|" + `
 / ___ \| | | | (_| |
/_/   \_\_| |_|\__,_|
`

    hugeTough = ` _                    _
| |_ ___  _   _  __ _| |__
| __/ _ \| | | |/ _` + "`" + ` | '_ \
| || (_) | |_| | (_| | | | |
\__\___/ \__,_|\__, |_| |_|
                |___/
`

    hugeChance = `  ____ _
 / ___| |__   __ _ _ __   ___ ___
| |   | '_ \ / _` + "`" + ` | '_ \ / __/ _ \
| |___| | | | (_| | | | | (_|  __/
\____|_| |_|\__,_|_| |_|\___\___|
`

    hugeLuck = ` _               _
| |   _   _  ___| | __
| |  | | | |/ __| |/ /
| |__| |_| | (__|   <
|_____\__,_|\___|_|\_\
`
)

実行してみましょう。
Golang の環境が無い方は以下より辿ってバイナリを直接ダウンロードして実行して下さい。
無駄に Windows, Mac, Linux の3環境に対応しています。クロスコンパイル万歳!!!!!!
https://github.com/yu81/getwild-zundoko-go/tree/master/bin

Golang の環境がある方はいつものように go get して下さい。
後は流れでお願いします。

実行

こうなります。

$ bin/darwin/amd64/getwild-zundoko-go
Tough Chance And Get
And Luck Chance Wild
Wild Chance And Get
Get Chance Luck And
Luck Tough Luck Chance
Get Chance Get Chance
Luck Chance Get Wild
Chance Get Get Tough
Luck Chance Chance Tough
Tough Tough Luck Luck
And Tough Luck Tough
Get Chance Tough Get
...
Get Chance And Luck
  ____      _
 / ___| ___| |_
| |  _ / _ \ __|
| |_| |  __/ |_
 \____|\___|\__|

  ____ _
 / ___| |__   __ _ _ __   ___ ___
| |   | '_ \ / _` | '_ \ / __/ _ \
| |___| | | | (_| | | | | (_|  __/
\____|_| |_|\__,_|_| |_|\___\___|

    _              _
   / \   _ __   __| |
  / _ \ | '_ \ / _`|
 / ___ \| | | | (_| |
/_/   \_\_| |_|\__,_|

 _               _
| |   _   _  ___| | __
| |  | | | |/ __| |/ /
| |__| |_| | (__|   <
|_____\__,_|\___|_|\_\

462 回目のチャレンジでGet Chance And Luck


ポイントはちゃんとAAの部分でリズムを取っている感じですが、微妙にメロディーライン外しているところです。
figlet の出力かわいくてべんり。

所感

来年こそは各位の期待に応えるようにしたいと思います。(事前の実装と時間の確保……)
GetWild 家元の @sion_cojp 先生には申し訳ない気持ちで一杯です。
ハードル上がりすぎやで……w

12
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
3