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


C# Guid.Condense方法代码示例

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


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

示例1: Reveal

 /// <summary>Reveal one card's identity</summary>
 /// <param name="card">The card, whose identity is revealed</param>
 /// <param name="revealed">Either the salted CardIdentity id (in the case of an alias), or the salted, condensed Card GUID.</param>
 /// <param name="guid"> </param>
 public void Reveal(Card card, ulong revealed, Guid guid)
 {
     // Save old id
     CardIdentity oldType = card.Type;
     // Check if the card is rightfully revealed
     if (!card.Type.Revealing)
         Program.Trace.TraceEvent(TraceEventType.Warning, EventIds.Event, "Someone tries to reveal a card which is not visible to everybody.");
     // Check if we can trust other clients
     if (!card.Type.MySecret)
     {
         if (guid != Guid.Empty && (uint)revealed != guid.Condense())
             Program.Trace.TraceEvent(TraceEventType.Warning, EventIds.Event, "[Reveal] Alias and id aren't the same. One client is buggy or tries to cheat.");
         if (Crypto.ModExp(revealed) != card.Type.Key)
             Program.Trace.TraceEvent(TraceEventType.Warning, EventIds.Event, "[Reveal] Card identity doesn't match. One client is buggy or tries to cheat.");
     }
     else
         card.Type.MySecret = false;
     // Reveal an alias
     if (guid == Guid.Empty)
     {
         // Find the new type
         CardIdentity newId = CardIdentity.Find((int)revealed);
         // HACK: it is unclear to me how the CardIdentity could not be found and newId ends up null
         // see this bug report: https://octgn.16bugs.com/projects/3602/bugs/192070
         // for now I'm just doing nothing (supposing that it means the type was already revealed).
         if (newId == null) { card.Reveal(); return; }
         // Possibly copy the model, if it was known and isn't anymore
         // (possible when the alias has beeen locally revealed)
         if (newId.Model == null) newId.Model = card.Type.Model;
         // Set the new type
         card.Type = newId;
         // Delete the old identity
         CardIdentity.Delete(oldType.Id);
         // Possibly reveal the alias further
         card.Reveal();
         // Raise a notification
         oldType.OnRevealed(newId);
     }
     // Reveal a card's type
     else if (card.Type.Model == null)
     {
         card.SetModel(Program.GameEngine.Definition.GetCardById(guid));
         // Raise a notification
         oldType.OnRevealed(oldType);
     }
 }
开发者ID:Kamalisk,项目名称:OCTGN,代码行数:50,代码来源:ClientHandler.cs

示例2: Reveal

 /// <summary>Reveal one card's identity</summary>
 /// <param name="card">The card, whose identity is revealed</param>
 /// <param name="revealed">Either the salted CardIdentity id (in the case of an alias), or the salted, condensed Card GUID.</param>
 /// <param name="id">If the revealed identity is a model, the non-condensed CardModel guid. Otherwise this parameter should be Guid.Empty.</param>
 public void Reveal(Card card, ulong revealed, Guid guid)
 {
     // Save old id
     CardIdentity oldType = card.Type;
     // Check if the card is rightfully revealed
     if (!card.Type.revealing)
         Program.Trace.TraceEvent(TraceEventType.Warning, EventIds.Event, "Someone tries to reveal a card which is not visible to everybody.");
     // Check if we can trust other clients
     if (!card.Type.mySecret)
     {
         if (guid != Guid.Empty && (uint)revealed != guid.Condense())
             Program.Trace.TraceEvent(TraceEventType.Warning, EventIds.Event, "[Reveal] Alias and id aren't the same. One client is buggy or tries to cheat.");
         if (Crypto.ModExp(revealed) != card.Type.key)
             Program.Trace.TraceEvent(TraceEventType.Warning, EventIds.Event, "[Reveal] Card identity doesn't match. One client is buggy or tries to cheat.");
     }
     else
         card.Type.mySecret = false;
     // Reveal an alias
     if (guid == Guid.Empty)
     {
         // Find the new type
         CardIdentity newId = CardIdentity.Find((int)revealed);
         // Possibly copy the model, if it was known and isn't anymore
         // (possible when the alias has beeen locally revealed)
         if (newId.model == null) newId.model = card.Type.model;
         // Set the new type
         card.Type = newId;
         // Delete the old identity
         CardIdentity.Delete(oldType.id);
         // Possibly reveal the alias further
         card.Reveal();
         // Raise a notification
         oldType.OnRevealed(newId);
     }
     // Reveal a card's type
     else if (card.Type.model == null)
     {
         card.SetModel(Database.GetCardById(guid));
         // Raise a notification
         oldType.OnRevealed(oldType);
     }
 }
开发者ID:kellyelton,项目名称:octgnwlobby,代码行数:46,代码来源:ClientHandler.cs


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