using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestConsoleApp
{
class Program
{
static void Main(string[] args)
{
int stone = 20;
const int MIN = 1;
const int MAX = 3;
int n;
Console.WriteLine("-----GAME START-----");
while (true) {
try
{
Console.WriteLine("LEFT: " + stone);
Console.WriteLine("HOW MANY DO YOU GET? (" + MIN + " - " + MAX + "): ");
String s = Console.ReadLine();
n = int.Parse(s);
}
catch {
n = MIN;
}
if (n < MIN) n = MIN;
if (n > MAX) n = MAX;
stone -= n;
if (stone < 0) stone = 0;
Console.WriteLine("YOU GET " + n + " STONES.");
Console.WriteLine("LEFT: " + stone);
if (stone == 0){
Console.WriteLine("\nOOPS, YOU LOST...\n");
break;
}
int n2 = (stone - 1) % (MIN + MAX);
if (n2 < MIN) n2 = MIN;
if (n2 > MAX) n2 = MAX;
stone -= n2;
if (stone < 0) stone = 0;
Console.WriteLine("I GOT " + n2 + " STONES.");
if (stone == 0) {
Console.WriteLine("\nGREAT! YOU WIN!\n");
break;
}
}
Console.Write("(TYPE ANY KEY)");
Console.ReadKey();
}
}
}