public string constructSkillString() { string output = ""; List <Skill> skills = DBManager.SkillData.getSkills(); List <string> allKnownSkills = Choices.AllKnownSkills; foreach (Skill skill in skills) { string currentSkill = HTMLRadioButton.Replace("@name@", skill.Name); AbilityScore currentSkillAbility = Choices.Abilities.FirstOrDefault(ability => ability.Name == skill.Ability); string buttonLabel = $"{skill.Name} ({skill.Ability.Substring(0, 3)})"; if (allKnownSkills.Contains(skill.Name)) { int proficientModifier = 0; if ((Choices.ClassChoice.ExtraSkills.Contains(skill.Name)) && Choices.ClassChoice.DoublesProficiency) { proficientModifier = currentSkillAbility.getModifier() + (ProficiencyBonus * 2); } else if ((Choices.ClassChoice.getSelectedSubclass().ExtraSkills.Contains(skill.Name)) && Choices.ClassChoice.getSelectedSubclass().DoublesProficiency) { proficientModifier = currentSkillAbility.getModifier() + (ProficiencyBonus * 2); } else { proficientModifier = currentSkillAbility.getModifier() + ProficiencyBonus; } currentSkill = currentSkill.Replace("@text@", $"{proficientModifier.ToString("+#;-#;+0")} {buttonLabel}"); currentSkill = currentSkill.Replace("@checked@", HTMLRadioButtonChecked); } else { currentSkill = currentSkill.Replace("@text@", $"{currentSkillAbility.getModifier().ToString("+#;-#;+0")} {buttonLabel}"); currentSkill = currentSkill.Replace("@checked@", ""); } output += currentSkill; } return(output); }
public int calculateSpellModifier() { AbilityScore abilityScore = Choices.Abilities.FirstOrDefault(ability => ability.Name == SpellcastingAbility); if (abilityScore != null) { return(abilityScore.getModifier() + ProficiencyBonus); } return(0); }
public int calculateAC() { int armoredAC = 0; int unarmoredAC = 10; //calculate armored AC List <Armor> ownedArmor = getOwnedArmor(); if (ownedArmor.Count > 0) { Armor bodyArmor = ownedArmor.FirstOrDefault(armor => armor.AC > 0); if (bodyArmor != null) { int armorModifier = 0; AbilityScore armorModifierAbility = Choices.Abilities.FirstOrDefault(ability => ability.Name == bodyArmor.AdditionalModifier); if (armorModifierAbility != null) { armorModifier = armorModifierAbility.getModifier(); } if (bodyArmor.AdditionalModifierLimit > 0) { if (armorModifier > bodyArmor.AdditionalModifierLimit) { armorModifier = bodyArmor.AdditionalModifierLimit; } } armoredAC = bodyArmor.AC + armorModifier; } } //calculate unarmored AC List <string> unarmoredAbilities = DBManager.ExportData.getUnarmoredDefenseAbilities(Choices.ClassChoice.Name); foreach (string ability in unarmoredAbilities) { AbilityScore unarmoredModifierAbility = Choices.Abilities.FirstOrDefault(score => score.Name == ability); unarmoredAC += unarmoredModifierAbility.getModifier(); } return(Math.Max(armoredAC, unarmoredAC)); }