Ejemplo n.º 1
0
        internal IDisposable PlayTemporaryMove(Square startingSquare, Square endingSquare)
        {
            var ret = new TemporaryMoveDisposable(startingSquare, endingSquare);

            _piecesInfluenceManager.PlayTemporaryMove(ret);
            return(ret);
        }
Ejemplo n.º 2
0
        private void HandleCapturedPiece(TemporaryMoveDisposable disp)
        {
            if (!disp.IsCapture)
            {
                return;
            }

            var previouslyControlledSquares = _control[disp.CapturedPiece.Color][disp.CapturedPiece];
            var newControlledSquares        = new List <Square>();

            ReplaceSquareInPiecesControlDict(disp.CapturedPiece, newControlledSquares, previouslyControlledSquares);

            disp.Disposing += (sender, e) =>
            {
                ReplaceSquareInPiecesControlDict(disp.CapturedPiece, previouslyControlledSquares, newControlledSquares);
            };
        }
Ejemplo n.º 3
0
        private void HandleInfluencedPieces(TemporaryMoveDisposable disp)
        {
            var influencedPieces = _piecesControlDict[disp.StartingSquare];

            influencedPieces.Add(disp.MovedPiece);

            foreach (var piece in influencedPieces.Where(p => !p.Captured).ToList())
            {
                var newControlledSquares = piece.GetControlledSquares(_board)
                                           .Select(coordinate => _board[coordinate]);
                var previouslyControlledSquares = _control[piece.Color][piece];

                ReplaceSquareInPiecesControlDict(piece, newControlledSquares, previouslyControlledSquares);

                disp.Disposing += (sender, e) =>
                {
                    ReplaceSquareInPiecesControlDict(piece, previouslyControlledSquares, newControlledSquares);
                };
            }
        }
Ejemplo n.º 4
0
 internal void PlayTemporaryMove(TemporaryMoveDisposable disp)
 {
     _controlManager.PlayTemporaryMove(disp);
 }
Ejemplo n.º 5
0
 internal void PlayTemporaryMove(TemporaryMoveDisposable disp)
 {
     HandleInfluencedPieces(disp);
     HandleCapturedPiece(disp);
 }