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


C# Network.PirateMessage类代码示例

本文整理汇总了C#中PirateSpades.Network.PirateMessage的典型用法代码示例。如果您正苦于以下问题:C# PirateMessage类的具体用法?C# PirateMessage怎么用?C# PirateMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PirateMessage类属于PirateSpades.Network命名空间,在下文中一共展示了PirateMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DealCard

        /// <summary>
        /// Deal card.
        /// </summary>
        /// <param name="host">The host.</param>
        /// <param name="data">Data received from client.</param>
        public static void DealCard(PirateHost host, PirateMessage data)
        {
            Contract.Requires(host != null && data != null && data.Head == PirateMessageHead.Xcrd);
            var player = PirateMessage.GetPlayerName(data);
            if(player == null) {
                return;
            }

            var pclient = host.PlayerFromString(player);
            if(pclient == null) {
                return;
            }

            var card = Card.FromString(data.Body);
            if(card == null) {
                return;
            }

            pclient.GetCard(card);

            Console.WriteLine("Host: Sending card " + card.ToShortString() + " to " + pclient);

            var msg = new PirateMessage(PirateMessageHead.Xcrd, card.ToString());
            host.SendMessage(pclient, msg);

            if(host.Game.Round.CardsDealt == host.Game.Round.TotalCards) {
                RequestBets(host);
            }
        }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:34,代码来源:PirateHostCommands.cs

