コード例 #1
0
ファイル: Deck.cs プロジェクト: Avtomatov76/a-game-of-fool
 public void DealCards(FoolHand fh, CompHand ch) //dealing cards, one at a time to each player: 6 cards each
 {
     for (int i = 0; i < 6; i++)
     {
         fh.AddCard(Deal());
         ch.AddCard(Deal());
     }
 }
コード例 #2
0
        //attack with any VALUE displayed within the PlayHand

        public CompHand CompSortCards(CompHand ch, Card tc)
        {
            List <Card> cards2 = new List <Card>(); //helper list for sorting trump cards
            CompHand    ch1    = new CompHand();

            cards.Sort();

            for (int i = 0; i < ch.NumCards; i++) //placing all Aces to the bottom of the hand
            {
                Card c = cards[0];
                if (c.Value == 1)
                {
                    cards.Remove(c);
                    cards.Add(c);
                }
            }

            for (int i = 0; i < cards.Count; i++)
            {
                Card c = cards[i];
                if (!c.HasMatchingSuit(tc))
                {
                    cards2.Add(c);
                }
            }

            for (int i = 0; i < cards.Count; i++)
            {
                Card c = cards[i];
                if (c.HasMatchingSuit(tc))
                {
                    cards2.Add(c);
                }
            }

            cards.Clear();

            for (int i = 0; i < cards2.Count; i++)
            {
                Card c = cards2[i];
                cards.Add(c);
                ch1.AddCard(c);
            }

            return(ch1);
        }