Skip to content

Commit

Permalink
Linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Vek17 committed Oct 30, 2021
1 parent 772bd2a commit c731e64
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 40 deletions.
2 changes: 1 addition & 1 deletion TabletopTweaks/Bugfixes/Items/Weapons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void PatchTerribleTremble() {
var Ultrasound = Resources.GetBlueprint<BlueprintWeaponEnchantment>("582849db96824254ebcc68f0b7484e51");
var TerrifyingTrembleEnchant_TTT = Resources.GetModBlueprint<BlueprintWeaponEnchantment>("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.");

Expand Down
5 changes: 0 additions & 5 deletions TabletopTweaks/NewComponents/AbilityEffectToggleBuff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions TabletopTweaks/NewComponents/AdditionalSpellSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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; }
Expand All @@ -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);
Expand Down
7 changes: 1 addition & 6 deletions TabletopTweaks/NewContent/Archetypes/MetamagicRager.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
using HarmonyLib;
using Kingmaker.Blueprints;
using Kingmaker.Blueprints;
using Kingmaker.Blueprints.Classes;
using Kingmaker.Blueprints.Classes.Prerequisites;
using Kingmaker.Blueprints.Classes.Selection;
using Kingmaker.Blueprints.Classes.Spells;
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;
Expand Down
2 changes: 1 addition & 1 deletion TabletopTweaks/NewContent/Classes/Loremaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 3 additions & 4 deletions TabletopTweaks/NewUI/ActionBarPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ static bool Prefix(ActionBarSpontaneousConvertedSlot __instance, UnitEntityData
Unit = selected
};
__instance.MechanicSlot.SetSlot(__instance);
}
else if (spell.Blueprint.GetComponent<QuickStudyComponent>()) {
} else if (spell.Blueprint.GetComponent<QuickStudyComponent>()) {
__instance.Selected = selected;
if (selected == null) {
return true;
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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;
Expand Down
32 changes: 15 additions & 17 deletions TabletopTweaks/NewUnitParts/UnitPartPseudoActivatableAbilities.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using HarmonyLib;
using Kingmaker.Blueprints;
using Kingmaker.Blueprints;
using Kingmaker.EntitySystem;
using Kingmaker.PubSubSystem;
using Kingmaker.UI.UnitSettings;
Expand All @@ -17,7 +16,7 @@
using TabletopTweaks.NewUI;

namespace TabletopTweaks.NewUnitParts {
public class UnitPartPseudoActivatableAbilities :
public class UnitPartPseudoActivatableAbilities :
UnitPart,
ISubscriber,
IUnitSubscriber,
Expand Down Expand Up @@ -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<MechanicActionBarSlot>(mechanicSlot));
}
else {
} else {
m_AbilitiesToMechanicSlots.Add(abilityBlueprint, new List<WeakReference<MechanicActionBarSlot>>() { new WeakReference<MechanicActionBarSlot>(mechanicSlot) });
}

Expand Down Expand Up @@ -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<BlueprintBuffReference>();
// 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);
}
}
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -238,30 +236,30 @@ private void UpdateSlotRefs(List<WeakReference<MechanicActionBarSlot>> 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<PseudoActivatable>() != null
if (buff.SourceAbility != null
&& buff.SourceAbility.GetComponent<PseudoActivatable>() != null
&& buff.SourceAbility.GetComponent<PseudoActivatable>().Buff.Equals(buff.Blueprint.ToReference<BlueprintBuffReference>())
&& !m_ActiveWatchedBuffs.Contains(buff.Blueprint.ToReference<BlueprintBuffReference>())) {
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.");
}
}

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");
}
Expand All @@ -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");
Expand All @@ -306,14 +304,14 @@ private void Validate() {

foreach (var buffGroup in m_GroupsToBuffs) {
var hasBuffs = new HashSet<BlueprintBuffReference>();
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()}");
}
}
Expand Down
4 changes: 2 additions & 2 deletions TabletopTweaks/Utilities/DescriptionTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static class DescriptionTools {
},
new EncyclopediaEntry {
Entry = "Saving_Throw",
Patterns = {
Patterns = {
"Saving Throw",
"Reflex Save",
"Will Save",
Expand Down Expand Up @@ -179,7 +179,7 @@ static class DescriptionTools {
},
new EncyclopediaEntry {
Entry = "Skills",
Patterns = {
Patterns = {
"Skills? Checks?",
"Skills?"
}
Expand Down

0 comments on commit c731e64

Please sign in to comment.