Ejemplo n.º 1
0
        private bool CheckRule(RoomInfo room_info, long uid, List <byte> cards)
        {
            if (room_info.game.IsMetallic())
            {
                //千变双扣
                var cur_results = TwillLogic.CheckCombines(cards);
                if (room_info.discard_info.pre_discard_uid == uid && cur_results.Any())
                {
                    return(true);
                }

                var pre_results = TwillLogic.CheckCombines(room_info.discard_info.pre_discard_cards);
                if (!pre_results.Any() && cur_results.Any())
                {
                    return(true);
                }


                if (pre_results.Any() && cur_results.Any())
                {
                    foreach (var pre_result in pre_results)
                    {
                        foreach (var cur_result in cur_results)
                        {
                            if (pre_result < cur_result)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            else
            {
                //传统双扣
                var cur_result = TwillLogic.CheckCombine(cards);
                if (room_info.discard_info.pre_discard_uid == uid && cur_result != null)
                {
                    return(true);
                }

                var pre_result = TwillLogic.CheckCombine(room_info.discard_info.pre_discard_cards);
                if (pre_result == null && cur_result != null)
                {
                    return(true);
                }

                if (pre_result != null && cur_result != null)
                {
                    if (pre_result < cur_result)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 选可以出的牌
        /// </summary>
        /// <param name="cards"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public static List <byte> ChooseCard(Games game_type, List <byte> cards, List <byte> pre_discard_cards, bool isPartner = false)
        {
            if (pre_discard_cards == null)
            {
                return(ChooseCard(game_type, cards));
            }

            List <CombineResult> results = null;

            if (game_type.IsMetallic())
            {
                results = TwillLogic.CheckCombines(pre_discard_cards);
            }
            else
            {
                results = new List <CombineResult>()
                {
                    TwillLogic.CheckCombine(pre_discard_cards)
                };
            }

            foreach (var result in results)
            {
                var hand_cards       = cards.ConvertToNumber();
                var hand_cards_clone = hand_cards.Clone();

                List <CardEnum> combine_cards = null;
                if (result.combine != Combine.Bomb)
                {
                    var bombs = RemoveBombs(hand_cards);                                //移除炸弹
                    combine_cards = FindCombine(game_type, hand_cards, result);         //获取符合条件牌组
                    if (combine_cards != null)
                    {
                        return(GetCards(cards, hand_cards_clone, combine_cards));        //转换为具体的牌
                    }
                }

                //不对对家使用炸弹
                if (isPartner)
                {
                    return(null);
                }

                //找炸弹
                combine_cards = FindBomb(game_type, hand_cards_clone, result);
                return(GetCards(cards, hand_cards_clone, combine_cards));    //转换为具体的牌
            }

            return(null);
        }
Ejemplo n.º 3
0
 private void SetBombLog(RoomInfo room_info)
 {
     if (room_info.game.IsMetallic())
     {
         var results = TwillLogic.CheckCombines(room_info.discard_info.pre_discard_cards);
         foreach (var result in results)
         {
             if (result.combine == Combine.Bomb)
             {
                 var player = room_info.GetPlayer(room_info.discard_info.pre_discard_uid);
                 player.AddBombLog(result.star);
             }
         }
     }
     else
     {
         var result = TwillLogic.CheckCombine(room_info.discard_info.pre_discard_cards);
         if (result.combine == Combine.Bomb)
         {
             var player = room_info.GetPlayer(room_info.discard_info.pre_discard_uid);
             player.AddBombLog(result.star);
         }
     }
 }