protected static void AssertBaseProperties(
            [NotNull] GameBoard gameBoard,
            GameSide expectedActiveSide,
            CastlingOptions expectedCastlingOptions,
            EnPassantCaptureInfo expectedEnPassantCaptureInfo,
            int expectedHalfMoveCountBy50MoveRule,
            int expectedFullMoveIndex,
            GameState expectedGameState,
            AutoDrawType autoDrawType = AutoDrawType.None)
        {
            Assert.That(gameBoard, Is.Not.Null);

            Assert.That(gameBoard.ActiveSide, Is.EqualTo(expectedActiveSide));
            Assert.That(gameBoard.CastlingOptions, Is.EqualTo(expectedCastlingOptions));
            AssertEnPassantCaptureInfo(gameBoard.EnPassantCaptureInfo, expectedEnPassantCaptureInfo);
            Assert.That(gameBoard.FullMoveIndex, Is.EqualTo(expectedFullMoveIndex));
            Assert.That(gameBoard.HalfMoveCountBy50MoveRule, Is.EqualTo(expectedHalfMoveCountBy50MoveRule));
            Assert.That(gameBoard.FullMoveCountBy50MoveRule, Is.EqualTo(expectedHalfMoveCountBy50MoveRule / 2));
            Assert.That(gameBoard.State, Is.EqualTo(expectedGameState));
            Assert.That(gameBoard.GetAutoDrawType(), Is.EqualTo(autoDrawType));
        }
Пример #2
0
        private void AffectStatesInternal(GameManagerState desiredState)
        {
            _whiteTotalStopwatch.Stop();
            _blackTotalStopwatch.Stop();
            _whiteLastMoveStopwatch.Stop();
            _blackLastMoveStopwatch.Stop();

            var gameBoard = GetActiveBoard();

            _autoDrawType = AutoDrawType.None;
            switch (gameBoard.State)
            {
            case GameState.Checkmate:
                _result = gameBoard.ActiveSide == GameSide.White ? GameResult.BlackWon : GameResult.WhiteWon;
                _state  = GameManagerState.GameFinished;
                return;

            case GameState.Stalemate:
                _result = GameResult.Draw;
                _state  = GameManagerState.GameFinished;
                return;

            default:
                _result = null;

                _autoDrawType = gameBoard.GetAutoDrawType();
                if (_autoDrawType != AutoDrawType.None)
                {
                    _result = GameResult.Draw;
                    _state  = GameManagerState.GameFinished;
                    return;
                }

                break;
            }

            _state = desiredState;
        }