public void Setup() { _character.Hp = 50; _damage = new DamageResultList() { Elements = new ObservableCollection <DamageResult>() { new DamageResult() { // using D1 to remove random factor Damage = new DiceRoll("1d1+9"), DamageType = DamageTypeEnum.Fire, }, new DamageResult() { Damage = new DiceRoll("1d1+4"), DamageType = DamageTypeEnum.Cold, }, new DamageResult() { Damage = new DiceRoll("1d1+9"), DamageType = DamageTypeEnum.Poison, }, }, }; foreach (DamageResult dmg in _damage.Elements) { dmg.Damage.Roll(); } }
/// <summary> /// Will trigger any dot damage required /// </summary> /// <param name="start"> true if its start of turn, false otherwise </param> /// <param name="caster"> true if its caster's turn, false otherwise </param> public static void CheckDotDamage(this OnHitStatus onHitStatus, bool start, bool caster) { DamageResultList to_apply = new DamageResultList(); foreach (DotTemplate dot in onHitStatus.DotDamageList.Elements) { if (dot.TriggersStartOfTurn == start && dot.TriggersOnCastersTurn == caster) { to_apply.AddElementSilent(new DamageResult(dot)); } } if (to_apply.Elements.Count != 0) { DamageResultListRollableWindow window = new DamageResultListRollableWindow() { DataContext = to_apply, }; window.TitleControl.Text = onHitStatus.Header + " inflicts damage to " + onHitStatus.Affected.DisplayName; window.ShowCentered(); if (window.Validated) { onHitStatus.Affected.TakeHitDamage(to_apply); } } }
public ApplyDamageResultListCommand(PlayableEntity target, DamageResultList damageList, bool lastSavingWasSuccessfull = false) : base(target.DisplayName) { LastSavingWasSuccessfull = lastSavingWasSuccessfull; foreach (DamageResult dmg in damageList.Elements) { DamageList.Add(new Damage( dmg.Damage.LastResult, dmg.SituationalDamageModifier, dmg.AffinityModifier, dmg.DamageType )); } }
/// <summary> /// A function that applies this status to the given target /// it will register to any required event for the status to automatically ends /// </summary> /// <param name="caster"> the one that tries to apply the status </param> /// <param name="target"> the target of the status </param> /// <param name="application_success"> tells wether or not the application is a success, only used with "false" to tell the OnApplyDamage can be resisted / canceled </param> /// <param name="multiple_application"> tells that a status will be applied more than once ==> to avoid the removal of concentration on every new affected ==> false for the first call, true for the other ones </param> public static void Apply(this OnHitStatus onHitStatus, PlayableEntity caster, PlayableEntity target, bool application_success = true, bool multiple_application = false) { // the applied status is a copy OnHitStatus applied = (OnHitStatus)onHitStatus.Clone(); if (applied.OnApplyDamageList.Elements.Count != 0) { DamageResultList onApplyDamageList = onHitStatus.OnApplyDamageList.GetResultList(); foreach (DamageResult dmg in onApplyDamageList.Elements) { dmg.LastSavingWasSuccesfull = !application_success; } DamageResultListRollableWindow window = new DamageResultListRollableWindow() { DataContext = onApplyDamageList }; window.ShowCentered(); if (window.Validated) { target.TakeHitDamage(onApplyDamageList); } } if (application_success) { console.AddEntry($"{caster.DisplayName}", fontWeightProvider.Bold); console.AddEntry(" applies "); console.AddEntry($"{onHitStatus.Header}", fontWeightProvider.Bold); console.AddEntry(" on "); console.AddEntry($"{target.DisplayName}\r\n", fontWeightProvider.Bold); applied.Caster = caster; applied.Affected = target; target.CustomVerboseStatusList.AddElementSilent(applied); OnHitStatus.RegisterEvents(applied); if (applied.EndsOnCasterLossOfConcentration) { if (caster.IsFocused == true && multiple_application == false) { caster.IsFocused = false; } caster.IsFocused = true; } } }
/// <summary> /// method called when a hit attack lands to compute the damage received /// </summary> /// <param name="damages"></param> // TODO Might need to rename this public static void TakeHitDamage(this PlayableEntity playableEntity, DamageResultList damages) { int i = 1; int total = 0; console.AddEntry($"{playableEntity.DisplayName}", fontWeightProvider.Bold); console.AddEntry(" takes "); foreach (DamageResult dmg in damages.Elements) { int damage_value = 0; if (dmg.Damage.LastResult > 0) { DamageAffinityEnum affinity = playableEntity.DamageAffinities.GetAffinity(dmg.DamageType).Affinity; // damage resistance / weakness switch (affinity) { case DamageAffinityEnum.Neutral: damage_value = dmg.Damage.LastResult; break; case DamageAffinityEnum.Resistant: damage_value = dmg.Damage.LastResult / 2; break; case DamageAffinityEnum.Immune: damage_value = 0; break; case DamageAffinityEnum.Weak: damage_value = dmg.Damage.LastResult * 2; break; } if (dmg.LastSavingWasSuccesfull) { // Situational damage modifiers (such as a saving throw that could divide damge by 2) switch (dmg.SituationalDamageModifier) { case DamageModifierEnum.Halved: damage_value /= 2; break; case DamageModifierEnum.Canceled: damage_value = 0; break; default: break; } dmg.LastSavingWasSuccesfull = false; } } if (i == damages.Elements.Count && i != 1) { console.AddEntry("and "); } console.AddEntry($"{damage_value} {dmg.DamageType}", fontWeightProvider.Bold, fontColorProvider.GetColorByKey(dmg.DamageType.ToString())); console.AddEntry($"{(i == damages.Elements.Count ? " damage" : " damage, ")}"); total += damage_value; i += 1; } playableEntity.LooseHp(total); }
public ApplyDamageResultListCommand(PlayableEntity target, DamageResultList damageList, bool isInnerCommand) : base(isInnerCommand) { Target = target; DamageList = (DamageResultList)damageList.Clone(); }
public GetInputDamageResultListResponse(DamageResultList damageResultList) { DamageResultList = damageResultList; }
/// <summary> /// Intended to ask the user to either enter numbers or roll for the given DamageResultList. /// / ! \ As the target is not known by the commands, the eventual resistances should be known in the list beforehand /// </summary> /// <param name="damages"> </param> public GetInputDamageResultListCommand(DamageResultList damages, string reason = "") { DamageList = damages.Clone() as DamageResultList; Reason = reason; }