/// <summary> /// Deal card to player. /// </summary> /// <param name="pclient">The client.</param> /// <param name="receiver">Receiving player.</param> /// <param name="card">Card dealt.</param> public static void DealCard(PirateClient pclient, Player receiver, Card card) { Contract.Requires(pclient != null && receiver != null && card != null); var body = PirateMessage.ConstructBody(PirateMessage.ConstructPlayerName(receiver.Name), card.ToString()); var msg = new PirateMessage(PirateMessageHead.Xcrd, body); if(!pclient.VirtualPlayer) Console.WriteLine(pclient.Name + ": Dealing " + card.ToShortString() + " to " + receiver.Name); pclient.SendMessage(msg); }
/// <summary> /// Verify connection with host. /// </summary> /// <param name="pclient">The client.</param> /// <param name="data">Data received from host.</param> public static void VerifyConnection(PirateClient pclient, PirateMessage data) { Contract.Requires(pclient != null && data != null && data.Head == PirateMessageHead.Init); var msg = new PirateMessage(PirateMessageHead.Verf, data.Body); pclient.SendMessage(msg); }
/// <summary> /// Set the bet. /// </summary> /// <param name="pclient">The client.</param> /// <param name="bet">Bet to use.</param> public static void SetBet(PirateClient pclient, int bet) { Contract.Requires(pclient != null & bet >= 0); var msg = new PirateMessage(PirateMessageHead.Pbet, bet.ToString()); pclient.SendMessage(msg); }
/// <summary> /// Send player information. /// </summary> /// <param name="pclient">The client.</param> public static void SendPlayerInfo(PirateClient pclient) { Contract.Requires(pclient != null); var msg = new PirateMessage(PirateMessageHead.Pnfo, pclient.ToString()); pclient.SendMessage(msg); }
/// <summary> /// Play a card. /// </summary> /// <param name="pclient">The client.</param> /// <param name="card">Card to be played.</param> public static void PlayCard(PirateClient pclient, Card card) { Contract.Requires(pclient != null && card != null); var body = PirateMessage.ConstructBody(pclient.ToString(), card.ToString()); var msg = new PirateMessage(PirateMessageHead.Pcrd, body); pclient.SendMessage(msg); }
/// <summary> /// Initialize connection. /// </summary> /// <param name="pclient">The client.</param> public static void InitConnection(PirateClient pclient) { Contract.Requires(pclient != null); var msg = new PirateMessage(PirateMessageHead.Init, ""); pclient.SendMessage(msg); }