当前位置: 首页>>代码示例>>C#>>正文


C# GameBoard.IsGameOver方法代码示例

本文整理汇总了C#中GameBoard.IsGameOver方法的典型用法代码示例。如果您正苦于以下问题:C# GameBoard.IsGameOver方法的具体用法?C# GameBoard.IsGameOver怎么用?C# GameBoard.IsGameOver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameBoard的用法示例。


在下文中一共展示了GameBoard.IsGameOver方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsGameOver_When3SameCharactersAreInTheForwardDiagonal_ReturnsTrueAndSetsWinnerFlag

        public void IsGameOver_When3SameCharactersAreInTheForwardDiagonal_ReturnsTrueAndSetsWinnerFlag()
        {
            _boardArray[2, 0] = 'O';
            _boardArray[1, 1] = 'O';
            _boardArray[0, 2] = 'O';
            var gameBoard = new GameBoard(_boardArray);

            bool hasAPlayerWon;
            var result = gameBoard.IsGameOver(out hasAPlayerWon);

            Assert.That(result, Is.True);
            Assert.That(hasAPlayerWon, Is.True);
        }
开发者ID:alpeshv,项目名称:TicTacToe,代码行数:13,代码来源:GameBoardTests.cs

示例2: Strike_Some_Cells_With_Ships_and_Check_If_Game_Is_Over

        public void Strike_Some_Cells_With_Ships_and_Check_If_Game_Is_Over()
        {
            var gameMoves = new List<GameMove>();
            var gameBoard = new GameBoard("Tom2");

            gameBoard.SetUpShips();

            var cellsWhichHaveShipsAndNotHit = (from c in gameBoard.Board.Cells
                                                where c.Value.HasShip && !c.Value.IsHit
                                                select c.Value).Take(12).ToList();

            foreach (var cell in cellsWhichHaveShipsAndNotHit)
            {
                var gameMove = gameBoard.PlayMove(cell.DisplayName);
                gameMoves.Add(gameMove);
            }

            var cells = gameBoard.Board.Cells;

            var gameOver = gameBoard.IsGameOver();

            Assert.AreEqual(false, gameOver);
            Assert.AreEqual(100, cells.Count);
            Assert.AreEqual(13, cells.Count(x => x.Value.HasShip));
            Assert.AreEqual(0, cells.Count(x => x.Value.IsSea));
            Assert.AreEqual(12, cells.Count(x => x.Value.HasShip && x.Value.IsHit));
            Assert.AreEqual(12, gameMoves.Count(y => y.Status == MoveStatus.Success));
        }
开发者ID:remy22,项目名称:BattleshipsGame,代码行数:28,代码来源:BattleShipGameBoardTests.cs

示例3: IsGameOver_When3SameCharactersAreInTheSameRow_ReturnsTrueAndSetsWinnerFlag

        public void IsGameOver_When3SameCharactersAreInTheSameRow_ReturnsTrueAndSetsWinnerFlag(int row)
        {
            _boardArray[row, 0] = 'X';
            _boardArray[row, 1] = 'X';
            _boardArray[row, 2] = 'X';
            var gameBoard = new GameBoard(_boardArray);

            bool hasAPlayerWon;
            var result = gameBoard.IsGameOver(out hasAPlayerWon);

            Assert.That(result, Is.True);
            Assert.That(hasAPlayerWon, Is.True);
        }
开发者ID:alpeshv,项目名称:TicTacToe,代码行数:13,代码来源:GameBoardTests.cs

示例4: IsGameOver_When3SameCharactersAreInTheSameColumn_ReturnsTrueAndSetsWinnerFlag

        public void IsGameOver_When3SameCharactersAreInTheSameColumn_ReturnsTrueAndSetsWinnerFlag(int column)
        {
            _boardArray[0, column] = 'O';
            _boardArray[1, column] = 'O';
            _boardArray[2, column] = 'O';
            var gameBoard = new GameBoard(_boardArray);

            bool hasAPlayerWon;
            var result = gameBoard.IsGameOver(out hasAPlayerWon);

            Assert.That(result, Is.True);
            Assert.That(hasAPlayerWon, Is.True);
        }
开发者ID:alpeshv,项目名称:TicTacToe,代码行数:13,代码来源:GameBoardTests.cs

示例5: IsGameOver_WhenGameBoardIsBlank_ReturnsFalseAndDoesNotSetWinnerFlag

        public void IsGameOver_WhenGameBoardIsBlank_ReturnsFalseAndDoesNotSetWinnerFlag()
        {
            var gameBoard = new GameBoard(_boardArray);

            bool hasAPlayerWon;
            var result = gameBoard.IsGameOver(out hasAPlayerWon);

            Assert.That(result, Is.False);
            Assert.That(hasAPlayerWon, Is.False);
        }
开发者ID:alpeshv,项目名称:TicTacToe,代码行数:10,代码来源:GameBoardTests.cs

示例6: IsGameOver_When3SameCharactersAreNotInLineAndGameBoardIsNotFull_ReturnsFalseAndDoesNotSetWinnerFlag

        public void IsGameOver_When3SameCharactersAreNotInLineAndGameBoardIsNotFull_ReturnsFalseAndDoesNotSetWinnerFlag()
        {
            _boardArray[0, 0] = 'O';
            _boardArray[0, 2] = 'X';

            _boardArray[1, 0] = 'X';
            _boardArray[1, 1] = 'O';

            _boardArray[2, 0] = 'O';
            _boardArray[2, 1] = 'X';

            var gameBoard = new GameBoard(_boardArray);

            bool hasAPlayerWon;
            var result = gameBoard.IsGameOver(out hasAPlayerWon);

            Assert.That(result, Is.False);
            Assert.That(hasAPlayerWon, Is.False);
        }
开发者ID:alpeshv,项目名称:TicTacToe,代码行数:19,代码来源:GameBoardTests.cs


注:本文中的GameBoard.IsGameOver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。