本文整理汇总了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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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)
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}