本文整理汇总了C#中Game.ConvertIntoCoordinates方法的典型用法代码示例。如果您正苦于以下问题:C# Game.ConvertIntoCoordinates方法的具体用法?C# Game.ConvertIntoCoordinates怎么用?C# Game.ConvertIntoCoordinates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game.ConvertIntoCoordinates方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}
示例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);
}
示例5: _020_Checker_Can_Jump_Over_FoeChecker
public void _020_Checker_Can_Jump_Over_FoeChecker()
{
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;
var moveStartCoordinate = game.ConvertIntoCoordinates(game.CurrentPlayer.EnterCoordinates());
var moveEndCoordinate = game.ConvertIntoCoordinates("D8");
game.FindCheckersWithTakes();
var expected = game.CanMoveThere(moveStartCoordinate, moveEndCoordinate);
Assert.IsTrue(expected);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例10: _010_Ordinary_Checkers_Cannot_Move_Backwards
public void _010_Ordinary_Checkers_Cannot_Move_Backwards()
{
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("A5");
var expected = game.IsMoveForward(moveStartCoordinate, moveEndCoordinate);
Assert.IsFalse(expected);
}
示例11: _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);
}
示例12: _008_Ordinary_Checker_Moves_At_One_Cell_Only
public void _008_Ordinary_Checker_Moves_At_One_Cell_Only()
{
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(0, 7)),
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("D4");
var expected = game.IsOneCellMove(moveStartCoordinate, moveEndCoordinate);
Assert.IsFalse(expected);
}