public static void TryApply(this OnHitStatus onHitStatus, SavingThrow savingThrow, PlayableEntity applicant, PlayableEntity target) { if (onHitStatus.HasApplyCondition) { ICustomConsole console = DIContainer.GetImplementation <ICustomConsole>(); IFontColorProvider colorProvider = DIContainer.GetImplementation <IFontColorProvider>(); IFontWeightProvider fontWeightProvider = DIContainer.GetImplementation <IFontWeightProvider>(); // there is a saving throw to resist the status Characteristic charac = target.Characteristics.GetCharacteristic(onHitStatus.ApplySavingCharacteristic); console.AddEntry(target.DisplayName, fontWeightProvider.Bold); console.AddEntry(" tries to restist the "); console.AddEntry(onHitStatus.Header, fontWeightProvider.Bold); console.AddEntry(" status from "); console.AddEntry(applicant.DisplayName, fontWeightProvider.Bold); console.AddEntry(". "); console.AddEntry($"{savingThrow.Result}/{savingThrow.Difficulty}", fontWeightProvider.Bold); console.AddEntry(" ==> "); if (savingThrow.Result >= savingThrow.Difficulty) { //resist console.AddEntry("Success\r\n", fontWeightProvider.Bold); //applyStatus(false); } else { //fails console.AddEntry("Failure\r\n", fontWeightProvider.Bold); //applyStatus(); } } }
public List <SavingThrow> ReadSavings() { List <SavingThrow> savings = new List <SavingThrow>(); SavingThrow saving; int buffer; _reader = XmlReader.Create(_path + _characterName + ".xml"); while (_reader.ReadToFollowing("SavingThrow")) { saving = new SavingThrow(); _reader.MoveToFirstAttribute(); saving.Name = _reader.Value; _reader.MoveToNextAttribute(); saving.RelevantAttribute = _reader.Value; _reader.MoveToNextAttribute(); Int32.TryParse(_reader.Value, out buffer); saving.BaseSave = buffer; _reader.MoveToNextAttribute(); Int32.TryParse(_reader.Value, out buffer); saving.MagicModifier = buffer; _reader.MoveToNextAttribute(); Int32.TryParse(_reader.Value, out buffer); saving.MiscModifier = buffer; savings.Add(saving); } return(savings); }
public void GetTotal() { // Arrange var mockAbilityScore = new Mock <IAbilityScore>(); mockAbilityScore.Setup(abs => abs.GetModifier()) .Returns(3); var mockCharacter = new Mock <ICharacter>(); mockCharacter.Setup(c => c.Level) .Returns(3); SavingThrow savingThrow = new SavingThrow(mockCharacter.Object, mockAbilityScore.Object) { IsGood = false }; savingThrow.LuckBonuses.Add(() => 5); savingThrow.ResistanceBonuses.Add(() => 7); savingThrow.UntypedBonuses.Add(() => 11); savingThrow.Penalties.Add(() => 13); // Act var total = savingThrow.GetTotal(); // Assert Assert.AreEqual(14, total, "+14 = (1 level) + (3 ability) + (5 luck) + (7 resistance) + (11 untyped) - (13 penalties)"); }
private void TargetListControl_LayoutUpdated(object sender, EventArgs e) { List <FrameworkElement> list = TargetListControl.GetAllChildrenByName("SavingThrowRollableDenseControl"); savings.Clear(); if (list.Count == data_context.Targets.Count) { TargetListControl.LayoutUpdated -= TargetListControl_LayoutUpdated; foreach (PlayableEntity target in data_context.Targets) { SavingThrow new_one = new SavingThrow { Characteristic = data_context.SavingCharacteristic, Difficulty = data_context.SavingDifficulty, Target = target, }; savings.Add(new_one); } int i = 0; foreach (SavingThrowRollableDenseUserControl control in list) { control.DataContext = savings.ElementAt(i); i += 1; } } }
private string GetSavingThrowString(SavingThrow save) { switch (save) { case DataTypes.SavingThrow.FortitudeHalves: return("Fortitude Half"); case DataTypes.SavingThrow.FortitudeNegates: return("Fortitude Negates"); case DataTypes.SavingThrow.FortitudePartial: return("Fortitude Partial"); case DataTypes.SavingThrow.ReflaxHalves: return("Reflex Half"); case DataTypes.SavingThrow.ReflexNegates: return("Reflex Negates"); case DataTypes.SavingThrow.ReflexPartial: return("Reflex Partial"); case DataTypes.SavingThrow.WillHalves: return("Will Half"); case DataTypes.SavingThrow.WillNegates: return("Will Negates"); case DataTypes.SavingThrow.WillPartial: return("Will Partial"); default: return(null); } }
/// <summary> /// Gets a list containing the saving throw progression granted by this class.<br/> /// The list is 0-indexed, with level 1 starting at element 0. /// </summary> /// <param name="savingThrow">The saving throw to query. <see cref="SavingThrow.All"/> is not supported.</param> /// <example> /// byte reflexSaveLevel15 = nwClass.GetSavingThrowTable(SavingThrow.Reflex)[14]; /// </example> public IReadOnlyList <byte> GetSavingThrowTable(SavingThrow savingThrow) { return(savingThrow switch { SavingThrow.Fortitude => classInfo.m_lstFortificationSaveThrowBonus.ToArray(), SavingThrow.Reflex => classInfo.m_lstReflexSaveThrowBonus.ToArray(), SavingThrow.Will => classInfo.m_lstWillSaveThrowBonus.ToArray(), _ => ImmutableArray <byte> .Empty, });
public void PopulateValues(SavingThrow savingThrow) { lblFortitudeBase.Text = savingThrow.BaseFortitude.ToString(); numFortitudeMisc.Value = savingThrow.MiscFortitudeMod; lblFortitudeTotal.Text = savingThrow.FortitudeSave.ToString(); lblReflexBase.Text = savingThrow.BaseReflex.ToString(); numReflexMisc.Value = savingThrow.MiscReflexMod; lblReflexTotal.Text = savingThrow.ReflexSave.ToString(); lblWillBase.Text = savingThrow.BaseWill.ToString(); numWillMisc.Value = savingThrow.MiscWillMod; lblWillTotal.Text = savingThrow.WillSave.ToString(); }
public void Default() { // Arrange var character = Mock.Of <ICharacter>(); var abilityScore = Mock.Of <IAbilityScore>(); // Act SavingThrow savingThrow = new SavingThrow(character, abilityScore); // Assert Assert.AreSame(abilityScore, savingThrow.KeyAbilityScore); Assert.IsFalse(savingThrow.IsGood); Assert.IsInstanceOf <LuckBonusTracker>(savingThrow.LuckBonuses); Assert.IsInstanceOf <ResistanceBonusTracker>(savingThrow.ResistanceBonuses); Assert.IsInstanceOf <UntypedBonusTracker>(savingThrow.UntypedBonuses); Assert.IsInstanceOf <PenaltyTracker>(savingThrow.Penalties); }
public void GetLevelBonus_Bad_Level1() { // Arrange var abilityScore = Mock.Of <IAbilityScore>(); var mockCharacter = new Mock <ICharacter>(); mockCharacter.Setup(c => c.Level) .Returns(1); SavingThrow savingThrow = new SavingThrow(mockCharacter.Object, abilityScore) { IsGood = false }; // Act var result = savingThrow.GetLevelBonus(); // Assert Assert.AreEqual(0, result, "A bad saving throw at level 1 provides a +0 bonus."); }
public static Effect SavingThrowIncrease(SavingThrow savingThrow, int amount, SavingThrowType savingThrowType = SavingThrowType.All) => NWScript.EffectSavingThrowIncrease((int)savingThrow, amount, (int)savingThrowType);
private void LoadData(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.InitialDirectory = @"C:\"; dialog.Filter = "mm files (*.mm)|*.mm"; dialog.RestoreDirectory = true; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Data jsonMonster = new Data(); jsonMonster = JsonConvert.DeserializeObject <Data>(System.IO.File.ReadAllText(dialog.FileName)); TraitsList.Items.Clear(); Monster.Input(jsonMonster); currentCR = Monster.CR; ChallengeRatingDropDown.Text = ""; ChallengeRatingDropDown.SelectedText = Help.FindCRByIndex(Monster.CR.Index).CR; crChangedUpdateProficiency(null, null); AlignmentDropDown.Text = ""; AlignmentDropDown.SelectedText = Monster.CreatureAlign; StrUpDown.Value = Monster.STR; DexUpDown.Value = Monster.DEX; ConUpDown.Value = Monster.CON; WisUpDown.Value = Monster.WIS; IntUpDown.Value = Monster.INT; ChaUpDown.Value = Monster.CHA; string[] speeds = Monster.Speed.Split(','); foreach (string speed in speeds) { string check = speed.Split(':')[0].Trim(); switch (check) { case "Burrow": int Burrow = 0; int.TryParse(speed.Split(':')[1], out Burrow); burrowUpDown.Value = Burrow; break; case "Climb": int Climb = 0; int.TryParse(speed.Split(':')[1], out Climb); ClimbUpDown.Value = Climb; break; case "Fly": int Fly = 0; if (speed.Split(':')[1].Contains("(Hover)")) { HoverCheckBox.Checked = true; int.TryParse(speed.Split(':')[1].Replace(" (Hover)", ""), out Fly); } else { int.TryParse(speed.Split(':')[1], out Fly); } FlyUpDown.Value = Fly; break; case "Swim": int Swim = 0; int.TryParse(speed.Split(':')[1], out Swim); SwimUpDown.Value = Swim; break; default: try { int temp = 0; int.TryParse(check, out temp); SpeedUpDown.Value = temp; } catch { } break; } } foreach (Ability item in Monster._Abilities) { TraitsList.Items.Add("Ability: " + item.Title); } foreach (Ability item in Monster._Attacks) { TraitsList.Items.Add("Attack: " + item.Title); } foreach (string language in Monster._Languages) { TraitsList.Items.Add("Language: " + language); } foreach (string senses in Monster._Senses) { TraitsList.Items.Add("Sense: " + senses); } foreach (string CImmunity in Monster.ConditionImmunities) { TraitsList.Items.Add("Condition Immunity: " + CImmunity); } foreach (string DImmunities in Monster.DamageImmunities) { TraitsList.Items.Add("Damage Immunity: " + DImmunities); } foreach (string DResistance in Monster.DamageResistances) { TraitsList.Items.Add("Damage Resistance: " + DResistance); } foreach (string DVulnerability in Monster.DamageVulnerability) { TraitsList.Items.Add("Damage Vulnerability: " + DVulnerability); } foreach (string SavingThrow in Monster.SavingThrowBonuses) { string temp = SavingThrow.Split(' ')[0]; int tempBonus = 0; int.TryParse(SavingThrow.Split('+')[1], out tempBonus); switch (temp) { case "Str": StrSaveBonusUpDown.Value = tempBonus; break; case "Dex": DexSaveBonusUpDown.Value = tempBonus; break; case "Con": ConSaveBonusUpDown.Value = tempBonus; break; case "Int": IntSaveBonusUpDown.Value = tempBonus; break; case "Wis": WisSaveBonusUpDown.Value = tempBonus; break; case "Cha": ChaSaveBonusUpDown.Value = tempBonus; break; } } foreach (string SkillBonus in Monster.SkillBonuses) { TraitsList.Items.Add(SkillBonus); } HitDieTextBox.Text = Monster.HP; try { string hpString = Monster.HP.Split('(')[1].Replace(')', ' ').Trim().Split('+')[0]; int DiceSize; int DiceNumber; int.TryParse(hpString.Split('d')[0], out DiceNumber); int.TryParse(hpString.Split('d')[1], out DiceSize); HitDieUpDown.Value = DiceNumber; HitDieDropDown.Text = ""; HitDieDropDown.SelectedText = "d" + DiceSize; } catch { } try { int ACValue = 0; int.TryParse(Monster.AC.Split(' ')[0], out ACValue); ACUpDown.Value = ACValue; ACSourceTextBox.Text = Monster.AC.Split(' ')[1]; } catch { } MonsterNameTextBox.Text = ""; SizeDropDown.Text = ""; TypeDropDown.Text = ""; TagDropDown.Text = ""; MonsterNameTextBox.Text = Monster.CreatureName; SizeDropDown.SelectedText = Monster.CreatureSize; TypeDropDown.SelectedText = Monster.CreatureType.Split(' ')[0]; try { TagDropDown.SelectedText = Monster.CreatureType.Split(' ')[1].Replace('(', ' ').Replace(')', ' ').Trim(); } catch { } //Monster.SkillBonuses.Clear(); Monster.Clear(); } }
public static Effect SavingThrowDecrease(SavingThrow savingThrow, int amount, SavingThrowType savingThrowType = SavingThrowType.All) { return(NWScript.EffectSavingThrowDecrease((int)savingThrow, amount, (int)savingThrowType) !); }
private void LoadData(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.InitialDirectory = @"C:\"; dialog.Filter = "mm files (*.mm)|*.mm"; dialog.RestoreDirectory = true; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Data jsonMonster = new Data(); jsonMonster = JsonConvert.DeserializeObject <Data>(System.IO.File.ReadAllText(dialog.FileName)); TraitsList.Items.Clear(); Monster.Input(jsonMonster); foreach (Ability item in Monster._Abilities) { TraitsList.Items.Add("Ability: " + item.Title); } foreach (Attack item in Monster._Attacks) { TraitsList.Items.Add("Attack: " + item.Title); } foreach (string language in Monster._Languages) { TraitsList.Items.Add("Language: " + language); } foreach (string senses in Monster._Senses) { TraitsList.Items.Add("Sense: " + senses); } foreach (string CImmunity in Monster.ConditionImmunities) { TraitsList.Items.Add("Condition Immunity: " + CImmunity); } foreach (string DImmunities in Monster.DamageImmunities) { TraitsList.Items.Add("Damage Immunity: " + DImmunities); } foreach (string DResistance in Monster.DamageResistances) { TraitsList.Items.Add("Damage Resistance: " + DResistance); } foreach (string DVulnerability in Monster.DamageVulnerability) { TraitsList.Items.Add("Damage Vulnerability: " + DVulnerability); } foreach (string SavingThrow in Monster.SavingThrowBonuses) { string temp = SavingThrow.Split(' ')[0]; int tempBonus = 0; int.TryParse(SavingThrow.Split('+')[1], out tempBonus); switch (temp) { case "Str": StrSaveBonusUpDown.Value = tempBonus; break; case "Dex": DexSaveBonusUpDown.Value = tempBonus; break; case "Con": ConSaveBonusUpDown.Value = tempBonus; break; case "Int": IntSaveBonusUpDown.Value = tempBonus; break; case "Wis": WisSaveBonusUpDown.Value = tempBonus; break; case "Cha": ChaSaveBonusUpDown.Value = tempBonus; break; } } foreach (string SkillBonus in Monster.SkillBonuses) { TraitsList.Items.Add(SkillBonus); } } }
public Spell(string name, Dictionary <string, int> level, string description, School school, Subschool subschool, IEnumerable <string> components, CastingTime castingTime, Range range, Duration duration, SavingThrow save, bool spellResistance) { Name = name; Level = level; Description = description; School = school; SchoolString = school.ToString(); Subschool = subschool; SubschoolString = subschool.ToString(); Components = components; CastingTime = GetCastingTimeString(castingTime); Range = GetRangeString(range); Duration = GetDurationString(duration); SavingThrow = GetSavingThrowString(save); SpellResistance = spellResistance; SrString = GetSrString(spellResistance); Link = "https://aonprd.com/SpellDisplay.aspx?ItemName=" + Name; }
public bool SavingThrowSuccessful(SavingThrow savingThrow, int adjustment = 0) { int[,] savingThrowMatrix = GetSavingThrowMatrix(); int requiredRoll = savingThrowMatrix[Experience.Level, (int)savingThrow]; int actualRoll = Dice.Roll(1, 20, adjustment); if (actualRoll >= requiredRoll) return true; else return false; }