本文整理汇总了C#中GameBoard.PlayMove方法的典型用法代码示例。如果您正苦于以下问题:C# GameBoard.PlayMove方法的具体用法?C# GameBoard.PlayMove怎么用?C# GameBoard.PlayMove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameBoard
的用法示例。
在下文中一共展示了GameBoard.PlayMove方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Play_Move_On_Cell_With_Ship_Which_Has_Been_Hit_And_Check
public void Play_Move_On_Cell_With_Ship_Which_Has_Been_Hit_And_Check()
{
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).ToList();
gameBoard.PlayMove(cellsWhichHaveShipsAndNotHit.First().DisplayName);
//Play again on same cell
var move = gameBoard.PlayMove(cellsWhichHaveShipsAndNotHit.First().DisplayName);
var cells = gameBoard.Board.Cells;
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(1, cells.Count(x => x.Value.HasShip && x.Value.IsHit));
Assert.AreEqual(MoveStatus.HasAlreadyBeenPlayed, move.Status);
}
示例2: Computer_Plays_A_Move
public void Computer_Plays_A_Move()
{
var gameMoves = new List<GameMove>();
var gameBoard = new GameBoard("Computer");
gameBoard.SetUpShips();
var cells = gameBoard.Board.Cells;
gameBoard.PlayMove();
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(1, cells.Count(x => x.Value.IsSea == true || x.Value.IsHit == true));
}
示例3: Play_Move_On_Cell_With_Ship_And_Check
public void Play_Move_On_Cell_With_Ship_And_Check()
{
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).ToList();
foreach (var cell in cellsWhichHaveShipsAndNotHit)
{
var gameMove = gameBoard.PlayMove(cell.DisplayName);
gameMoves.Add(gameMove);
}
var cells = gameBoard.Board.Cells;
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(13, cells.Count(x => x.Value.HasShip && x.Value.IsHit));
Assert.AreEqual(13, gameMoves.Count(y=> y.Status == MoveStatus.Success));
}
示例4: Play_Ten_Valid_Moves_And_Check_If_Moved_played_Ok
public void Play_Ten_Valid_Moves_And_Check_If_Moved_played_Ok()
{
var gameBoard = new GameBoard("Tom2");
gameBoard.SetUpShips();
for (int i = 1; i < 11; i++)
{
gameBoard.PlayMove("A" + i.ToString());
}
var cells = gameBoard.Board.Cells;
Assert.AreEqual(100, cells.Count);
Assert.AreEqual(13, cells.Count(x => x.Value.HasShip));
Assert.AreEqual(10, cells.Count(x => x.Value.IsSea || x.Value.IsHit));
}
示例5: 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));
}
示例6: Play_Three_InValid_Moves_And_Check
public void Play_Three_InValid_Moves_And_Check()
{
var gameBoard = new GameBoard("Tom2");
gameBoard.SetUpShips();
gameBoard.PlayMove("K10");
gameBoard.PlayMove("A");
gameBoard.PlayMove("A1]");
var cells = gameBoard.Board.Cells;
Assert.AreEqual(100, cells.Count);
Assert.AreEqual(13, cells.Count(x => x.Value.HasShip));
Assert.AreEqual(0, cells.Count(x => x.Value.IsSea));
}