Example #1
0
 public void ClearPot()
 {
     this.CardPile.Clear();
        potList.Clear();
        highestCard = null;
        highestPlayer = null;
 }
Example #2
0
 public void AddPot(SpadesCard c, player p)
 {
     this.AddCard(c);
        SpadesPot newPot = new SpadesPot();
        newPot.card = c;
        newPot.potter = p;
        setHighest(c,p);
        potList.Add(newPot);
 }
Example #3
0
        public void setHighest(SpadesCard c,player p)
        {
            // just set this as highest
               if (highestCard == null)
               {
               highestPlayer = p;
               highestCard = c;
               }
               else
               {
               // if already set highest check with it

               // if same suit then check value
               if (c.Suit == highestCard.Suit)
               {
                   // compare the values
                   if (c.Rank == CardRank.Ace)
                   {
                       highestCard = c;
                       highestPlayer = p;
                       return;
                   }
                   else if (c.Rank > highestCard.Rank && highestCard.Rank != CardRank.Ace)
                   {
                       highestCard = c;
                       highestPlayer = p;
                       return;
                   }
               }
               else
               {
                   // if not same suit check if spades has been played
                   if (c.Suit == CardSuit.Spades)
                   {
                       highestPlayer = p;
                       highestCard = c;
                       return;
                   }
               }

               }
        }
 SpadesRoundController(player p)
 {
 }
Example #5
0
        /// <summary>
        /// checks whether the card played by the player is valid or not in current scenario
        /// </summary>
        /// <param name="currentPlayer">The card player</param>
        /// <param name="playedCard">what card has the player chooosen to play </param>
        /// <param name="currentPot">pot of current running hand</param>
        /// <returns></returns>
        public static bool isValidCard(player currentPlayer,  SpadesCard playedCard, Pot currentPot)
        {
            // if pot is empty its the first card and is always valid
            if (currentPot.CardPile.Count == 0)
            {
                return true;
            }
            else
            {
                // get 1st played card

                SpadesCard first = (SpadesCard)currentPot.CardPile[0];

                // check if player has the same suit to play
                if (hasSuit(first.Suit, currentPlayer.Hand))
                {
                    if (first.Suit == playedCard.Suit)
                    {

                        if (first.Suit != CardSuit.Spades && currentPot.highestCard.Suit == CardSuit.Spades)
                        {
                            return true;
                        }
                        else
                        {
                            // check its higher than the higest card in the pile
                            if (playedCard.Rank == CardRank.Ace) return true;
                            else
                            {
                                if (playedCard.Rank > currentPot.highestCard.Rank) return true;
                                else
                                {
                                    // check if he has higher card in this hand
                                    if (checkHandForHigherCard(currentPot.highestCard, currentPlayer.Hand))
                                    {
                                        // player has other higher card
                                        return false;
                                    }
                                    else
                                    {
                                        return true;
                                    }

                                }
                            }
                        }

                    }
                    else return false;
                }
                // check if he has spades to play
                else if (hasSuit(CardSuit.Spades, currentPlayer.Hand))
                {

                    if (checkHandForHigherCard(currentPot.highestCard, currentPlayer.Hand))
                    {

                        if (currentPot.highestCard.Suit != CardSuit.Spades && playedCard.Suit == CardSuit.Spades) return true;
                        if (playedCard.Rank == CardRank.Ace && playedCard.Suit == CardSuit.Spades) return true;
                        if ((playedCard.Rank > currentPot.highestCard.Rank) && ((currentPot.highestCard.Suit == CardSuit.Spades) && (playedCard.Suit == CardSuit.Spades))) return true;

                        return false;
                    }

                  // if no higher card play any thing
                  return true;

                }
                // if nothing play anyhitng
                else return true;

            }
        }
 SpadesRoundController(player p)
 {
 }
Example #7
0
        /// <summary>
        /// checks whether the card played by the player is valid or not in current scenario
        /// </summary>
        /// <param name="currentPlayer">The card player</param>
        /// <param name="playedCard">what card has the player chooosen to play </param>
        /// <param name="currentPot">pot of current running hand</param>
        /// <returns></returns>
        public static bool isValidCard(player currentPlayer, SpadesCard playedCard, Pot currentPot)
        {
            // if pot is empty its the first card and is always valid
            if (currentPot.CardPile.Count == 0)
            {
                return(true);
            }
            else
            {
                // get 1st played card



                SpadesCard first = (SpadesCard)currentPot.CardPile[0];

                // check if player has the same suit to play
                if (hasSuit(first.Suit, currentPlayer.Hand))
                {
                    if (first.Suit == playedCard.Suit)
                    {
                        if (first.Suit != CardSuit.Spades && currentPot.highestCard.Suit == CardSuit.Spades)
                        {
                            return(true);
                        }
                        else
                        {
                            // check its higher than the higest card in the pile
                            if (playedCard.Rank == CardRank.Ace)
                            {
                                return(true);
                            }
                            else
                            {
                                if (playedCard.Rank > currentPot.highestCard.Rank)
                                {
                                    return(true);
                                }
                                else
                                {
                                    // check if he has higher card in this hand
                                    if (checkHandForHigherCard(currentPot.highestCard, currentPlayer.Hand))
                                    {
                                        // player has other higher card
                                        return(false);
                                    }
                                    else
                                    {
                                        return(true);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                // check if he has spades to play
                else if (hasSuit(CardSuit.Spades, currentPlayer.Hand))
                {
                    if (checkHandForHigherCard(currentPot.highestCard, currentPlayer.Hand))
                    {
                        if (currentPot.highestCard.Suit != CardSuit.Spades && playedCard.Suit == CardSuit.Spades)
                        {
                            return(true);
                        }
                        if (playedCard.Rank == CardRank.Ace && playedCard.Suit == CardSuit.Spades)
                        {
                            return(true);
                        }
                        if ((playedCard.Rank > currentPot.highestCard.Rank) && ((currentPot.highestCard.Suit == CardSuit.Spades) && (playedCard.Suit == CardSuit.Spades)))
                        {
                            return(true);
                        }



                        return(false);
                    }



                    // if no higher card play any thing
                    return(true);
                }
                // if nothing play anyhitng
                else
                {
                    return(true);
                }
            }
        }