Beispiel #1
0
 /// <summary>
 /// 改变出牌者,被管住了
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="cardsType"></param>
 /// <param name="cardsLenght"></param>
 /// <param name="cardsWeight"></param>
 public void ChangeBiggestId(int userId, CardsType cardsType, int cardsLenght, CardWeight cardsWeight)
 {
     this.currentBiggsetId = userId;
     this.lastCardsType    = cardsType;
     this.lastCardsLength  = cardsLenght;
     this.lastCardsWeight  = cardsWeight;
 }
Beispiel #2
0
        /// <summary>
        /// 顺子
        /// </summary>
        /// <param name="cards"></param>
        /// <returns></returns>
        public static bool IsStraight(List <Card> cards)
        {
            // 最多只能从3连到A。刚好12张。并且不能小于5张牌。
            if (cards.Count < 5 || cards.Count > 12)
            {
                return(false);
            }

            for (int i = 0; i < cards.Count - 1; i++)
            {
                CardWeight w = cards[i].Weight;

                // 因为是升序,所以前一张权重刚好比后一张多一
                if (cards[i + 1].Weight - w != 1)
                {
                    return(false);
                }

                if (w > CardWeight.A || cards[i + 1].Weight > CardWeight.A)
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #3
0
 private void Init()
 {
     currentUserId    = -1;
     currentBiggsetId = -1;
     lastCardsType    = CardsType.None;
     lastCardsLength  = 0;
     lastCardsWeight  = 0;
 }
Beispiel #4
0
        /// <summary>
        /// 开始出牌   设置完了地主之后 发了底牌就该出牌了
        /// </summary>
        /// <param name="userId"></param>
        public void Start(int userId)
        {
            this.currentUserId    = userId;
            this.currentBiggsetId = userId;

            lastCardsType   = CardsType.None;
            lastCardsLength = 0;
            lastCardsWeight = 0;
        }
 /// <summary>
 /// 构造函数
 /// 花色,牌权值 设定后不能修改
 /// </summary>
 /// <param name="name">牌名</param>
 /// <param name="color">花色</param>
 /// <param name="weight">权重</param>
 /// /// <param name="belongTo">归属</param>
 public BaseCard(string name, int id, CardColors color, CardWeight weight, CardBelongTo belongTo, CardDisplay cardDisplay)
 {
     this.cardName     = name;
     this.CardId       = id;
     this.cardColor    = color;
     this.cardWeight   = weight;
     this.cardBelongTo = belongTo;
     this.cardDisplay  = cardDisplay;
 }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="cardDtos">所出的牌</param>
 public DealDto(List <CardDto> cardDtos, int uid)
 {
     this.Uid       = uid;
     this.Cards     = cardDtos;
     this.Length    = cardDtos.Count;
     this.Type      = CardType.GetType(cardDtos);
     this.Weight    = CardWeight.GetWeight(cardDtos, this.Type);
     this.IsRegular = (this.Type != CardType.NONE);
 }
Beispiel #7
0
 public DealDto(List <CardDto> cardList, int uid)
 {
     this.selectCardList = cardList;
     this.Length         = cardList.Count;
     this.Type           = CardType.GetCardType(cardList);
     this.Weight         = CardWeight.GetWeight(cardList, this.Type);
     this.UserId         = uid;
     this.IsRegular      = (this.Type != CardType.NONE);
     this.RemainCardList = new List <CardDto>();
 }
Beispiel #8
0
 public DealDto(List <CardDto> cardList, int userID)
 {
     this.selectCardList = cardList;
     this.length         = cardList.Count;
     this.type           = CardType.GetCardType(cardList);
     this.weight         = CardWeight.GetWeight(cardList, this.type);
     this.userId         = userID;
     this.isRegular      = (this.type != CardType.NONE);
     this.remainCardList = new List <CardDto>();
 }
 public int GetCardCount(CardWeight weight)
 {
     if (weightCountDict.TryGetValue((int)(weight), out int count))
     {
         return(count);
     }
     else
     {
         return(0);
     }
 }
Beispiel #10
0
        public void Set(int userId, List <CardDto> cards)
        {
            this.userId    = userId;
            this.cardsList = cards;
            var typeWeight = cardsList.GetCardsTypeWeight();

            this.type    = typeWeight.type;
            this.weight  = typeWeight.weight;
            this.length  = cardsList.Count;
            this.isLeagl = this.type != CardsType.None;
            isBiggest    = false;
        }
Beispiel #11
0
        /// <summary>
        /// 创建牌
        /// </summary>
        private void create()
        {
            cardDtos = new Queue <CardDto>();
            for (int color = CardColor.CLUE; color <= CardColor.SQUARE; color++)
            {
                for (int weight = CardWeight.THREE; weight <= CardWeight.TWO; weight++)
                {
                    string  cardName = CardColor.GetString(color) + CardWeight.GetString(weight);
                    CardDto cardDto  = new CardDto(color, weight, cardName);
                    this.cardDtos.Enqueue(cardDto);
                }
            }
            //大王小王
            CardDto sJoker = new CardDto(CardColor.NONE, CardWeight.SJOKER, "SJoker");
            CardDto lJoker = new CardDto(CardColor.NONE, CardWeight.LJOKER, "LJoker");

            this.cardDtos.Enqueue(sJoker);
            this.cardDtos.Enqueue(lJoker);
        }
Beispiel #12
0
        private void Creat()
        {
            CardQueue = new Queue <CardDto>();
            //创建普通的牌
            for (int color = CardColor.SPADE; color <= CardColor.SQUARE; color++)
            {
                for (int weight = CardWeight.THREE; weight <= CardWeight.TWO; weight++)
                {
                    string  cardName = CardColor.GetColor(color) + CardWeight.GetWeight(weight);
                    CardDto dto      = new CardDto(cardName, color, weight);
                    CardQueue.Enqueue(dto);
                }
            }
            CardDto sJoker = new CardDto("SJoker", CardColor.NONE, CardWeight.SJOKER);
            CardDto lJoker = new CardDto("LJoker", CardColor.NONE, CardWeight.LJOKER);

            CardQueue.Enqueue(sJoker);
            CardQueue.Enqueue(lJoker);
        }
Beispiel #13
0
        private void Create()
        {
            cardQueue = new Queue <CardDto>();
            //创建普通的牌
            for (int color = CardColor.CLUB; color <= CardColor.SQUARE; color++)
            {
                for (int weight = CardWeight.THREE; weight <= CardWeight.TWO; weight++)
                {
                    string  cardName = CardColor.GetString(color) + CardWeight.GetString(weight);
                    CardDto card     = new CardDto(cardName, color, weight);
                    //添加到CardQuene里面
                    cardQueue.Enqueue(card);
                }
            }
            CardDto sJoker = new CardDto("SJoker", CardColor.NONE, CardWeight.SJOKER);
            CardDto lJoker = new CardDto("LJoker", CardColor.NONE, CardWeight.LJOKER);

            cardQueue.Enqueue(sJoker);
            cardQueue.Enqueue(lJoker);
        }
Beispiel #14
0
        public void Create()
        {
            CardQueue = new Queue <CardDto>();

            for (int suit = CardSuit.CLUB; suit <= CardSuit.DIAMOND; suit++)
            {
                //create 3 to 2 ,no jocker
                for (int weight = CardWeight.THREE; weight <= CardWeight.TWO; weight++)
                {
                    string cardName = CardSuit.GetString(suit) + CardWeight.GetString(weight);

                    CardDto card = new CardDto(cardName, suit, weight);
                    CardQueue.Enqueue(card);
                }
            }
            CardDto sJoker = new CardDto("SJoker", CardSuit.NONE, CardWeight.SJOKER);
            CardDto lJoker = new CardDto("LJoker", CardSuit.NONE, CardWeight.LJOKER);

            CardQueue.Enqueue(sJoker);
            CardQueue.Enqueue(lJoker);
        }
Beispiel #15
0
 /// <summary>
 /// 是否是顺子
 /// </summary>
 /// <param name="cards"></param>
 /// <returns></returns>
 public static bool IsStraight(List <CardDto> cards)
 {
     if (cards.Count < 5 || cards.Count > 12)
     {
         return(false);
     }
     for (int i = 0; i < cards.Count - 1; i++)
     {
         CardWeight tempWeight = cards[i].Weight;
         if (cards[i + 1].Weight - tempWeight != 1)
         {
             return(false);
         }
         //顺子不能超过a
         if (tempWeight > CardWeight.One || cards[i + 1].Weight > CardWeight.One)
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #16
0
 /// <summary>
 /// 是否是王(小王,大王)
 /// </summary>
 /// <param name="weight"></param>
 /// <returns></returns>
 public static bool IsJoker(CardWeight weight)
 {
     return(weight >= CardWeight.SJoker);
 }
Beispiel #17
0
 public CardDto(string name, CardColor color, CardWeight weight)
 {
     this.name   = name;
     this.color  = color;
     this.weight = weight;
 }