Ejemplo n.º 1
0
        public void ReturnRuleNothingWhenEmpty()
        {
            var ruleSet = new RuleSet();
            var result  = ruleSet.BestRule(new int[] { 1, 2, 3 });

            Assert.IsNull(result);
        }
Ejemplo n.º 2
0
        public void ReturnOnlyRuleIfMatchFound()
        {
            var ruleSet = new RuleSet();

            ruleSet.Add(new SingleDieRule(1, 100));
            var result = ruleSet.BestRule(new int[] { 1, 2, 3 });

            Assert.IsInstanceOf <SingleDieRule>(result);
        }
Ejemplo n.º 3
0
        public int Score(int[] roles)
        {
            int score         = 0;
            var remainingDice = new List <int>(roles);
            var bestRule      = _ruleSet.BestRule(remainingDice.ToArray());

            while (bestRule != null)
            {
                var result = bestRule.Eval(remainingDice.ToArray());
                foreach (var die in result.DiceUsed)
                {
                    remainingDice.Remove(die);
                }
                score   += result.Score;
                bestRule = _ruleSet.BestRule(remainingDice.ToArray());
            }
            return(score);
        }