/// <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); } } }
/// <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; } } }