public override string SpecialRoll(ulong userId, string input) { input = Regex.Replace(input, "adv" + IgnoreMath, "2d20d1"); input = Regex.Replace(input, "dis" + IgnoreMath, "2d20k1"); DnDPlayerCharacter player = GetPlayer(userId); if (player != null) { foreach (DnDAbilityScores ability in Utilities.GetEnumValues <DnDAbilityScores>()) { // first 3 letters... str, dex, con, int, wis, cha string name = ability.ToString().Substring(0, 3).ToLowerInvariant() + IgnoreMath; // only an ability score -> roll d20 + mod input = Regex.Replace(input, "^" + name + "$", "1d20" + GetModString(player, ability)); // somewhere in a string -> assume it can be replaced with the mod input = Regex.Replace(input, name, "(" + player.BasicInfo.GetAbilityMod(ability) + ")"); } foreach (DnDCharacterSkills skill in Utilities.GetEnumValues <DnDCharacterSkills>()) { // first 4 letters... athl, acro, slei, stea, arca, hist, inve, natu, reli, anim, insi, medi, perc, surv, dece, inti, perf, pers string name = skill.ToString().Substring(0, 4).ToLowerInvariant() + IgnoreMath; // only a skill -> roll d20 + mod input = Regex.Replace(input, "^" + name + "$", "1d20" + GetModString(player, skill)); // somewhere in a string -> assume it can be replaced with the mod input = Regex.Replace(input, name, "(" + player.GetSkillMod(skill) + ")"); } } return(input); }
private static string GetModString(DnDPlayerCharacter player, DnDCharacterSkills skill) { int mod = player.GetSkillMod(skill); return((mod < 0 ? " - " : " + ") + Math.Abs(mod)); }