Exemple #1
0
        public static bool IsCardsMatch(IEnumerable <Card> cards, Desk desk)
        {
            var list   = cards.ToListAndSort();
            var player = desk.CurrentPlayer;

            if (list.Count == 0)
            {
                return(false);
            }

            var lastCardList = desk.LastCards?.ToList();

            foreach (var rule in RulesList)
            {
                if (desk.CurrentRule == null || desk.CurrentRule == rule ||
                    rule is RuleBomb && !(desk.CurrentRule is RuleRocket) || rule is RuleRocket)
                {
                    if (rule.IsMatch(list.ExtractCardGroups(), lastCardList?.ExtractCardGroups()))
                    {
                        var result = player.Cards.IsTargetVaildAndRemove(list);
                        if (result.isVaild)
                        {
                            desk.LastSuccessfulSender = desk.CurrentPlayer;
                            desk.CurrentRule          = rule;
                            desk.LastCards            = list;
                            player.Cards = result.result;
                            Multiplier.Multiplie(desk, rule);
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }