Exemple #1
0
        public void AiWrite(int move)
        {
            Console.WriteLine();
            Console.Write("hreje ");
            if (color)
            {
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.Write("AI\n");
                Console.ForegroundColor = ConsoleColor.White;
            }

            //roll sticks
            Console.Write("hodil jsi: ");
            int i = 0;

            bool[] aSticks = Sticks.GetSticks();
            int    number  = Sticks.GetNumber();

            if (color)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write(number);
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write(" = ");
            }
            else
            {
                Console.Write(number + " = ");
            }
            while (i != 4)
            {
                Console.Write(Convert.ToInt32(aSticks[i]) + " ");
                i++;
            }
            if (move == 0)
            {
                Console.Write("\nAI se nemůže hnout");
            }
            else
            {
                Console.Write("\nAI posune kámen z ");
                if (color)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.Write(move + 1 - Sticks.GetNumber());
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else
                {
                    Console.Write(move + 1 - Sticks.GetNumber());
                }
                Console.Write(" na ");
                //flip if reverse
                if (reverse)
                {
                    move = -move;
                }
                if (color)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.Write(move + 1);
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else
                {
                    Console.Write(move + 1);
                }
            }
            Console.Write(" pro pokračování zmáčkni ");
            if (color)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("enter ");
                Console.ForegroundColor = ConsoleColor.White;
            }
            else
            {
                Console.Write("enter ");
            }
            Console.ReadLine();
        }
Exemple #2
0
        /*
         * 1 => player 1
         * 2 => player 2
         */
        public int Input(int player, bool repeat = false)
        {
            int i, number, input;

            bool[] aSticks;

            List <Figure> figures;

            if (player == 1)
            {
                figures = GetAvaibleFigures(player1, player2);
            }
            else
            {
                figures = GetAvaibleFigures(player2, player1);
            }

            if (repeat)
            {
                if (color)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                Console.Write("špatný vstup");
                if (color)
                {
                    Console.ForegroundColor = ConsoleColor.White;
                }
            }

            //player
            Console.Write("\n");
            if (color)
            {
                if (player == 1)
                {
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write("hraje ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write("hráč jedna");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write("hraje ");
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.Write("hráč dva");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                Console.Write("\n");
            }
            else
            {
                if (player == 1)
                {
                    Console.Write("hraje hráč jedna");
                }
                else
                {
                    Console.Write("hraje hráč dva");
                }
                Console.Write("\n");
            }

            //roll sticks
            Console.Write("hodil jsi: ");
            i       = 0;
            aSticks = Sticks.GetSticks();
            number  = Sticks.GetNumber();
            if (color)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write(number);
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write(" = ");
            }
            else
            {
                Console.Write(number + " = ");
            }
            while (i != 4)
            {
                Console.Write(Convert.ToInt32(aSticks[i]) + " ");
                i++;
            }

            if (skip_move)
            {
                Console.Write("\nnemáš jak se hýbat. zmáčkni ");
                if (color)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                Console.Write("enter ");
                if (color)
                {
                    Console.ForegroundColor = ConsoleColor.White;
                }
                Console.Write("pro pokračování ");
                Console.ReadLine();
                return(99);
            }

            //picking next move
            Console.Write("\njakým kamenem budeš hrát? (");

            i = 0;
            foreach (Figure figure in figures)
            {
                if (i > 0)
                {
                    Console.Write(", ");
                }
                if (color)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                }
                Console.Write(figure.GetPosition() + 1);
                if (color)
                {
                    Console.ForegroundColor = ConsoleColor.White;
                }
                i++;
            }

            Console.Write("): ");
            int.TryParse(Console.ReadLine(), out input);
            repeat = true;
            foreach (Figure figure in figures)
            {
                if (figure.GetPosition() == input - 1)
                {
                    repeat = false;
                    break;
                }
            }
            if (repeat)
            {
                Console.Clear();
                Render.PrintArray(this);
                this.Input(player, repeat = true);
            }
            return(input - 1);
        }