Beispiel #1
0
 /// <summary>
 /// The constructor for CardSprite takes a card and a rectangle
 /// </summary>
 /// <param name="card">The card to be grapically represented</param>
 /// <param name="rect">The rectangle is used to specify the size of the graphical card</param>
 public CardSprite(Card card, Rectangle rect)
 {
     Contract.Requires(card != null);
     this.Card = card;
     this.Rect = rect;
     Color = Color.White;
 }
Beispiel #2
0
 public void PlaceCard(Player player, Card card)
 {
     Contract.Requires(player != null && card != null && !Pile.ContainsKey(player));
     if(FirstCard == null) FirstCard = card;
     CardsPlayed.Add(player, card);
     this.UpdatePile();
 }
 public void DealCard(
     PirateClient pclient,
     Player receiver,
     Card card
 )
 {
     PirateClientCommands.DealCard(pclient, receiver, card);
     // TODO: add assertions to method PirateClientCommandsTest.DealCard(PirateClient, Player, Card)
 }
        /// <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);
        }
 public void PlayCard(PirateClient pclient, Card card)
 {
     PirateClientCommands.PlayCard(pclient, card);
     // TODO: add assertions to method PirateClientCommandsTest.PlayCard(PirateClient, Card)
 }
 /// <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);
 }
Beispiel #7
0
 public bool SameSuit(Card card)
 {
     Contract.Requires(card != null);
     return Suit == card.Suit;
 }
Beispiel #8
0
 public bool HigherThan(Card card)
 {
     Contract.Requires(card != null);
     if(Suit == Suit.Spades && card.Suit != Suit) return true;
     if(Suit == card.Suit && Value > card.Value) return true;
     return false;
 }
Beispiel #9
0
 /// <summary>
 /// This player has played this card
 /// </summary>
 /// <param name="player">The player</param>
 /// <param name="card">The card</param>
 public void PlayCard(Player player, Card card)
 {
     Contract.Requires(player != null && card != null && player.HasCard(card));
     BoardCards.PlaceCard(player, card);
     if(PileDone) {
         this.NextPile();
     } else {
        this.NextPlayer();
     }
 }
Beispiel #10
0
 /// <summary>
 /// When a card has been played.
 /// </summary>
 /// <param name="card">The card played.</param>
 private void OnCardPlayed(Card card)
 {
     PirateClientCommands.PlayCard(this, card);
 }
Beispiel #11
0
 /// <summary>
 /// When a card has been dealt.
 /// </summary>
 /// <param name="p">Receiving player.</param>
 /// <param name="c">Card dealt.</param>
 private void OnCardDealt(Player p, Card c)
 {
     PirateClientCommands.DealCard(this, p, c);
 }