Exemplo n.º 1
0
 public void SetPreset(Preset preset)
 {
     try
     {
         MainBoard = new Board(preset.BoardRank);
         DrawProcessor.SetBoard(MainBoard);
         MovementProcessor.SetBoard(MainBoard);
         Players = preset.Players;
         MainBoard.SetPieces(preset.StartingPosition);
         SwapSides();
     }
     catch {
         DrawProcessor.Display("Invalid game preset");
     }
 }
Exemplo n.º 2
0
        private void DisplayInfo()
        {
            switch (LastMoveResult)
            {
            case MoveResult.Success:
            default:
                break;

            case MoveResult.NeedToConvert:
                DrawProcessor.Display($"{CurrentPlayer.Color} pawn is ready to convert.");
                DrawProcessor.Display($"Please choose piece pawb wiil be converted into: ");
                DrawProcessor.Display($"Ф - Queen");
                DrawProcessor.Display($"i - Bishop");
                DrawProcessor.Display($"2 - Knight");
                DrawProcessor.Display($"Д - Rook");
                DrawProcessor.Display($"");
                break;

            case MoveResult.WrongInputFormat:
                DrawProcessor.DisplayError("Wrong format");
                break;

            case MoveResult.WrongBeginningCell:
                DrawProcessor.DisplayError($"Chosen piece is not yours. Choose {CurrentPlayer.Color} piece");
                break;

            case MoveResult.EmptyBeginningCell:
                DrawProcessor.DisplayError("Chosen starting cell is empty");
                break;

            case MoveResult.WrongDestinationCell:
                break;

            case MoveResult.OccupiedDestinationCell:
                DrawProcessor.DisplayError("Chosen target cell is occupied by your piece");
                break;

            case MoveResult.ImpossibleMove:
                DrawProcessor.DisplayError("Chosen piece cannot move to the target cell");
                break;
            }

            DrawProcessor.Display("");
            DrawProcessor.Display("Type in your move in following format - \"A7 A5\",\"B5 E2\",\"G8 F6\"");
            DrawProcessor.Display("");
            DrawProcessor.Display($"Now is {CurrentPlayer.Name}'s turn");
        }
Exemplo n.º 3
0
        private void Turn()
        {
            try
            {
                DrawProcessor.Clear();
                DrawProcessor.DrawBoard();
                DisplayInfo();

                LastMoveResult = LastMoveResult == MoveResult.NeedToConvert
                    ? MovementProcessor.ConvertPiece(GetMove(), CurrentPlayer)
                    : LastMoveResult = MovementProcessor.ProcessAMove(GetMove(), CurrentPlayer);

                if (LastMoveResult == MoveResult.Success)
                {
                    SwapSides();
                }
            }
            catch (NullReferenceException)
            {
            }
        }
Exemplo n.º 4
0
 public GameProcessor()
 {
     DrawProcessor     = new DrawProcessor();
     MovementProcessor = new MovementProcessor();
 }