Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp2
- {
- class Program
- {
- static void sirka2(int pozice)//vypis jedne sirky
- {
- Console.SetCursorPosition(pozice, 0);//nulty sloupce
- Console.WriteLine("*");
- Console.SetCursorPosition(pozice, 1);//nulty sloupce
- Console.WriteLine("|");
- Console.SetCursorPosition(pozice, 2);//nulty sloupce
- Console.WriteLine("|");
- Console.SetCursorPosition(pozice, 3);//nulty sloupce
- Console.WriteLine("|");
- }
- static void Main(string[] args)
- {
- int pozice = 0;
- int sirky = 13;
- while (true) //dělá furt
- {
- Console.WriteLine("Jsi na tahu");
- sirky = hrac(sirky3);
- if (sirky3 == 0)
- {
- Console.WriteLine("prohrál jsi");
- break;
- }
- Console.WriteLine("Na tahu je protihráč");
- sirky3 = AI(sirky3);
- if (pocetSirek == 0)
- {
- Console.WriteLine("vyhrál jsi");
- break;
- }
- Console.ReadKey();
- }
- static void sirky(int sirky3);
- {
- Console.Clear();
- for (int i = 0; i < sirky3; i++)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write("O\t");
- }
- Console.WriteLine("");
- for (int i = 0; i < sirky3; i++)
- {
- Console.ForegroundColor = ConsoleColor.DarkYellow;
- Console.Write("|\t");
- }
- Console.ForegroundColor = ConsoleColor.White;
- Console.WriteLine("");
- }
- static int AI(int sirky3)
- {
- sirka2(pozice);
- if (sirky3 > 8)
- {
- {
- random(out odectiTo);
- return sirky3 - odectiTo;
- }
- else if (sirky3 > 5 & sirky3 < 9)
- {
- odectiTo = sirky3 - 5;
- return sirky3 - odectiTo;
- }
- else
- {
- switch (sirky3)
- {
- case 5:
- random(out odectiTo);
- return sirky3 - odectiTo;
- break;
- case 4:
- return sirky3 - 3;
- break;
- case 3:
- return sirky3 - 2;
- break;
- case 2:
- return sirky3 - 1;
- break;
- default:
- return sirky3 - 1;
- break;
- }
- }
- }
- static int hrac(int sirky3)
- {
- while (true)
- {
- short odeberTo;
- sirky(sirky3);
- Console.WriteLine("zbývající sirky: {0}", sirky3);
- Console.Write("odeber 1-3 sirky: ");
- string s = Console.ReadLine();
- if ((Int16.TryParse(s, out odeberTo)) & odeberTo > 0 & odeberTo < 4 & odeberTo <= sirky3)
- {
- sirky(sirky3 - odeberTo);
- Console.WriteLine("zbývající sirky: {0}", sirky3 - odeberTo);
- return sirky3 - odeberTo;
- break;
- }
- else
- {
- Console.WriteLine("Neplatný počet sirek! Nezadal jsi 1-3 sirky nebo jsi odebral víc sirek, nez je k dispozici.");
- }
- }
- }
- static void random(out int rnd)
- {
- int a = 1;
- int b = 3;
- Random rn = new Random();
- rnd = rn.Next(a, b);
- }
- }
- }
- }
- Console.WriteLine("Zadej číslo");
- string s = Console.ReadLine();
- sirky = int.Parse(s);
- Console.WriteLine("Zadej číslo");
- while (!int.TryParse(Console.ReadLine(), out x))
- sirky3 = sirky - x;
- if (sirky3 == 0)
- Console.WriteLine("Konec hry");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement