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


C# Game.GetChecker方法代码示例

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


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

示例1: _002_Can_Make_Move

        public void _002_Can_Make_Move()
        {
            var game = new Game
            {
                Board = new Board(),
                Player1 = new FakePlayer(true),
                Player2 = new FakePlayer(false),
                CheckersSet = new List<Checker>
                {
                    new Checker(true, false,  new Coordinate(2, 1)),
                    new Checker(true, false,  new Coordinate(3, 4)),
                    new Checker(false, false, new Coordinate(1, 2)),
                    new Checker(false, false, new Coordinate(2, 5)),
                    new Checker(false, false, new Coordinate(4, 5)),
                }
            };
            game.CurrentPlayer = game.Player1;

            game.Move = new Move();

            var moveStartCoordinate = game.ConvertIntoCoordinates(game.CurrentPlayer.EnterCoordinates());
            game.Move.AddCoordinate(moveStartCoordinate);

            var moveEndCoordinate = game.ConvertIntoCoordinates("c5");
            game.Move.AddCoordinate(moveEndCoordinate);

            game.MoveChecker();

            var actual = game.GetChecker(moveEndCoordinate);
            var expected = new Checker(true, false, new Coordinate(3, 2));

            Assert.AreEqual(expected, actual);
        }
开发者ID:kolinlob,项目名称:Checkers,代码行数:33,代码来源:MoveTests.cs

示例2: _001_Player_Can_Select_Checker

        public void _001_Player_Can_Select_Checker()
        {
            var game = new Game();
            var validInput = new FakePlayer(true).EnterCoordinates();

            var expectedChecker = new Checker(false, false, new Coordinate(2, 1));

            game.CreateCheckers(false);

            var moveStartCoordinate = game.ConvertIntoCoordinates(validInput);
            var actualChecker = game.GetChecker(moveStartCoordinate);

            Assert.AreEqual(actualChecker, expectedChecker);
        }
开发者ID:kolinlob,项目名称:Checkers,代码行数:14,代码来源:PlayerTests.cs

示例3: _023_Can_Make_Compound_Move

        public void _023_Can_Make_Compound_Move()
        {
            var game = new Game
            {
                Board = new Board(),
                Player1 = new FakePlayer(true),
                Player2 = new FakePlayer(false),
                CheckersSet = new List<Checker>
                {
                    new Checker(true, false,  new Coordinate(4, 3)), // CHECKER WE TEST
                    new Checker(false, false, new Coordinate(3, 4)),
                    new Checker(false, false, new Coordinate(1, 4)),
                    new Checker(false, false, new Coordinate(1, 2)),
                    new Checker(false, false, new Coordinate(3, 2)),
                }
            };
            game.CurrentPlayer = game.Player1;

            game.FindCheckersWithTakes();

            game.Move = new Move();

            var moveStartCoordinate1 = game.ConvertIntoCoordinates("D4");
            game.Move.AddCoordinate(moveStartCoordinate1);

            var moveEndCoordinate1 = game.ConvertIntoCoordinates("F6");
            game.Move.AddCoordinate(moveEndCoordinate1);

            game.MoveChecker();
            game.PossibleTakes.Clear();
            game.FindCheckersWithTakes();

            var moveEndCoordinate2 = game.ConvertIntoCoordinates("D8");
            game.Move.AddCoordinate(moveEndCoordinate2);

            game.MoveChecker();
            game.PossibleTakes.Clear();
            game.FindCheckersWithTakes();

            var moveEndCoordinate3 = game.ConvertIntoCoordinates("B6");
            game.Move.AddCoordinate(moveEndCoordinate3);

            game.MoveChecker();
            game.PossibleTakes.Clear();
            game.FindCheckersWithTakes();

            var moveEndCoordinate4 = game.ConvertIntoCoordinates("D4");
            game.Move.AddCoordinate(moveEndCoordinate4);

            game.MoveChecker();
            game.PossibleTakes.Clear();
            game.FindCheckersWithTakes();

            var noPossibleTakes = game.PossibleTakes.Keys.Count == 0;
            Assert.IsTrue(noPossibleTakes);

            var checkerInRightPlace = game.CheckersSet[0].Coordinate.X == 4 && game.CheckersSet[0].Coordinate.Y == 3;
            Assert.IsTrue(checkerInRightPlace);

            var checker1IsTaken = game.GetChecker(game.ConvertIntoCoordinates("E5"));
            Assert.IsNull(checker1IsTaken);

            var checker2IsTaken = game.GetChecker(game.ConvertIntoCoordinates("E7"));
            Assert.IsNull(checker2IsTaken);

            var checker3IsTaken = game.GetChecker(game.ConvertIntoCoordinates("C7"));
            Assert.IsNull(checker3IsTaken);

            var checker4IsTaken = game.GetChecker(game.ConvertIntoCoordinates("C5"));
            Assert.IsNull(checker4IsTaken);
        }
开发者ID:kolinlob,项目名称:Checkers,代码行数:71,代码来源:GameTests.cs

示例4: _022_Can_Remove_Taken_Checker

        public void _022_Can_Remove_Taken_Checker()
        {
            var game = new Game
            {
                Board = new Board(),
                Player1 = new FakePlayer(true),
                Player2 = new FakePlayer(false),
                CheckersSet = new List<Checker>
                {
                    new Checker(true, false,  new Coordinate(2, 1)),
                    new Checker(false, false, new Coordinate(1, 2)),
                }
            };
            game.CurrentPlayer = game.Player1;

            game.FindCheckersWithTakes();

            game.Move = new Move();

            var moveStartCoordinate = game.ConvertIntoCoordinates(game.CurrentPlayer.EnterCoordinates());
            game.Move.AddCoordinate(moveStartCoordinate);

            var moveEndCoordinate = game.ConvertIntoCoordinates("D8");
            game.Move.AddCoordinate(moveEndCoordinate);

            game.RemoveTakenChecker();

            var expected = game.GetChecker(game.ConvertIntoCoordinates("C7"));

            Assert.IsNull(expected);
        }
开发者ID:kolinlob,项目名称:Checkers,代码行数:31,代码来源:GameTests.cs

示例5: _018_Find_Possible_Takes

        public void _018_Find_Possible_Takes()
        {
            var game = new Game
            {
                Board = new Board(),
                Player1 = new FakePlayer(true),
                Player2 = new FakePlayer(false),
                CheckersSet = new List<Checker>
                {
                    new Checker(true, false,  new Coordinate(3, 4)),
                    new Checker(false, false, new Coordinate(4, 5))
                }
            };
            game.CurrentPlayer = game.Player1;

            var takingMove = new List<Coordinate> { new Coordinate(3, 4), new Coordinate(5, 6) };

            var expectedChecker = game.GetChecker(takingMove[0]);
            var currentChecker = game.CheckersSet[0];

            var expectedPossibleTakes = new Dictionary<Checker, List<Coordinate>>
            {
                {
                    expectedChecker, new List<Coordinate>(){new Coordinate(5,6)}
                }
            };

            game.FindPossibleTakes(currentChecker);

            var expected = expectedPossibleTakes[expectedChecker]; //5,6
            var actual = game.PossibleTakes[currentChecker];

            CollectionAssert.AreEqual(actual, expected);
        }
开发者ID:kolinlob,项目名称:Checkers,代码行数:34,代码来源:GameTests.cs

示例6: _017_Cannot_Move_to_Unusable_Cell

        public void _017_Cannot_Move_to_Unusable_Cell()
        {
            var game = new Game
            {
                Board = new Board(),
                Player1 = new FakePlayer(true),
                Player2 = new FakePlayer(false)
            };
            game.CurrentPlayer = game.Player1;

            game.CreateCheckers(false);
            game.CreateCheckers(true);

            game.CurrentPlayer = new FakePlayer(true);

            var moveStartCoordinate = game.ConvertIntoCoordinates(game.CurrentPlayer.EnterCoordinates());
            var checker = game.GetChecker(moveStartCoordinate);
            checker.IsQueen = true;

            var moveEndCoordinate = game.ConvertIntoCoordinates("C4");

            var canMoveThere = game.CanMoveThere(moveStartCoordinate, moveEndCoordinate);
            Assert.IsFalse(canMoveThere);
        }
开发者ID:kolinlob,项目名称:Checkers,代码行数:24,代码来源:GameTests.cs

