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


C# Card.Select方法代码示例

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


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

示例1: handstring

 private string handstring(Card[] hand)
 {
     return
         hand.Select(c => Ranks[c.Rank] + "" + Suits[(int) c.Suit])
             .Aggregate("", (h, c) => h + " " + c)
             .Remove(0, 1);
 }
开发者ID:charvey,项目名称:ProjectEuler,代码行数:7,代码来源:Problem054.cs

示例2: ScoreHand

        HandScore ScoreHand(Card[] hand)
        {
            HandClass handClass = HandClass.HighCard;
            int classRank = 0;

            bool flush = hand.GroupBy(c => c.Suit).Max(g => g.Count()) == 5;
            bool straight = hand.Select(c => c.Rank).Distinct().Count() == 5 &&
                            hand.OrderBy(c => c.Rank).Max(c => c.Rank) - hand.OrderBy(c => c.Rank).Min(c => c.Rank) == 4;

            if (flush && straight && hand.OrderBy(c => c.Rank).Max().Rank == Ranks.Count-1)
            {
                handClass=HandClass.RoyalFlush;
                classRank = Ranks.Count - 1;
            }
            else if(flush&&straight)
            {
             handClass=HandClass.StraightFlush;
                classRank = hand.Max(c => c.Rank);
            }
            else if (hand.GroupBy(c => c.Rank).Max(g => g.Count()) == 4)
            {
                handClass = HandClass.FourKind;
                classRank = hand.GroupBy(c => c.Rank).OrderByDescending(g => g.Count()).First().First().Rank;
            }
            else if (hand.GroupBy(c => c.Rank).Select(g => g.Count()).All(c => c == 2 || c == 3))
            {
                handClass = HandClass.FullHouse;
                classRank = hand.GroupBy(c => c.Rank).OrderByDescending(g => g.Count()).First().First().Rank;
            }
            else if (flush)
            {
                handClass = HandClass.Flush;
                classRank = hand.Max(c => c.Rank);
            }
            else if (straight)
            {
                handClass = HandClass.Straight;
                classRank = hand.Max(c => c.Rank);
            }
            else if (hand.GroupBy(c => c.Rank).Max(g => g.Count()) == 3)
            {
                handClass = HandClass.ThreeKind;
                classRank = hand.GroupBy(c => c.Rank).OrderByDescending(g => g.Count()).First().First().Rank;
            }
            else if (hand.GroupBy(c => c.Rank).Count(g => g.Count() == 2) == 2)
            {
                handClass = HandClass.TwoPair;
                classRank = hand.GroupBy(c => c.Rank).Where(g => g.Count() == 2).OrderByDescending(g => g.First().Rank).First().First().Rank;
            }
            else if (hand.GroupBy(c => c.Rank).Any(g => g.Count() == 2))
            {
                handClass = HandClass.OnePair;
                classRank = hand.GroupBy(c => c.Rank).Where(g => g.Count() == 2).OrderByDescending(g => g.First().Rank).First().First().Rank;
            }

            return new HandScore {Class = handClass, ClassRank = classRank, HighRank = hand.Max(c => c.Rank)};
        }
开发者ID:charvey,项目名称:ProjectEuler,代码行数:57,代码来源:Problem054.cs

示例3: MoveTo

 public void MoveTo(Group to, bool lFaceUp, int idx, bool isScriptMove)
 {
     //converts negative indexes to count from the bottom for consistency with python behavior
     if (idx < 0) idx = to.Count + 1 + idx;
     //over-large indecies reduced to place cards at end of pile
     if (idx >= to.Count) idx = to.Count;
     if (idx < 0) idx = 0;
     //move skipped if card already at location specified
     if (to == Group && idx < Group.Count && Group[idx] == this) return;
     if (to.Visibility != GroupVisibility.Undefined) lFaceUp = FaceUp;
     var cards = new Card[1] { this };
     Program.Client.Rpc.MoveCardReq(cards.Select(x => x.Id).ToArray(), to, new[] { idx }, new[] { lFaceUp }, isScriptMove);
     new MoveCards(Player.LocalPlayer, cards, to, new[] { idx }, new[] { lFaceUp }, isScriptMove).Do();
     Program.Client.Rpc.CardSwitchTo(Player.LocalPlayer, this, this.Alternate());
 }
开发者ID:Gravecorp,项目名称:OCTGN,代码行数:15,代码来源:Card.cs

