Ejemplo n.º 1
0
        /// <summary>
        /// Returns the value of the specified character's given skill.
        /// </summary>
        /// <returns>Returns 0 if character or skills are null.</returns>
        public int GetSkill(Character character, Globals.SkillType skill)
        {
            if (character == null || !AreSkillsSet(character))
            {
                return(0);
            }

            return((int)typeof(SkillSheet).GetProperty(skill.ToString()).GetValue(character.Skills));
        }
Ejemplo n.º 2
0
        public async Task <string> GetSkillRollAsync(IUser user, Globals.SkillType skillToRoll)
        {
            var character = await _charService.GetCharacterAsync(user.Id);

            if (character == null)
            {
                return(String.Format(Messages.ERR_CHAR_NOT_FOUND, user.Mention));
            }

            if (!_specService.IsSpecialSet(character))
            {
                return(String.Format(Messages.ERR_SPECIAL_NOT_FOUND, user.Mention));
            }

            if (!_skillsService.AreSkillsSet(character))
            {
                return(String.Format(Messages.ERR_SKILLS_NOT_FOUND, user.Mention));
            }

            return(GetRollMessage(character.Name, skillToRoll.ToString(), GetRollResult(skillToRoll, character)));
        }
Ejemplo n.º 3
0
        public async Task CheckSkill(IUser user, Globals.SkillType skill, int minimum)
        {
            var character = await _charService.GetCharacterAsync(user.Id);

            if (character == null)
            {
                await ReplyAsync(String.Format(Messages.ERR_CHAR_NOT_FOUND, user.Username));

                return;
            }
            if (!_skillsService.AreSkillsSet(character))
            {
                await ReplyAsync(String.Format(Messages.ERR_SKILLS_NOT_FOUND, user.Username));

                return;
            }

            int skillValue = _skillsService.GetSkill(character, skill);

            await ReplyAsync(GetCheckMessage(character.Name, skill.ToString(), skillValue, minimum));
        }
Ejemplo n.º 4
0
        public double GetRollResult(Globals.SkillType attribute, Character character)
        {
            var charSkills  = character.Skills;
            var charSpecial = character.Special;

            // match given attribute string to property in character
            int attributeValue = 0;
            int rng            = 0;

            attributeValue = _skillsService.GetSkill(character, attribute);
            rng            = _rand.Next(1, 101);

            // affects odds by the percentage of LUCK_INFLUENCE for each point of luck above or below 5.
            // i.e. if you have 6 luck, and LUCK_INFLUENCE == 5, then now your odds are multiplied by 0.95,
            // which is a good thing.
            int    luckDifference = charSpecial.Luck - 5;
            double luckMultiplier = 1.0 - (luckDifference * (LUCK_INFLUENCE / 100.0));

            double finalResult;

            if (LUCK_INFLUENCE_ENABLED)
            {
                finalResult = rng * luckMultiplier;
            }
            else
            {
                finalResult = rng;
            }

            // compares your roll with your skills, and how much better you did than the bare minimum
            double resultPercent = (attributeValue - finalResult) / attributeValue;

            // make it pretty for chat
            resultPercent = Math.Round(resultPercent * 100.0, 1);

            return(resultPercent);
        }
Ejemplo n.º 5
0
 public async Task RollSkill(Globals.SkillType skill)
 {
     await ReplyAsync($"{await _rollService.GetSkillRollAsync(Context.User, skill)} ({Context.User.Mention})");
 }