Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
 /// <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);
 }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
 /// <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);
 }
Ejemplo n.º 5
0
 /// <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);
 }
Ejemplo n.º 6
0
 /// <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);
 }