Skip to content

Instantly share code, notes, and snippets.

@oyakodon
Last active March 4, 2016 15:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save oyakodon/aa5897676610b71cc0e3 to your computer and use it in GitHub Desktop.
ぬるぽゲーム / C#
using System;
using System.Collections.Generic;
class Program
{
static void Main(string[] args)
{
var rnd = new Random(Environment.TickCount - 1); // 乱数
var nullpo = new List<char>() { 'ぬ', 'る', 'ぽ' }; // 「ぬるぽ」の3文字のChar型配列
var str = ""; // これまで選択された文字をどんどんケツに連結させるためのString
var i = 1; // 何文字目か
var debug = false; // デバッグか否か
Console.WriteLine("ランダムに表示される「ぬ」と「る」と「ぽ」は");
Console.WriteLine("何文字目で「ぬるぽ」になるでしょうか?");
Console.Write("続行するには何かキーを押してください. . . > ");
var keyinfo = Console.ReadKey(); // キー入力1文字
if (keyinfo.Modifiers == ConsoleModifiers.Control)
{
// コントロールキーが押されていたら
debug = true;
Console.WriteLine("");
Console.Write("Please input \"i\" value...(Caution:[INT]) > ");
i = int.Parse(Console.ReadLine());
}
Console.WriteLine();
while ( true && !debug )
{
var index = rnd.Next(114514) % 3; // 0~114514-1までの乱数を3で割ったあまり(0, 1, 2)
var chosen_char = nullpo[index]; // ぬるぽ配列からランダムに選択
str += chosen_char; // ケツに突っ込む
if ( str.Length % 8 == 0)
{
Console.Write(chosen_char + "\n"); // 8文字だったら改行してから表示
}
else
{
Console.Write(chosen_char); // 表示
}
if ( str.Contains("ぬるぽ")) // 「ぬるぽ」文字列が現れたら
{
break; // whileループを抜ける
} else
{
++i; // 回数 + 1
}
}
Console.WriteLine();
if ( i == 3 )
{
// 乱数が「0 1 2」の順番で現れ、すんなり「ぬるぽ」した
Console.WriteLine("いっぱつで「ぬるぽ」しました!");
}
else if ( i < 100 )
{
// 100文字以下でぬるぽ出現
Console.WriteLine(i + "文字目で「ぬるぽ」しました!");
}
else
{
// 乱数のせいで100回以上かかってしまった
Console.WriteLine("あああああああああああああああああああああああああああああああ!!!!!!!!!!!(ブリブリブリブリュリュリュリュリュリュ!!!!!!ブツチチブブブチチチチブリリイリブブブブゥゥゥゥッッッ!!!!!!! )");
// 汚い。
Console.WriteLine("" + i + "文字目で「ぬるぽ」しました。");
}
// ガッ
// ※AAはちゃんと表示されない可能性があります、適時調節してください。
Console.WriteLine(
"( ・∀・)   || ガッ\n" +
"と    )    ||\n" +
" Y / ノ 人\n" +
" / ) < > __Λ∩\n" +
" _/ し'//. V`Д´)/ \n" +
"(_フ彡 /\n");
Console.Write("続行するには何かキーを押してください. . . > ");
Console.ReadKey();
Console.WriteLine();
if ( !debug )
{
// 結局ぬるぽする
Console.WriteLine("すみません、C#では「NullReferenceException」でした。");
throw new NullReferenceException();
} else
{
Console.WriteLine("/* ここでNullReferenceException */");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment