Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="stone"></param>
        public void Challenge(Stone stone)
        {
            Console.WriteLine("Select the name of the selected stone.");
            Stone.DrawStones(Game.Instance.stones, false);
            var input = Console.ReadKey();

            //Gives or takes a point to the opposite player.
            if (stone.Name == Game.Instance.stones.First(stone => stone.Id == int.Parse(input.KeyChar.ToString()) - 1).Name)
            {
                Console.WriteLine("Correct");
                if (Game.Instance.Player == 1)
                {
                    Game.Instance.Points -= 1;
                }
                else
                {
                    Game.Instance.Points += 1;
                }
            }
            else
            {
                Console.WriteLine("Incorrect");
                if (Game.Instance.Player == 1)
                {
                    Game.Instance.Points += 1;
                }
                else
                {
                    Game.Instance.Points -= 1;
                }
            }
            Console.WriteLine("Press any key to continue.");
            Console.ReadKey();
        }
Ejemplo n.º 2
0
        //TODO
        /// <summary>
        ///
        /// </summary>
        /// <param name="cki"></param>
        /// <returns></returns>
        private static bool ExecuteAction(ConsoleKeyInfo cki)
        {
            if (!int.TryParse(cki.KeyChar.ToString(), out var input) || input < 1 || input > 6)
            {
                return(false);
            }
            Stone        stone = null;
            List <Stone> lineStonesOrderedByBoardPosition = Game.Instance.stones.Where(stone => stone.BoardPosition != 0).ToList().OrderBy(stone => stone.BoardPosition).ToList();

            CustomConsole.SetCursorPositionAndClearAfter(Console.CursorLeft, Console.CursorTop - 8);
            switch (input)
            {
            case 1:
                Console.WriteLine("Action: Place");
                stone = Stone.PickFromPool();
                int position;
                do
                {
                    CustomConsole.SetCursorPositionAndClearAfter(Console.CursorLeft, Console.CursorTop - (Stone.GetStonesFromPool().Count + 1));
                    position = GetPositionForPlaceAction();
                    CustomConsole.SetCursorPositionAndClearAfter(Console.CursorLeft, Console.CursorTop - 4);
                }while (position == -1);
                Action.Instance.Place(stone, position);
                break;

            case 2:
                Console.WriteLine("Action: Hide");
                Stone.DrawStones(lineStonesOrderedByBoardPosition);
                stone = Stone.GetStoneFromList(lineStonesOrderedByBoardPosition);
                Action.Instance.Hide(stone);
                break;

            case 3:
                Console.WriteLine("Action: Swap");
                Stone[] swapStones = new Stone[2];
                for (int i = 0; i < swapStones.Length; i++)
                {
                    Stone.DrawStones(lineStonesOrderedByBoardPosition);
                    swapStones[i] = Stone.GetStoneFromList(lineStonesOrderedByBoardPosition);
                    CustomConsole.SetCursorPositionAndClearAfter(Console.CursorLeft, Console.CursorTop - 4);
                }
                Action.Instance.Swap(swapStones);
                break;

            case 4:
                Console.WriteLine("Action: Peek");
                Stone.DrawStones(lineStonesOrderedByBoardPosition);
                stone = Stone.GetStoneFromList(lineStonesOrderedByBoardPosition);
                Action.Instance.Peek(stone);
                break;

            case 5:
                Console.WriteLine("Action: Challenge");
                Stone.DrawStones(lineStonesOrderedByBoardPosition);
                stone = Stone.GetStoneFromList(lineStonesOrderedByBoardPosition);
                Action.Instance.Challenge(stone);
                break;

            case 6:
                Console.WriteLine("Action: Boast");
                Action.Instance.Boast();
                break;

            default:
                return(false);
            }
            return(true);
        }