Exemplo n.º 1
0
        /// <summary>
        /// 保存一下卡牌数据
        /// </summary>
        ///1 21dian 2爆牌 3不要
        /// <param name="state"></param>
        /// <param name="isDouble"></param>
        public void SaveList(int state, bool isDouble)
        {
            PlayerCardDto playerCardDto = new PlayerCardDto();

            playerCardDto.CardList.AddRange(player.CardList);
            playerCardDto.CardState = state;
            playerCardDto.Weight    = CardWeight21.GetWeight(player.CardList);
            playerCardDto.isDouble  = isDouble;
            player.SpliteCardListList.Add(playerCardDto);
        }
Exemplo n.º 2
0
        public string getPlayerCardType()
        {
            string playerCardType = "";

            if (player.CardList.Count == 2)
            {
            }
            if (player.CardList.Count == 2 && player.CardList[0].Weight == player.CardList[1].Weight)//对子
            {
                if (player.CardList[0].Weight == 1)
                {
                    playerCardType += "AA";
                }
                else if (player.CardList[0].Weight >= 10)
                {
                    playerCardType += "TT";
                }
                else
                {
                    playerCardType += player.CardList[0].Weight.ToString();
                    playerCardType += player.CardList[0].Weight.ToString();
                }
            }
            else if (isContainA(player.CardList))
            {
                int otherWeight = 0;
                foreach (CardDto c in player.CardList)
                {
                    otherWeight += c.Weight;
                }
                otherWeight -= 1;
                if (otherWeight <= 9)
                {
                    playerCardType += "A";
                    playerCardType += otherWeight.ToString();
                }
                else
                {
                    playerCardType += "H";
                    playerCardType += CardWeight21.GetWeight(player.CardList).ToString();
                }
            }
            else
            {
                playerCardType += "H";
                playerCardType += CardWeight21.GetWeight(player.CardList).ToString();
            }
            return(playerCardType);
        }
Exemplo n.º 3
0
 public void TestInitPlayerCards()
 {
     DealerCardList = new List <CardDto>();
     //庄家和闲家各发两张牌
     //闲家
     for (int i = 0; i < 2; i++)
     {
         string  cardName = CardColor.GetString(1) + CardWeight21.GetString(1);
         CardDto card     = new CardDto(cardName, 1, 1);
         player.Add(card);
     }
     //庄家
     for (int i = 0; i < 2; i++)
     {
         CardDto card = libraryModel.Deal();
         DealerCardList.Add(card);
     }
 }
Exemplo n.º 4
0
 private void create(int CardsNum)
 {
     CardQueue = new Queue <Card>();
     while (CardsNum > 0)
     {
         //创建普通的牌
         for (int color = CardColor.CLUB; color <= CardColor.SQUARE; color++)
         {
             for (int weight = CardWeight21.ONE; weight <= CardWeight21.KING; weight++)
             {
                 string cardName = CardColor.GetString(color) + CardWeight21.GetString(weight);
                 Card   card     = new Card(cardName, color, weight);
                 //添加到 CardQueue  里面
                 CardQueue.Enqueue(card);
             }
         }
         CardsNum--;
     }
 }
Exemplo n.º 5
0
 public int GetDealerWeight()
 {
     return(CardWeight21.GetWeight(DealerCardList));
 }
Exemplo n.º 6
0
 public int GetPlayerWeight()
 {
     return(CardWeight21.GetWeight(player.CardList));
 }
Exemplo n.º 7
0
 public bool isPlayer21()
 {
     return(CardWeight21.GetWeight(player.CardList) == 21);
 }