From 1bd7017bf87ab4c90e28230f7ce6006aed2d8f9f Mon Sep 17 00:00:00 2001 From: The Gray Alien <103865052+TheGrayAlien@users.noreply.github.com> Date: Sat, 21 Jun 2025 01:36:57 -0400 Subject: [PATCH 1/3] New rule REPLACES the list of addition effects to the selected abilities. If the ability already has an effect it should be included in the list unless you don't want the original effect on the ability. Usage example: { "Rule": "AbilityTargetEffects", "Config": { "Javelin": [ "Weaken1Turn" ], "PVPBlink": [ "Weaken1Turn", "Disoriented" ], "PanicPowderArrow": [ "Panic", "Netted" ], "TurretDamageProjectile": [ "Tangled" ], "EnemyTurretDamageProjectile": [ "Tangled" ], "TurretHighDamageProjectile": [ "Panic", "Blinded" ], "TauntingScream": [ "Weaken2Turns", "Disoriented" ], "WarCry": [ "Panic", "Blinded" ], "ExplodingGasLamp": [ "Diseased", "Stunned" ] } --- .../AbilityTargetEffectsRule.cs | 56 +++++++++++++++++++ .../HouseRulesEssentialsBase.cs | 1 + 2 files changed, 57 insertions(+) create mode 100644 HouseRules.Essentials/AbilityTargetEffectsRule.cs diff --git a/HouseRules.Essentials/AbilityTargetEffectsRule.cs b/HouseRules.Essentials/AbilityTargetEffectsRule.cs new file mode 100644 index 00000000..9009d989 --- /dev/null +++ b/HouseRules.Essentials/AbilityTargetEffectsRule.cs @@ -0,0 +1,56 @@ +namespace HouseRules.Essentials.Rules +{ + using System.Collections.Generic; + using System.Linq; + using DataKeys; + using HouseRules.Core.Types; + + public sealed class AbilityTargetEffectsRule : Rule, IConfigWritable>>, IMultiplayerSafe + { + public override string Description => "Some abilities have added secondary effects."; + + private readonly Dictionary> _adjustments; + private Dictionary> _originals; + + /// + /// Initializes a new instance of the class. + /// + /// Key-value pairs of abilityKey and List. + public AbilityTargetEffectsRule(Dictionary> adjustments) + { + _adjustments = adjustments; + _originals = new Dictionary>(); + } + + public Dictionary> GetConfigObject() => _adjustments; + + protected override void OnPreGameCreated(Context context) + { + _originals = ReplaceAbilities(context, _adjustments); + } + + protected override void OnDeactivate(Context context) + { + ReplaceAbilities(context, _originals); + } + + private static Dictionary> ReplaceAbilities(Context context, Dictionary> replacements) + { + var originals = new Dictionary>(); + foreach (var replacement in replacements) + { + var abilityPromise = context.AbilityFactory.LoadAbility(replacement.Key); + abilityPromise.OnLoaded(ability => + { + originals[replacement.Key] = ability.targetEffects.ToList(); + ability.targetEffects = replacement.Value.ToArray(); + }); + } + + // Theoretically, there can be a race condition as there's no guarantee the promise above is fulfilled by + // the return value is used. Realistically, there's no concern since the value isn't used until after the + // promise has long been fulfilled. + return originals; + } + } +} diff --git a/HouseRules.Essentials/HouseRulesEssentialsBase.cs b/HouseRules.Essentials/HouseRulesEssentialsBase.cs index b88dce9e..00c2db2b 100644 --- a/HouseRules.Essentials/HouseRulesEssentialsBase.cs +++ b/HouseRules.Essentials/HouseRulesEssentialsBase.cs @@ -60,6 +60,7 @@ private static void RegisterRuleTypes() HR.Rulebook.Register(typeof(AbilityActionCostAdjustedRule)); HR.Rulebook.Register(typeof(AbilityRandomPieceListRule)); HR.Rulebook.Register(typeof(AbilityStealthDamageOverriddenRule)); + HR.Rulebook.Register(typeof(AbilityTargetEffectsRule)); HR.Rulebook.Register(typeof(ApplyEffectOnHitAdjustedRule)); HR.Rulebook.Register(typeof(BackstabConfigOverriddenRule)); HR.Rulebook.Register(typeof(CourageShantyAddsHpRule)); From 25f5b8aaa8bc4a069d3558cb42e61bfabedb1903 Mon Sep 17 00:00:00 2001 From: The Gray Alien <103865052+TheGrayAlien@users.noreply.github.com> Date: Sat, 21 Jun 2025 02:42:53 -0400 Subject: [PATCH 2/3] Update README Include rule in the Essentials README. --- HouseRules.Essentials/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/HouseRules.Essentials/README.md b/HouseRules.Essentials/README.md index 56518225..e5a27ac2 100644 --- a/HouseRules.Essentials/README.md +++ b/HouseRules.Essentials/README.md @@ -189,6 +189,23 @@ The [Settings Reference](../docs/SettingsReference.md) contains lists of all dif }, ``` + #### __AbilityTargetEffectsAdjusted__: Replaces the list of addition effects to the selected abilities + - REPLACES the list of addition effects for the selected abilities. You may manually include the original effect if desired. + - To configure: + - Specify the [AbilityKey](../docs/SettingsReference.md#abilitykeys) of the ability to modify. + - Specify the list of [EffectStates](../docs/SettingsReference.md#effectstatetypes) that the ability should apply. + + ###### _Example JSON config for AbilityTargetEffectsAdjusted_ + + ```json + { + "Rule": "AbilityTargetEffectsAdjusted", + "Config": { + "Javelin": [ "Weaken1Turn" ], + "WarCry": [ "Panic", "Blinded" ] + } + ``` + #### __ApplyEffectOnHitAdjusted__: Adjusts the effect that a ♟️BoardPiece has on attackers. - For example, you can make Barricades inspire Panic on enemies that hit it. - To be useful the effect has to last at least 2 rounds. From 723a15d30ba63bdc57bda161d19a5a6568d5929a Mon Sep 17 00:00:00 2001 From: The Gray Alien <103865052+TheGrayAlien@users.noreply.github.com> Date: Sat, 21 Jun 2025 02:48:51 -0400 Subject: [PATCH 3/3] Rename rule Renamed to fit in line with current rule name methodology. --- ...EffectsRule.cs => AbilityTargetEffectsOverriddenRule.cs} | 6 +++--- HouseRules.Essentials/HouseRulesEssentialsBase.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename HouseRules.Essentials/{AbilityTargetEffectsRule.cs => AbilityTargetEffectsOverriddenRule.cs} (87%) diff --git a/HouseRules.Essentials/AbilityTargetEffectsRule.cs b/HouseRules.Essentials/AbilityTargetEffectsOverriddenRule.cs similarity index 87% rename from HouseRules.Essentials/AbilityTargetEffectsRule.cs rename to HouseRules.Essentials/AbilityTargetEffectsOverriddenRule.cs index 9009d989..c90c062c 100644 --- a/HouseRules.Essentials/AbilityTargetEffectsRule.cs +++ b/HouseRules.Essentials/AbilityTargetEffectsOverriddenRule.cs @@ -5,7 +5,7 @@ using DataKeys; using HouseRules.Core.Types; - public sealed class AbilityTargetEffectsRule : Rule, IConfigWritable>>, IMultiplayerSafe + public sealed class AbilityTargetEffectsOverriddenRule : Rule, IConfigWritable>>, IMultiplayerSafe { public override string Description => "Some abilities have added secondary effects."; @@ -13,10 +13,10 @@ public sealed class AbilityTargetEffectsRule : Rule, IConfigWritable> _originals; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// Key-value pairs of abilityKey and List. - public AbilityTargetEffectsRule(Dictionary> adjustments) + public AbilityTargetEffectsOverriddenRule(Dictionary> adjustments) { _adjustments = adjustments; _originals = new Dictionary>(); diff --git a/HouseRules.Essentials/HouseRulesEssentialsBase.cs b/HouseRules.Essentials/HouseRulesEssentialsBase.cs index 00c2db2b..87b38cfb 100644 --- a/HouseRules.Essentials/HouseRulesEssentialsBase.cs +++ b/HouseRules.Essentials/HouseRulesEssentialsBase.cs @@ -60,7 +60,7 @@ private static void RegisterRuleTypes() HR.Rulebook.Register(typeof(AbilityActionCostAdjustedRule)); HR.Rulebook.Register(typeof(AbilityRandomPieceListRule)); HR.Rulebook.Register(typeof(AbilityStealthDamageOverriddenRule)); - HR.Rulebook.Register(typeof(AbilityTargetEffectsRule)); + HR.Rulebook.Register(typeof(AbilityTargetEffectsOverriddenRule)); HR.Rulebook.Register(typeof(ApplyEffectOnHitAdjustedRule)); HR.Rulebook.Register(typeof(BackstabConfigOverriddenRule)); HR.Rulebook.Register(typeof(CourageShantyAddsHpRule));