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


C# GameBoard.PlayMove方法代码示例

本文整理汇总了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);
        }
开发者ID:remy22,项目名称:BattleshipsGame,代码行数:22,代码来源:BattleShipGameBoardTests.cs

示例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));
        }
开发者ID:remy22,项目名称:BattleshipsGame,代码行数:16,代码来源:BattleShipGameBoardTests.cs

示例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));
        }
开发者ID:remy22,项目名称:BattleshipsGame,代码行数:24,代码来源:BattleShipGameBoardTests.cs

示例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));
        }
开发者ID:remy22,项目名称:BattleshipsGame,代码行数:15,代码来源:BattleShipGameBoardTests.cs

示例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));
        }
开发者ID:remy22,项目名称:BattleshipsGame,代码行数:28,代码来源:BattleShipGameBoardTests.cs

示例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));
        }
开发者ID:remy22,项目名称:BattleshipsGame,代码行数:14,代码来源:BattleShipGameBoardTests.cs


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