public PieceMoving(PieceMoving pieceMoving) { PieceColor = pieceMoving.PieceColor; PieceType = pieceMoving.PieceType; SrcPosition = pieceMoving.SrcPosition; DstPosition = pieceMoving.DstPosition; Moved = pieceMoving.Moved; }
public PieceMoving(PieceMoving pieceMoving) { PieceColor = pieceMoving.PieceColor; PieceType = pieceMoving.PieceType; SrcPosition = pieceMoving.SrcPosition; DstPosition = pieceMoving.DstPosition; Moved = pieceMoving.Moved; }
public PieceMoving(PieceMoving pieceMoving) { this.PieceColor = pieceMoving.PieceColor; this.PieceType = pieceMoving.PieceType; this.SrcPosition = pieceMoving.SrcPosition; this.DstPosition = pieceMoving.DstPosition; this.Moved = pieceMoving.Moved; }
public MoveContent(MoveContent moveContent) { this.MovingPiecePrimary = new PieceMoving(moveContent.MovingPiecePrimary); this.MovingPieceSecondary = new PieceMoving(moveContent.MovingPieceSecondary); this.TakenPiece = new PieceTaken(moveContent.TakenPiece.PieceColor, moveContent.TakenPiece.PieceType, moveContent.TakenPiece.Moved, moveContent.TakenPiece.Position); this.EnPassantOccured = moveContent.EnPassantOccured; this.PawnPromotedTo = moveContent.PawnPromotedTo; }
private void OnlineManagerOnOnOpponentMove(Domain.MoveDescription move) { if (_chessState.Engine.WhoseMove == _chessState.PlayerColor) { Debug.LogError("Player move, but received event from server of opponent move"); return; } if (_chessState.Engine.IsValidMove(move.Primary.Src, move.Primary.Dst) && _chessState.Engine.MovePiece(move.Primary.Src, move.Primary.Dst)) { var pawnPromotion = move.PawnPromotion == FSharpOption <Domain.PieceType> .None ? ChessPieceType.None : EngineMappers.toEngineType.Invoke(move.PawnPromotion.Value); var secondaryMove = new PieceMoving { PieceType = ChessPieceType.None }; if (move.Secondary != FSharpOption <Domain.Move> .None) { var secondary = move.Secondary.Value; secondaryMove = new PieceMoving { PieceType = ChessPieceType.Bishop, SrcPosition = secondary.Src, DstPosition = secondary.Dst }; } var takenPiece = new PieceTaken { PieceType = ChessPieceType.None }; if (move.TakenPiecePos != FSharpOption <byte> .None) { var taken = move.TakenPiecePos.Value; takenPiece = new PieceTaken { PieceType = ChessPieceType.Bishop, Position = taken }; } var moveContent = new MoveContent { MovingPiecePrimary = new PieceMoving { SrcPosition = move.Primary.Src, DstPosition = move.Primary.Dst }, PawnPromotedTo = pawnPromotion, MovingPieceSecondary = secondaryMove, TakenPiece = takenPiece }; _chessState.Board.Move(moveContent); PlayerLock.GameLock = false; } else { Debug.LogError("Invalid move from server: " + FSharp.Json.Json.serialize(move)); } }
public MoveContent() { MovingPiecePrimary = new PieceMoving(ChessPieceType.None); MovingPieceSecondary = new PieceMoving(ChessPieceType.None); TakenPiece = new PieceTaken(ChessPieceType.None); }
public MoveContent() { MovingPiecePrimary = new PieceMoving(ChessPieceType.None); MovingPieceSecondary = new PieceMoving(ChessPieceType.None); TakenPiece = new PieceTaken(ChessPieceType.None); }
public MoveContent(MoveContent moveContent) { MovingPiecePrimary = new PieceMoving(moveContent.MovingPiecePrimary); MovingPieceSecondary = new PieceMoving(moveContent.MovingPieceSecondary); TakenPiece = new PieceTaken(moveContent.TakenPiece.PieceColor, moveContent.TakenPiece.PieceType, moveContent.TakenPiece.Moved, moveContent.TakenPiece.Position); EnPassantOccured = moveContent.EnPassantOccured; PawnPromoted = moveContent.PawnPromoted; }
public static void play() { GameBoard Tab = new GameBoard(); Tab.initializeBoard(); while (true) { int posj = (positionX - 28) / 3; //0 - 7 i int posi = positionY - 10; // 0 - 7 j Tab.blackTurn = Round % 2 == 0; Tab.checkRequiredMoves(); title(); Tab.printBoard(); version(); Tab.remainingPieces(); Tab.showRoundNumber(); //linha comeca no (28,10) //termina no (49,10) //coluna comeca no (28,10) //termina no (28,17) //extremos: (28,10), (49,10), (28,17), (49,17) Console.SetCursorPosition(positionX, positionY); Console.CursorVisible = true; var tecla = ConsoleKey.LeftArrow; //inicializando tecla com um valor qualquer //var necessita de inicialização tecla = Console.ReadKey().Key; if (tecla == ConsoleKey.Escape) //voltar ao menu //ESC { Console.CursorVisible = false; int optionE = 1; while (true) { if (optionE == 1) { Console.SetCursorPosition(15, 22); Console.WriteLine(" Do you wanna return to the menu?"); Console.SetCursorPosition(15, 23); Console.WriteLine(" ->YES"); Console.SetCursorPosition(15, 24); Console.WriteLine(" NO"); } if (optionE == 2) { Console.SetCursorPosition(15, 22); Console.WriteLine(" Do you wanna return to the menu?"); Console.SetCursorPosition(15, 23); Console.WriteLine(" YES"); Console.SetCursorPosition(15, 24); Console.WriteLine(" ->NO"); } if (tecla == ConsoleKey.Enter) { if (optionE == 1) { Console.Clear(); Display(); } else { break; //continua o jogo } } tecla = Console.ReadKey().Key; Console.Clear(); title(); Tab.printBoard(); version(); Tab.remainingPieces(); Tab.showRoundNumber(); if ((int)tecla == 87 || tecla == ConsoleKey.UpArrow) { optionE = 1; } if ((int)tecla == 83 || tecla == ConsoleKey.DownArrow) { optionE = 2; } } Console.CursorVisible = true; } if (isMove || tecla == ConsoleKey.Enter && Tab.Pieces[posi, posj] != null && Tab.blackTurn && Tab.Pieces[posi, posj].Color == ConsoleColor.Black || tecla == ConsoleKey.Enter && Tab.Pieces[posi, posj] != null && !Tab.blackTurn && Tab.Pieces[posi, posj].Color == ConsoleColor.White) { if (!isMove) { if (Tab.thereIsARequiredMoveB && Tab.Pieces[posi, posj].canEat || Tab.thereIsARequiredMoveW && Tab.Pieces[posi, posj].canEat || !Tab.thereIsARequiredMoveB && Tab.blackTurn || !Tab.thereIsARequiredMoveW && !Tab.blackTurn) { Tab.Pieces[posi, posj].Tab = Tab.Pieces; PieceMoving = Tab.Pieces[posi, posj]; PieceMoving.possibleMoves(); counter = 1; } else if (!everEat && Tab.Pieces[posi, posj].isMyTurn(Tab.blackTurn)) { Tab.Pieces[posi, posj].Tab = Tab.Pieces; PieceMoving = Tab.Pieces[posi, posj]; PieceMoving.possibleMoves(); counter = 1; } } if (isMove && tecla == ConsoleKey.Enter && counter > 1) { Tab.movePiece(); } ++counter; } Console.CursorVisible = false; //mover cursor no tabuleiro if ((int)tecla == 65 || tecla == ConsoleKey.LeftArrow) // A { positionX = positionX - 3; } if ((int)tecla == 68 || tecla == ConsoleKey.RightArrow) // D { positionX = positionX + 3; } if ((int)tecla == 83 || tecla == ConsoleKey.DownArrow) // S { positionY++; } if ((int)tecla == 87 || tecla == ConsoleKey.UpArrow) // W { positionY--; } //se o cursor sair do tabuleiro if (positionX < 28) { positionX = 49; } if (positionX > 49) { positionX = 28; } if (positionY < 10) { positionY = 17; } if (positionY > 17) { positionY = 10; } Tab.isThereAWinner(); Console.Clear(); } }