public SkillMod(Skill skill, string addition, int bonus, AlternateAbilityMods alternates, bool ast) { Skill = skill; Addition = addition; Bonus = bonus; DefMod = DefaultSkillToAbilityMod[skill]; AlternateAbility.STR = alternates.STR; AlternateAbility.DEX = alternates.DEX; AlternateAbility.CON = alternates.CON; AlternateAbility.INT = alternates.INT; AlternateAbility.WIS = alternates.WIS; AlternateAbility.CHA = alternates.CHA; Asterisk = ast; }
public static SkillMod GetSkill(string skill) { AlternateAbilityMods addlAbMods = new AlternateAbilityMods(); string cleanSkill = skill.Replace("+", "ø").Replace("-", "ø").Replace("*", "ø").Replace("(", "ø").Split('ø')[0]; string addlComments = Regex.Match(skill, @"\(([^)]+)\)").Value; int skillRanks = Convert.ToInt32(Regex.Match(skill, "[+-]?[0-9]+").Value); string addlMods = Regex.Replace(skill, "[0-9]+", ""); addlMods = addlMods.TrimStart(' ').TrimEnd(' '); bool asteriskFound = false; if (addlMods != "") { if (addlMods.Contains("*")) { asteriskFound = true; } List <string> otherMods = addlMods.Split(' ').ToList(); addlAbMods.STR = otherMods.Any(x => x.ToUpper() == "STR") ? AbilityMod.Str : (AbilityMod?)null; addlAbMods.DEX = otherMods.Any(x => x.ToUpper() == "DEX") ? AbilityMod.Dex : (AbilityMod?)null; addlAbMods.CON = otherMods.Any(x => x.ToUpper() == "CON") ? AbilityMod.Con : (AbilityMod?)null; addlAbMods.INT = otherMods.Any(x => x.ToUpper() == "INT") ? AbilityMod.Int : (AbilityMod?)null; addlAbMods.WIS = otherMods.Any(x => x.ToUpper() == "WIS") ? AbilityMod.Wis : (AbilityMod?)null; addlAbMods.CHA = otherMods.Any(x => x.ToUpper() == "CHA") ? AbilityMod.Cha : (AbilityMod?)null; } List <Skill> availableSkills = Enum.GetValues(typeof(Skill)).Cast <Skill>().ToList(); int foundIndex = availableSkills.FindIndex(x => x.ToString() == cleanSkill.Replace(" ", "")); if (foundIndex > -1) { return(new SkillMod(availableSkills[foundIndex], addlComments, skillRanks, addlAbMods, asteriskFound)); } else { } return(null); }