Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
        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));
            }
        }
Exemplo n.º 3
0
 public MoveContent()
 {
     MovingPiecePrimary   = new PieceMoving(ChessPieceType.None);
     MovingPieceSecondary = new PieceMoving(ChessPieceType.None);
     TakenPiece           = new PieceTaken(ChessPieceType.None);
 }
Exemplo n.º 4
0
 public MoveContent()
 {
     MovingPiecePrimary = new PieceMoving(ChessPieceType.None);
     MovingPieceSecondary = new PieceMoving(ChessPieceType.None);
     TakenPiece = new PieceTaken(ChessPieceType.None);
 }
Exemplo n.º 5
0
        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;
        }