示例4: MoveCardsTo

 internal static void MoveCardsTo(Group to, Card[] cards, bool[] faceups, int[] idxs, bool isScriptMove)
 {
     var notMoved = new List<Card>();
     for (var i = 0; i < cards.Length; i++)
     {
         var c = cards[i];
         var lFaceUp = faceups[i];
         //converts negative indexes to count from the bottom for consistency with python behavior
         if (idxs[i] < 0) idxs[i] = to.Count + 1 + idxs[i];
         //over-large indecies reduced to place cards at end of pile
         if (idxs[i] >= to.Count) idxs[i] = to.Count;
         if (idxs[i] < 0) idxs[i] = 0;
         //move skipped if card already at location specified
         if (to == c.Group && idxs[i] < c.Group.Count && c.Group[idxs[i]] == c)
         {
             notMoved.Add(c);
             continue;
         }
         if (to.Visibility != GroupVisibility.Undefined) lFaceUp = c.FaceUp;
     }
     Program.Client.Rpc.MoveCardReq(cards.Select(x => x.Id).ToArray(), to, idxs, faceups, isScriptMove);
     new MoveCards(Player.LocalPlayer, cards, to, idxs, faceups, isScriptMove).Do();
     foreach (var c in cards.Where(x => notMoved.Contains(x) == false))
         Program.Client.Rpc.CardSwitchTo(Player.LocalPlayer, c, c.Alternate());
 }
开发者ID:Gravecorp,项目名称:OCTGN,代码行数:25,代码来源:Card.cs

示例5: MoveCardsToTable

 public static void MoveCardsToTable(Card[] cards, int[] x, int[] y, bool[] lFaceUp, int[] idx, bool isScriptMove)
 {
     Program.Client.Rpc.MoveCardAtReq(cards.Select(a => a.Id).ToArray(), x, y, idx, isScriptMove, lFaceUp);
     new MoveCards(Player.LocalPlayer, cards, x, y, idx, lFaceUp, isScriptMove).Do();
     foreach (var c in cards)
         Program.Client.Rpc.CardSwitchTo(Player.LocalPlayer, c, c.Alternate());
 }
开发者ID:Gravecorp,项目名称:OCTGN,代码行数:7,代码来源:Card.cs

示例6: MoveCardsToTable

        public static void MoveCardsToTable(Card[] cards, int[] x, int[] y, bool[] lFaceUp, int[] idx, bool isScriptMove)
        {
            if( cards.Length == 0 ) return;

            if (Program.GameEngine.Definition.Events.ContainsKey("OverrideCardsMoved") && !isScriptMove)
            {
                var tos = Enumerable.Repeat(Program.GameEngine.Table, cards.Count()).ToArray();
                Program.GameEngine.EventProxy.OverrideCardsMoved_3_1_0_2(cards, tos, idx, x, y);
                return;
            }
            Program.Client.Rpc.MoveCardAtReq(cards.Select(a => a.Id).ToArray(), x, y, idx, isScriptMove, lFaceUp);
            new MoveCards(Player.LocalPlayer, cards, x, y, idx, lFaceUp, isScriptMove).Do();
            foreach (var c in cards)
                Program.Client.Rpc.CardSwitchTo(Player.LocalPlayer, c, c.Alternate());
        }
开发者ID:octgn,项目名称:OCTGN,代码行数:15,代码来源:Card.cs

示例7: DrawAction

 /// <summary>
 /// Draw the action cards.
 /// </summary>
 /// <param name="cards">
 /// The cards.
 /// </param>
 public void DrawAction(Card[] cards)
 {
     List<CardSprite> sprite = cards.Select((t, i) => new CardSprite(t.Name, i)).ToList();
     game.ActionZone.NewCards(sprite);
 }
开发者ID:esfdk,项目名称:BDSADominion,代码行数:11,代码来源:GUIInterface.cs

示例8: DrawHand

 /// <summary>
 /// Draw the hand.
 /// </summary>
 /// <param name="cards">
 /// The cards.
 /// </param>
 public void DrawHand(Card[] cards)
 {
     var sprite = cards.Select((t, i) => new CardSprite(t.Name, i)).ToList();
     game.HandZone.NewCards(sprite);
 }
开发者ID:esfdk,项目名称:BDSADominion,代码行数:11,代码来源:GUIInterface.cs

示例9: OrderCards

 private static void OrderCards(Card[] cards)
 {
     Array.Sort(cards.Select(x => (-1)*(int)x.Value).ToArray(), cards);
 }
开发者ID:pJqEM5Kj,项目名称:stuff,代码行数:4,代码来源:PokerStatisticCalc.cs


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