Example #1
0
        public IEnumerable <Skill> ApplySkillPointsAsRanks(
            IEnumerable <Skill> skills,
            HitPoints hitPoints,
            CreatureType creatureType,
            Dictionary <string, Ability> abilities,
            bool includeFirstHitDieBonus)
        {
            var points = GetTotalSkillPoints(creatureType, hitPoints.RoundedHitDiceQuantity, abilities[AbilityConstants.Intelligence], includeFirstHitDieBonus);
            var totalRanksAvailable = skills.Sum(s => s.RankCap - s.Ranks);

            if (points >= totalRanksAvailable)
            {
                return(MaxOutSkills(skills));
            }

            var skillsWithAvailableRanks = skills.Where(s => !s.RanksMaxedOut);
            var creatureSkills           = skillsWithAvailableRanks.Where(s => s.ClassSkill);
            var untrainedSkills          = skillsWithAvailableRanks.Where(s => !s.ClassSkill);

            while (points > 0)
            {
                var skill          = collectionsSelector.SelectRandomFrom(creatureSkills, untrainedSkills);
                var availableRanks = Math.Min(skill.RankCap - skill.Ranks, points);
                var rankRoll       = RollHelper.GetRollWithMostEvenDistribution(1, availableRanks);
                var ranks          = dice.Roll(rankRoll).AsSum();

                skill.Ranks += ranks;
                points      -= ranks;
            }

            return(skills);
        }
        public void RangeConstant(string constant, int quantity, int die, int multiplier = 1, int bonus = 0)
        {
            var lower = quantity * multiplier + bonus;
            var upper = quantity * die * multiplier + bonus;
            var roll  = RollHelper.GetRollWithFewestDice(lower, upper);

            Assert.That(constant, Is.EqualTo(roll));
        }
Example #3
0
        private void SetUpRoll(int lower, int upper, int result)
        {
            var mockPartial = new Mock <PartialRoll>();

            mockPartial.Setup(p => p.AsSum <int>()).Returns(result);
            var roll = RollHelper.GetRollWithMostEvenDistribution(lower, upper);

            mockDice.Setup(d => d.Roll(roll)).Returns(mockPartial.Object);
        }
Example #4
0
        public int GenerateFor(string itemType, string name)
        {
            if (itemType == ItemTypeConstants.Wand || itemType == ItemTypeConstants.Staff)
            {
                return(PercentileCharges());
            }

            if (name == WondrousItemConstants.DeckOfIllusions)
            {
                var isFullyCharged = percentileSelector.SelectFrom <bool>(TableNameConstants.Percentiles.Set.IsDeckOfIllusionsFullyCharged);

                if (isFullyCharged)
                {
                    name = WondrousItemConstants.DeckOfIllusions_Full;
                }
            }

            var result = rangeDataSelector.SelectFrom(TableNameConstants.Collections.Set.ChargeLimits, name);
            var roll   = RollHelper.GetRollWithMostEvenDistribution(result.Minimum, result.Maximum);

            return(dice.Roll(roll).AsSum());
        }