Exemplo n.º 1
0
        public static bool UseSkill(Skill skill, Entity entity, Difficulty difficulty)
        {
            int target = skill.Value + (int) difficulty
                + skill.ClassModifiers.Keys.Where(key => key == entity.Class).Sum(key => skill.ClassModifiers[key])
                + entity.SkillModifiers.Where(mod => mod.Modifying == skill.Name).Sum(mod => mod.Amount);

            switch(skill.PrimaryAttribute.ToLower())
            {
                case "strength":
                    target += Skill.AttributeModifier(entity.Strength);
                    break;
                case "dexterity":
                    target += Skill.AttributeModifier(entity.Dexterity);
                    break;
                case "cunning":
                    target += Skill.AttributeModifier(entity.Cunning);
                    break;
                case "willpower":
                    target += Skill.AttributeModifier(entity.Willpower);
                    break;
                case "magic":
                    target += Skill.AttributeModifier(entity.Magic);
                    break;
                case "constitution":
                    target += Skill.AttributeModifier(entity.Constitution);
                    break;
            }

            return RollDice(DiceType.D100) <= target;
        }
Exemplo n.º 2
0
        public static Skill FromSkillData(SkillData data)
        {
            var skill = new Skill
            {
                Name = data.Name,
                Value = 0
            };

            foreach (var key in data.ClassModifiers.Keys)
            {
                skill.ClassModifiers.Add(key, data.ClassModifiers[key]);
            }

            return skill;
        }