本文整理汇总了C#中Card.IsOneEyedJack方法的典型用法代码示例。如果您正苦于以下问题:C# Card.IsOneEyedJack方法的具体用法?C# Card.IsOneEyedJack怎么用?C# Card.IsOneEyedJack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Card
的用法示例。
在下文中一共展示了Card.IsOneEyedJack方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OneEyedJacks_are_Jacks_of_the_Black_Suits
public void OneEyedJacks_are_Jacks_of_the_Black_Suits(Suit suit, bool expected)
{
// Arrange.
var sut = new Card(suit, Rank.Jack);
// Act.
var actual = sut.IsOneEyedJack();
// Assert.
Assert.That(actual, Is.EqualTo(expected));
}
示例2: PlayCard
public Game PlayCard(Guid userId, int row, int column, Card card)
{
if (card == null)
{
throw new ArgumentNullException("card");
}
if (Status != GameStatus.Playing)
{
throw new InvalidOperationException("Game is not under way.");
}
var user = _users.SingleOrDefault(id => id == userId);
if (user == null)
{
throw new InvalidOperationException("User is not in game.");
}
if (GameBoard.IsShared(row, column))
{
var error = string.Format("{{ Row: {0}, Column: {1} }} is a corner.", row.ToString(), column.ToString());
throw new InvalidOperationException(error);
}
if (card.IsOneEyedJack())
{
if (_board.IsFree(row, column))
{
throw new InvalidOperationException("Tile is empty.");
}
var sequences = _board.GetSequences();
if (sequences.Any(s => s.Contains(row, column)))
{
var error = string.Format("{{ Row: {0}, Column: {1} }} is part of a sequence.", row, column);
throw new InvalidOperationException(error);
}
}
else
{
if (!Equals(GameBoard.GetCard(row, column), card) && !card.IsTwoEyedJack())
{
throw new InvalidOperationException("Card does not match tile.");
}
}
if (_hands[userId].Contains(card) == false)
{
throw new InvalidOperationException("User does not have that card.");
}
var index = _users.IndexOf(user);
var team = (Team) (index % 2 + 1);
var deadCards = _hands[userId].Where(c => _board.IsCardDead(c));
var dealtCards = deadCards.Count() + 1;
var e = new MovePerformedGameEvent(Guid.NewGuid(), Id, userId, Version + 1)
{
CardPlayed = card,
NumCardsDealt = dealtCards,
DeadCards = deadCards,
Column = column,
Created = DateTimeOffset.Now,
Row = row,
Team = team
};
RaiseEvent(e);
return this;
}