示例2: GetBytes366

 public void GetBytes366()
 {
     PirateMessage pirateMessage;
     byte[] bs;
     pirateMessage =
       new PirateMessage(PirateMessageHead.Fail, "\0\0\0\0\0\0\udc00\0\0\0\0");
     bs = this.GetBytes(pirateMessage);
     Assert.IsNotNull((object)bs);
     Assert.AreEqual<int>(21, bs.Length);
     Assert.AreEqual<byte>((byte)48, bs[0]);
     Assert.AreEqual<byte>((byte)48, bs[1]);
     Assert.AreEqual<byte>((byte)49, bs[2]);
     Assert.AreEqual<byte>((byte)55, bs[3]);
     Assert.AreEqual<byte>((byte)70, bs[4]);
     Assert.AreEqual<byte>((byte)65, bs[5]);
     Assert.AreEqual<byte>((byte)73, bs[6]);
     Assert.AreEqual<byte>((byte)76, bs[7]);
     Assert.AreEqual<byte>((byte)0, bs[8]);
     Assert.AreEqual<byte>((byte)0, bs[9]);
     Assert.AreEqual<byte>((byte)0, bs[10]);
     Assert.AreEqual<byte>((byte)0, bs[11]);
     Assert.AreEqual<byte>((byte)0, bs[12]);
     Assert.AreEqual<byte>((byte)0, bs[13]);
     Assert.AreEqual<byte>((byte)239, bs[14]);
     Assert.AreEqual<byte>((byte)191, bs[15]);
     Assert.AreEqual<byte>((byte)189, bs[16]);
     Assert.AreEqual<byte>((byte)0, bs[17]);
     Assert.AreEqual<byte>((byte)0, bs[18]);
     Assert.AreEqual<byte>((byte)0, bs[19]);
     Assert.AreEqual<byte>((byte)0, bs[20]);
     Assert.IsNotNull((object)pirateMessage);
     Assert.AreEqual<PirateMessageHead>(PirateMessageHead.Fail, pirateMessage.Head);
     Assert.AreEqual<string>("\0\0\0\0\0\0\udc00\0\0\0\0", pirateMessage.Body);
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:34,代码来源:PirateMessageTest.GetBytes.g.cs

示例3: GetPlayerName816

 public void GetPlayerName816()
 {
     PirateMessage pirateMessage;
     string s;
     pirateMessage = new PirateMessage(PirateMessageHead.Fail, "player_name: 000");
     s = this.GetPlayerName(pirateMessage);
     Assert.AreEqual<string>("000", s);
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:8,代码来源:PirateMessageTest.GetPlayerNames.g.cs

示例4: GetGameName787

 public void GetGameName787()
 {
     PirateMessage pirateMessage;
     string s;
     pirateMessage = new PirateMessage(PirateMessageHead.Fail, "game_name: A");
     s = this.GetGameName(pirateMessage);
     Assert.AreEqual<string>("A", s);
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:8,代码来源:PirateMessageTest.GetGameName.g.cs

示例5: GetWinner103

 public void GetWinner103()
 {
     PirateMessage pirateMessage;
     string s;
     pirateMessage = new PirateMessage(PirateMessageHead.Fail, "winning_player: a0");
     s = this.GetWinner(pirateMessage);
     Assert.AreEqual<string>("a0", s);
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:8,代码来源:PirateMessageTest.GetWinner.g.cs

示例6: GetDealer695

 public void GetDealer695()
 {
     PirateMessage pirateMessage;
     string s;
     pirateMessage = new PirateMessage(PirateMessageHead.Fail, "dealer: 00000000");
     s = this.GetDealer(pirateMessage);
     Assert.AreEqual<string>("00000000", s);
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:8,代码来源:PirateMessageTest.GetDealer.g.cs

示例7: GetRound92

 public void GetRound92()
 {
     PirateMessage pirateMessage;
     int i;
     pirateMessage = new PirateMessage(PirateMessageHead.Fail, "round: 8");
     i = this.GetRound(pirateMessage);
     Assert.AreEqual<int>(8, i);
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:8,代码来源:PirateMessageTest.GetRound.g.cs

示例8: GetPlayersInGame777

 public void GetPlayersInGame777()
 {
     PirateMessage pirateMessage;
     int i;
     pirateMessage = new PirateMessage(PirateMessageHead.Fail, "players_ingame: 0");
     i = this.GetPlayersInGame(pirateMessage);
     Assert.AreEqual<int>(0, i);
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:8,代码来源:PirateMessageTest.GetPlayersInGame.g.cs

示例9: GetStartingPlayer6001

 public void GetStartingPlayer6001()
 {
     PirateMessage pirateMessage;
     string s;
     pirateMessage = new PirateMessage(PirateMessageHead.Fail, "starting_player: 00");
     s = this.GetStartingPlayer(pirateMessage);
     Assert.AreEqual<string>("00", s);
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:8,代码来源:PirateMessageTest.GetStartingPlayer.g.cs

示例10: GetWinner424

 public void GetWinner424()
 {
     PirateMessage pirateMessage;
     string s;
     pirateMessage =
       new PirateMessage(PirateMessageHead.Fail, "winning_player: 0\u00f6\u803c");
     s = this.GetWinner(pirateMessage);
     Assert.AreEqual<string>("", s);
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:9,代码来源:PirateMessageTest.GetWinner.g.cs

示例11: InitConnection

 public void InitConnection(
     PirateHost host,
     PirateClient pclient,
     PirateMessage data
 )
 {
     PirateHostCommands.InitConnection(host, pclient, data);
     // TODO: add assertions to method PirateHostCommandsTest.InitConnection(PirateHost, PirateClient, PirateMessage)
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:9,代码来源:PirateHostCommandsTest.cs

示例12: GetPlayerNames138

 public void GetPlayerNames138()
 {
     PirateMessage pirateMessage;
     HashSet<string> hashSet;
     pirateMessage = new PirateMessage(PirateMessageHead.Fail, "");
     hashSet = this.GetPlayerNames(pirateMessage);
     Assert.IsNotNull((object)hashSet);
     Assert.AreEqual<int>(0, hashSet.Count);
     Assert.IsNotNull(hashSet.Comparer);
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:10,代码来源:PirateMessageTest.GetPlayerNames.g.cs

示例13: GetPlayerScores544

 public void GetPlayerScores544()
 {
     PirateMessage pirateMessage;
     Dictionary<string, int> dictionary;
     pirateMessage = new PirateMessage(PirateMessageHead.Fail, new string('\0', 14));
     dictionary = this.GetPlayerScores(pirateMessage);
     Assert.IsNotNull((object)dictionary);
     Assert.IsNotNull(dictionary.Comparer);
     Assert.AreEqual<int>(0, dictionary.Count);
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:10,代码来源:PirateMessageTest.GetPlayerScores.g.cs

示例14: GetPlayerScores440

 public void GetPlayerScores440()
 {
     PirateMessage pirateMessage;
     Dictionary<string, int> dictionary;
     pirateMessage = new PirateMessage(PirateMessageHead.Fail, "player_score: a;-0");
     dictionary = this.GetPlayerScores(pirateMessage);
     Assert.IsNotNull((object)dictionary);
     Assert.IsNotNull(dictionary.Comparer);
     Assert.AreEqual<int>(1, dictionary.Count);
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:10,代码来源:PirateMessageTest.GetPlayerScores.g.cs

示例15: GetPlayerTricks393

 public void GetPlayerTricks393()
 {
     PirateMessage pirateMessage;
     Dictionary<string, int> dictionary;
     pirateMessage = new PirateMessage(PirateMessageHead.Fail, "player_tricks: Z");
     dictionary = this.GetPlayerTricks(pirateMessage);
     Assert.IsNotNull((object)dictionary);
     Assert.IsNotNull(dictionary.Comparer);
     Assert.AreEqual<int>(0, dictionary.Count);
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:10,代码来源:PirateMessageTest.GetPlayerTricks.g.cs


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