Beispiel #1
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);
        }