Пример #1
0
        internal IDisposable PlayTemporaryMove(Square startingSquare, Square endingSquare)
        {
            var ret = new TemporaryMoveDisposable(startingSquare, endingSquare);

            _piecesInfluenceManager.PlayTemporaryMove(ret);
            return(ret);
        }
Пример #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);
            };
        }
Пример #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);
                };
            }
        }
Пример #4
0
 internal void PlayTemporaryMove(TemporaryMoveDisposable disp)
 {
     _controlManager.PlayTemporaryMove(disp);
 }
Пример #5
0
 internal void PlayTemporaryMove(TemporaryMoveDisposable disp)
 {
     HandleInfluencedPieces(disp);
     HandleCapturedPiece(disp);
 }