示例7: _016_Cannot_Get_Any_Checker_If_Empty_Cell_Selected

        public void _016_Cannot_Get_Any_Checker_If_Empty_Cell_Selected()
        {
            var game = new Game
            {
                Board = new Board(),
                Player1 = new FakePlayer(true),
                Player2 = new FakePlayer(false)
            };
            game.CurrentPlayer = game.Player1;

            game.CreateCheckers(false);
            game.CreateCheckers(true);

            const string validAdress = "A8";
            var adress = game.ConvertIntoCoordinates(validAdress);
            var coordinate = new Coordinate(adress.X, adress.Y);

            var checker = game.GetChecker(coordinate);
            var canSelect = game.CanSelectChecker(checker);

            Assert.IsFalse(canSelect);
        }
开发者ID:kolinlob,项目名称:Checkers,代码行数:22,代码来源:GameTests.cs

示例8: _015_Can_Get_Checker

        public void _015_Can_Get_Checker()
        {
            var game = new Game
            {
                Board = new Board(),
                Player1 = new FakePlayer(true),
                Player2 = new FakePlayer(false)
            };
            game.CurrentPlayer = game.Player2;

            game.CreateCheckers(false);
            game.CreateCheckers(true);

            game.FindCheckersWithTakes();

            var validAdress = game.CurrentPlayer.EnterCoordinates();
            var moveStartCoordinate = game.ConvertIntoCoordinates(validAdress);

            var checker = game.GetChecker(moveStartCoordinate);
            var canSelectChecker = game.CanSelectChecker(checker);

            Assert.IsTrue(canSelectChecker);
        }
开发者ID:kolinlob,项目名称:Checkers,代码行数:23,代码来源:GameTests.cs

示例9: _012_Queen_Can_Move_Only_on_Diagonals

        public void _012_Queen_Can_Move_Only_on_Diagonals()
        {
            var game = new Game
            {
                Board = new Board(),
                Player1 = new FakePlayer(true),
                Player2 = new FakePlayer(false),
                CheckersSet = new List<Checker>
                {
                    new Checker(true, true,   new Coordinate(2, 1)),
                    new Checker(true, false,  new Coordinate(3, 4)),
                    new Checker(false, false, new Coordinate(1, 2)),
                    new Checker(false, false, new Coordinate(2, 5)),
                    new Checker(false, false, new Coordinate(4, 5)),
                }
            };
            game.CurrentPlayer = game.Player1;

            var moveStartCoordinate = game.ConvertIntoCoordinates(game.CurrentPlayer.EnterCoordinates());
            var moveEndCoordinate = game.ConvertIntoCoordinates("B4");

            var currentChecker = game.GetChecker(moveStartCoordinate);
            currentChecker.IsQueen = true;

            var expected = game.IsDiagonalMove(moveStartCoordinate, moveEndCoordinate);
            Assert.IsFalse(expected);
        }
开发者ID:kolinlob,项目名称:Checkers,代码行数:27,代码来源:GameTests.cs

示例10: _009_Queen_Moves_At_More_than_1_Cell

        public void _009_Queen_Moves_At_More_than_1_Cell()
        {
            var game = new Game
            {
                Board = new Board(),
                Player1 = new FakePlayer(true),
                Player2 = new FakePlayer(false),
                CheckersSet = new List<Checker>
                {
                    new Checker(true, true,   new Coordinate(2, 1)),
                    new Checker(true, false,  new Coordinate(3, 4)),
                    new Checker(false, false, new Coordinate(1, 2)),
                    new Checker(false, false, new Coordinate(2, 5)),
                    new Checker(false, false, new Coordinate(4, 5)),
                }
            };
            game.CurrentPlayer = game.Player1;

            var input = game.CurrentPlayer.EnterCoordinates();
            var moveStartCoordinate = game.ConvertIntoCoordinates(input);
            var moveEndCoordinate = game.ConvertIntoCoordinates("D4");

            game.GetChecker(moveStartCoordinate).IsQueen = true;

            var expected = game.IsOneCellMove(moveStartCoordinate, moveEndCoordinate);
            Assert.IsFalse(expected);
        }
开发者ID:kolinlob,项目名称:Checkers,代码行数:27,代码来源:GameTests.cs


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