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


C# Card.IsOneEyedJack方法代码示例

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

示例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;
        }
开发者ID:jbfp,项目名称:Sequence_old,代码行数:72,代码来源:Game.cs


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