Example #1
0
        public static Roll RollDice(RollSpec spec)
        {
            var groupRolls =
                (from diceGroup in spec.DiceGroups
                 let results = rollDiceGroup(diceGroup)
                               let total = results.Sum()
                                           select new DiceGroupRoll {
                DiceGroup = diceGroup, Results = results, Total = total
            })
                .ToList();

            var grandTotal = groupRolls.Sum(g => g.Total);

            return(new Roll {
                Formula = spec.Formula, DiceGroupRolls = groupRolls, Total = grandTotal
            });
        }
Example #2
0
        public static Roll RollDice(RollSpec spec)
        {
            var groupRolls =
               (from diceGroup in spec.DiceGroups
                let results = rollDiceGroup(diceGroup)
                let total = results.Sum()
                select new DiceGroupRoll { DiceGroup = diceGroup, Results = results, Total = total })
               .ToList();

            var grandTotal = groupRolls.Sum(g => g.Total);

            return new Roll { Formula = spec.Formula, DiceGroupRolls = groupRolls, Total = grandTotal };
        }