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


C# Group.FindByCardIdentity方法代码示例

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


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

示例1: Shuffle

 /// <summary>Part of a shuffle process.</summary>
 /// <param name="group">The group being shuffled.</param>
 /// <param name="card">An array containing the CardIdentity ids to shuffle.</param>
 public void Shuffle(Group group, int[] card)
 {
     // Array to hold the new aliases (sent to CreateAlias)
     ulong[] aliases = new ulong[card.Length];
     // Intialize the group shuffle
     group.filledShuffleSlots = 0;
     group.hasReceivedFirstShuffledMessage = false;
     group.myShufflePos = new short[card.Length];
     // Check if we received enough cards
     if (Player.Count <= 1)
         return;
     if (card.Length < group.Count / (Player.Count - 1))
         Program.Trace.TraceEvent(TraceEventType.Warning, EventIds.Event, "[Shuffle] Too few cards received.");
     // Do the shuffling
     Random rnd = new Random();
     for (int i = card.Length - 1; i >= 0; i--)
     {
         int r = rnd.Next(i);
         int tc = card[r];
         card[r] = card[i];
         // Create a new alias, if the card is not face up
         CardIdentity ci = CardIdentity.Find(tc);
         if (group.FindByCardIdentity(ci) != null)
         {
             card[i] = tc; aliases[i] = ulong.MaxValue;
             ci.visible = true;
         }
         else
         {
             ci = new CardIdentity(Program.Game.GenerateCardId());
             ci.mySecret = ci.alias = true;
             ci.key = ((ulong)Crypto.PositiveRandom()) << 32 | (uint)tc;
             card[i] = ci.id; aliases[i] = Crypto.ModExp(ci.key);
             ci.visible = false;
         }
         // Give a random position to the card
         // TODO: I don't think this shuffling algorithm generates all possibilities equiprobably
         group.myShufflePos[i] = (short)Crypto.Random(group.Count);
     }
     // Send the results
     Program.Client.Rpc.CreateAlias(card, aliases);
     Program.Client.Rpc.Shuffled(group, card, group.myShufflePos);
 }
开发者ID:kellyelton,项目名称:octgnwlobby,代码行数:46,代码来源:ClientHandler.cs


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