本文整理汇总了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);
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}