コード例 #1
0
ファイル: Game.cs プロジェクト: JakeFenley/Chess
        private void Turn(Player currentPlayer)
        {
            Board.DisplayBoard();

            List <GamePiece> movablePieces = GetMoves(currentPlayer);

            if (KingThreatened)
            {
                movablePieces = RemoveIllegalMoves(movablePieces);
            }

            if (movablePieces.Count == 0)
            {
                if (PlayerTurn == 1)
                {
                    CheckMate(player2);
                }
                else
                {
                    CheckMate(player1);
                }
            }
            else if (!currentPlayer.IsAi)
            {
                Console.WriteLine($"{currentPlayer.Name}'s turn.");
                Console.WriteLine("Select a piece to move.");

                for (int i = 0; i < movablePieces.Count; i++)
                {
                    Console.WriteLine($"[{i}]- {movablePieces[i].Type} -[{movablePieces[i].Place.X},{movablePieces[i].Place.Y}] ");
                }

                int result = GetTurnInput(movablePieces);

                MovePiece(movablePieces[result]);
            }
            else if (currentPlayer.IsAi)
            {
                GetAiInput(movablePieces);
            }
        }