From c731e644eb239cacca2a5fc8d7ef974e76c78382 Mon Sep 17 00:00:00 2001 From: Sean Petrie Date: Sat, 30 Oct 2021 15:07:44 -0500 Subject: [PATCH] Linter --- TabletopTweaks/Bugfixes/Items/Weapons.cs | 2 +- .../NewComponents/AbilityEffectToggleBuff.cs | 5 --- .../AbilitySpecific/MetaRageComponent.cs | 2 +- .../NewComponents/AdditionalSpellSelection.cs | 5 ++- .../NewContent/Archetypes/MetamagicRager.cs | 7 +--- .../NewContent/Classes/Loremaster.cs | 2 +- TabletopTweaks/NewUI/ActionBarPatches.cs | 7 ++-- .../UnitPartPseudoActivatableAbilities.cs | 32 +++++++++---------- TabletopTweaks/Utilities/DescriptionTools.cs | 4 +-- 9 files changed, 26 insertions(+), 40 deletions(-) diff --git a/TabletopTweaks/Bugfixes/Items/Weapons.cs b/TabletopTweaks/Bugfixes/Items/Weapons.cs index 40fb7ef5..20f06309 100644 --- a/TabletopTweaks/Bugfixes/Items/Weapons.cs +++ b/TabletopTweaks/Bugfixes/Items/Weapons.cs @@ -107,7 +107,7 @@ void PatchTerribleTremble() { var Ultrasound = Resources.GetBlueprint("582849db96824254ebcc68f0b7484e51"); var TerrifyingTrembleEnchant_TTT = Resources.GetModBlueprint("TerrifyingTrembleEnchant_TTT"); - TerrifyingTrembleItem.m_DescriptionText = Helpers.CreateTaggedString($"{TerrifyingTrembleItem.name}.description", + TerrifyingTrembleItem.m_DescriptionText = Helpers.CreateTaggedString($"{TerrifyingTrembleItem.name}.description", "Whenever the wielder of this +5 ultrasound earthbreaker lands a killing blow, he deals sonic damage equal to his ranks in " + "the Athletics skill to all enemies within 10 feet. Successful Reflex save (DC 30) halves the damage."); diff --git a/TabletopTweaks/NewComponents/AbilityEffectToggleBuff.cs b/TabletopTweaks/NewComponents/AbilityEffectToggleBuff.cs index 86b41289..1c44a22e 100644 --- a/TabletopTweaks/NewComponents/AbilityEffectToggleBuff.cs +++ b/TabletopTweaks/NewComponents/AbilityEffectToggleBuff.cs @@ -6,11 +6,6 @@ using Kingmaker.UnitLogic.Abilities.Components.Base; using Kingmaker.Utility; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using TabletopTweaks.NewUnitParts; namespace TabletopTweaks.NewComponents { diff --git a/TabletopTweaks/NewComponents/AbilitySpecific/MetaRageComponent.cs b/TabletopTweaks/NewComponents/AbilitySpecific/MetaRageComponent.cs index 575ea6dc..ee8ee1c8 100644 --- a/TabletopTweaks/NewComponents/AbilitySpecific/MetaRageComponent.cs +++ b/TabletopTweaks/NewComponents/AbilitySpecific/MetaRageComponent.cs @@ -134,7 +134,7 @@ public MetaRageAbilityData(AbilityData other, BlueprintAbility replaceBlueprint) this.m_ConvertedFrom = other; } - public new string Name { get => $"{Blueprint.Name} — {addedMetamagic}"; } + public new string Name { get => $"{Blueprint.Name} — {addedMetamagic}"; } public BlueprintFeature MetamagicFeature { get => m_MetamagicFeature.Get(); } public BlueprintFeatureReference m_MetamagicFeature; diff --git a/TabletopTweaks/NewComponents/AdditionalSpellSelection.cs b/TabletopTweaks/NewComponents/AdditionalSpellSelection.cs index 4be1a485..9a9802b7 100644 --- a/TabletopTweaks/NewComponents/AdditionalSpellSelection.cs +++ b/TabletopTweaks/NewComponents/AdditionalSpellSelection.cs @@ -8,7 +8,6 @@ using Kingmaker.UnitLogic; using Kingmaker.UnitLogic.Abilities.Blueprints; using Kingmaker.UnitLogic.Class.LevelUp; -using Kingmaker.UnitLogic.Class.LevelUp.Actions; using Kingmaker.Utility; using System; using System.Collections.Generic; @@ -20,7 +19,7 @@ namespace TabletopTweaks.NewComponents { class AdditionalSpellSelection : UnitFactComponentDelegate, IUnitCompleteLevelUpHandler { private Spellbook SpellBook { get => Owner.DemandSpellbook(m_SpellCastingClass); } - private BlueprintSpellList SpellList { get => ProxyList(m_SpellList ?? SpellBook?.Blueprint?.SpellList); } + private BlueprintSpellList SpellList { get => ProxyList(m_SpellList ?? SpellBook?.Blueprint?.SpellList); } public int AdjustedMaxLevel { get { if (!UseOffset) { return MaxSpellLevel; } @@ -44,7 +43,7 @@ public override void OnActivate() { spellSelections[i].SetExtraSpells(Count, AdjustedMaxLevel); } for (; i < selectionCount; i++) { - + if (i >= selectionCount) { continue; } var selection = controller.State.DemandSpellSelection(SpellBook.Blueprint, SpellList); selection.SetExtraSpells(Count, AdjustedMaxLevel); diff --git a/TabletopTweaks/NewContent/Archetypes/MetamagicRager.cs b/TabletopTweaks/NewContent/Archetypes/MetamagicRager.cs index ee1c90ea..58fc85dc 100644 --- a/TabletopTweaks/NewContent/Archetypes/MetamagicRager.cs +++ b/TabletopTweaks/NewContent/Archetypes/MetamagicRager.cs @@ -1,5 +1,4 @@ -using HarmonyLib; -using Kingmaker.Blueprints; +using Kingmaker.Blueprints; using Kingmaker.Blueprints.Classes; using Kingmaker.Blueprints.Classes.Prerequisites; using Kingmaker.Blueprints.Classes.Selection; @@ -7,13 +6,9 @@ using Kingmaker.Designers.Mechanics.Facts; using Kingmaker.ElementsSystem; using Kingmaker.Localization; -using Kingmaker.UI.UnitSettings; -using Kingmaker.UnitLogic; -using Kingmaker.UnitLogic.Abilities; using Kingmaker.UnitLogic.Abilities.Blueprints; using Kingmaker.UnitLogic.Abilities.Components; using Kingmaker.UnitLogic.Abilities.Components.CasterCheckers; -using Kingmaker.UnitLogic.ActivatableAbilities; using Kingmaker.UnitLogic.Buffs.Blueprints; using Kingmaker.UnitLogic.FactLogic; using Kingmaker.UnitLogic.Mechanics; diff --git a/TabletopTweaks/NewContent/Classes/Loremaster.cs b/TabletopTweaks/NewContent/Classes/Loremaster.cs index a1aea58b..2e0ca515 100644 --- a/TabletopTweaks/NewContent/Classes/Loremaster.cs +++ b/TabletopTweaks/NewContent/Classes/Loremaster.cs @@ -44,7 +44,7 @@ void CreateSpellSecretSelection(BlueprintFeatureSelection secret) { BlueprintFeature[] CreateSpellSecretClasses(BlueprintFeatureSelection secretSelection) { var secret = secretSelection.m_AllFeatures.First().Get() as BlueprintParametrizedFeature; return SpellTools.SpellCastingClasses.AllClasses.Select(castingClass => { - var name = $"{secretSelection.name.Replace("Selection", "").Replace("Spell","")}{castingClass.Name}_TTT"; + var name = $"{secretSelection.name.Replace("Selection", "").Replace("Spell", "")}{castingClass.Name}_TTT"; if (Regex.Matches(name, "Cleric").Count > 1 || Regex.Matches(name, "Druid").Count > 1) { return null; } diff --git a/TabletopTweaks/NewUI/ActionBarPatches.cs b/TabletopTweaks/NewUI/ActionBarPatches.cs index 9ba613fa..0b48d160 100644 --- a/TabletopTweaks/NewUI/ActionBarPatches.cs +++ b/TabletopTweaks/NewUI/ActionBarPatches.cs @@ -43,8 +43,7 @@ static bool Prefix(ActionBarSpontaneousConvertedSlot __instance, UnitEntityData Unit = selected }; __instance.MechanicSlot.SetSlot(__instance); - } - else if (spell.Blueprint.GetComponent()) { + } else if (spell.Blueprint.GetComponent()) { __instance.Selected = selected; if (selected == null) { return true; @@ -134,7 +133,7 @@ static bool Prefix(ActionBarVM __instance, UnitEntityData unit) { MechanicActionBarSlotAbility actionBarSlotAbility = new MechanicActionBarSlotAbility(); actionBarSlotAbility.Ability = ability.Data; actionBarSlotAbility.Unit = unit; - ActionBarSlotVM actionBarSlotVm = new ActionBarSlotVM((MechanicActionBarSlot)actionBarSlotAbility); + ActionBarSlotVM actionBarSlotVm = new ActionBarSlotVM(actionBarSlotAbility); groupAbilities.Add(actionBarSlotVm); } } @@ -144,7 +143,7 @@ static bool Prefix(ActionBarVM __instance, UnitEntityData unit) { MechanicActionBarSlotActivableAbility activableAbility = new MechanicActionBarSlotActivableAbility(); activableAbility.ActivatableAbility = activatableAbility; activableAbility.Unit = unit; - ActionBarSlotVM actionBarSlotVm = new ActionBarSlotVM((MechanicActionBarSlot)activableAbility); + ActionBarSlotVM actionBarSlotVm = new ActionBarSlotVM(activableAbility); groupAbilities.Add(actionBarSlotVm); } return false; diff --git a/TabletopTweaks/NewUnitParts/UnitPartPseudoActivatableAbilities.cs b/TabletopTweaks/NewUnitParts/UnitPartPseudoActivatableAbilities.cs index fa984158..28b7610d 100644 --- a/TabletopTweaks/NewUnitParts/UnitPartPseudoActivatableAbilities.cs +++ b/TabletopTweaks/NewUnitParts/UnitPartPseudoActivatableAbilities.cs @@ -1,5 +1,4 @@ -using HarmonyLib; -using Kingmaker.Blueprints; +using Kingmaker.Blueprints; using Kingmaker.EntitySystem; using Kingmaker.PubSubSystem; using Kingmaker.UI.UnitSettings; @@ -17,7 +16,7 @@ using TabletopTweaks.NewUI; namespace TabletopTweaks.NewUnitParts { - public class UnitPartPseudoActivatableAbilities : + public class UnitPartPseudoActivatableAbilities : UnitPart, ISubscriber, IUnitSubscriber, @@ -48,8 +47,7 @@ public void RegisterPseudoActivatableAbilitySlot(MechanicActionBarSlot mechanicS var abilityBlueprint = abilitySlot.PseudoActivatableAbility.Blueprint; if (m_AbilitiesToMechanicSlots.TryGetValue(abilityBlueprint, out var slotRefs)) { slotRefs.Add(new WeakReference(mechanicSlot)); - } - else { + } else { m_AbilitiesToMechanicSlots.Add(abilityBlueprint, new List>() { new WeakReference(mechanicSlot) }); } @@ -162,12 +160,12 @@ public void BuffActivated(BlueprintBuff buff) { // add the to be removed buffs to a collection first, otherwise we'll be modifying m_ActiveWatchedBuffs while using it in the calculation var buffsToRemove = new HashSet(); // double nested loop, but usually buffs are only in one group, and there should be in the order of 10 buffs in a group so this should be fine - foreach(var groupName in groupsForBuff) { - foreach(var buffToRemove in m_GroupsToBuffs[groupName].Where(b => !b.Equals(buffRef) && m_ActiveWatchedBuffs.Contains(b))) { + foreach (var groupName in groupsForBuff) { + foreach (var buffToRemove in m_GroupsToBuffs[groupName].Where(b => !b.Equals(buffRef) && m_ActiveWatchedBuffs.Contains(b))) { buffsToRemove.Add(buffToRemove); } } - foreach(var buffToRemove in buffsToRemove) { + foreach (var buffToRemove in buffsToRemove) { this.Owner.Buffs.RemoveFact(buffToRemove); } } @@ -186,7 +184,7 @@ private void UpdateAbilitiesForBuff(BlueprintBuffReference buff) { if (!m_BuffsToAbilities.TryGetValue(buff, out var abilities)) return; - foreach(var abilityBlueprint in abilities) { + foreach (var abilityBlueprint in abilities) { UpdateStateForAbility(abilityBlueprint); } } @@ -238,15 +236,15 @@ private void UpdateSlotRefs(List> slotRefs, private void Validate() { - foreach(var activeBuff in m_ActiveWatchedBuffs) { + foreach (var activeBuff in m_ActiveWatchedBuffs) { if (!this.Owner.HasFact(activeBuff)) { Main.Log($"WARNING: UnitPartPseudoActivatableAbilities Validation Error on unit \"{Owner.CharacterName}\": buff \"{activeBuff.NameSafe()}\" is in active watched buffs list, but owner does not actually have that buff."); } } foreach (var buff in this.Owner.Buffs) { - if (buff.SourceAbility != null - && buff.SourceAbility.GetComponent() != null + if (buff.SourceAbility != null + && buff.SourceAbility.GetComponent() != null && buff.SourceAbility.GetComponent().Buff.Equals(buff.Blueprint.ToReference()) && !m_ActiveWatchedBuffs.Contains(buff.Blueprint.ToReference())) { Main.Log($"WARNING: UnitPartPseudoActivatableAbilities Validation Error on unit \"{Owner.CharacterName}\": unit has buff \"{buff.Name}\", which is toggled by pseudo activatable ability \"{buff.SourceAbility.NameSafe()}\", but this buff is not present in active watched buff list."); @@ -254,14 +252,14 @@ private void Validate() { } var abilitiesInBuffsDictionary = m_BuffsToAbilities.Values.SelectMany(x => x).ToHashSet(); - foreach(var abilityBlueprint in abilitiesInBuffsDictionary) { + foreach (var abilityBlueprint in abilitiesInBuffsDictionary) { if (!m_AbilitiesToBuffs.ContainsKey(abilityBlueprint)) { Main.Log($"WARNING: UnitPartPseudoActivatableAbilities Validation Error on unit \"{Owner.CharacterName}\": ability \"{abilityBlueprint.NameSafe()}\" is in values of Buff dictionary, but is not a key in Abilities dictionary"); } } var buffsInAbilitiesDictionary = m_AbilitiesToBuffs.Values.SelectMany(x => x).ToHashSet(); - foreach(var buff in buffsInAbilitiesDictionary) { + foreach (var buff in buffsInAbilitiesDictionary) { if (!m_BuffsToAbilities.ContainsKey(buff)) { Main.Log($"WARNING: UnitPartPseudoActivatableAbilities Validation Error on unit \"{Owner.CharacterName}\": buff \"{buff.NameSafe()}\" is in values of Abilities dictionary, but is not a key in the Buffs dictionary"); } @@ -284,7 +282,7 @@ private void Validate() { } } - foreach(var buffGroup in m_GroupsToBuffs) { + foreach (var buffGroup in m_GroupsToBuffs) { foreach (var buffRef in buffGroup.Value) { if (!m_BuffsToGroups.ContainsKey(buffRef)) { Main.Log($"WARNING: UnitPartPseudoActivatableAbilities Validation Error on unit \"{Owner.CharacterName}\": buff \"{buffRef.NameSafe()}\" is in group named \"{buffGroup.Key}\" in m_GroupsToBuffs, but this buff is not present as a key in m_BuffsToGroups"); @@ -306,14 +304,14 @@ private void Validate() { foreach (var buffGroup in m_GroupsToBuffs) { var hasBuffs = new HashSet(); - foreach(var buff in buffGroup.Value) { + foreach (var buff in buffGroup.Value) { if (this.Owner.HasFact(buff)) { hasBuffs.Add(buff); } } if (hasBuffs.Count > 1) { Main.Log($"WARNING: UnitPartPseudoActivatableAbilities Validation Error on unit \"{Owner.CharacterName}\": multiple buffs are active for group {buffGroup.Key}. Active buffs: "); - foreach(var activeBuff in hasBuffs) { + foreach (var activeBuff in hasBuffs) { Main.Log($"WARNING: UnitPartPseudoActivatableAbilities Validation Error on unit \"{Owner.CharacterName}\": - {activeBuff.NameSafe()}"); } } diff --git a/TabletopTweaks/Utilities/DescriptionTools.cs b/TabletopTweaks/Utilities/DescriptionTools.cs index 31ec780b..d90c67ad 100644 --- a/TabletopTweaks/Utilities/DescriptionTools.cs +++ b/TabletopTweaks/Utilities/DescriptionTools.cs @@ -101,7 +101,7 @@ static class DescriptionTools { }, new EncyclopediaEntry { Entry = "Saving_Throw", - Patterns = { + Patterns = { "Saving Throw", "Reflex Save", "Will Save", @@ -179,7 +179,7 @@ static class DescriptionTools { }, new EncyclopediaEntry { Entry = "Skills", - Patterns = { + Patterns = { "Skills? Checks?", "Skills?" }