Skip to content

Commit

Permalink
polishing up for release
Browse files Browse the repository at this point in the history
  • Loading branch information
atenfyr committed May 28, 2020
1 parent a00c0da commit a906598
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 28 deletions.
14 changes: 7 additions & 7 deletions BetterTaxes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ public override void PostSetupContent()
{
ModWorld thoriumWorld = thoriumMod.GetModWorld("ThoriumWorld");
Call("AddList", "Thorium");
Call("AddKey", "Thorium", "ragnarok", (Func<bool>)delegate () { return (bool)thoriumWorld.GetType().GetField("downedRealityBreaker").GetValue(thoriumWorld); });
Call("AddKey", "Thorium", "patchwerk", (Func<bool>)delegate () { return (bool)thoriumWorld.GetType().GetField("downedPatchwerk").GetValue(thoriumWorld); });
Call("AddKey", "Thorium", "bloom", (Func<bool>)delegate () { return (bool)thoriumWorld.GetType().GetField("downedBloom").GetValue(thoriumWorld); });
Call("AddKey", "Thorium", "strider", (Func<bool>)delegate () { return (bool)thoriumWorld.GetType().GetField("downedStrider").GetValue(thoriumWorld); });
Call("AddKey", "Thorium", "coznix", (Func<bool>)delegate () { return (bool)thoriumWorld.GetType().GetField("downedFallenBeholder").GetValue(thoriumWorld); });
Call("AddKey", "Thorium", "lich", (Func<bool>)delegate () { return (bool)thoriumWorld.GetType().GetField("downedLich").GetValue(thoriumWorld); });
Call("AddKey", "Thorium", "abyssion", (Func<bool>)delegate () { return (bool)thoriumWorld.GetType().GetField("downedDepthBoss").GetValue(thoriumWorld); });
Call("AddKey", "Thorium", "ragnarok", (Func<bool>)delegate () { return (bool)thoriumWorld.GetType().GetField("downedRealityBreaker").GetValue(thoriumWorld); }, -1);
Call("AddKey", "Thorium", "patchwerk", (Func<bool>)delegate () { return (bool)thoriumWorld.GetType().GetField("downedPatchwerk").GetValue(thoriumWorld); }, -1);
Call("AddKey", "Thorium", "bloom", (Func<bool>)delegate () { return (bool)thoriumWorld.GetType().GetField("downedBloom").GetValue(thoriumWorld); }, -1);
Call("AddKey", "Thorium", "strider", (Func<bool>)delegate () { return (bool)thoriumWorld.GetType().GetField("downedStrider").GetValue(thoriumWorld); }, -1);
Call("AddKey", "Thorium", "coznix", (Func<bool>)delegate () { return (bool)thoriumWorld.GetType().GetField("downedFallenBeholder").GetValue(thoriumWorld); }, -1);
Call("AddKey", "Thorium", "lich", (Func<bool>)delegate () { return (bool)thoriumWorld.GetType().GetField("downedLich").GetValue(thoriumWorld); }, -1);
Call("AddKey", "Thorium", "abyssion", (Func<bool>)delegate () { return (bool)thoriumWorld.GetType().GetField("downedDepthBoss").GetValue(thoriumWorld); }, -1);
}

// HERO's Mod support
Expand Down
5 changes: 3 additions & 2 deletions BetterTaxesConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,15 @@ public Dictionary<string, SpecialInt> GetTaxDefaults()
{
Dictionary<string, SpecialInt> result = StaticConstants.TaxRatesDefaults.ToDictionary(i => i.Key, i => i.Value);

// Here we go ahead and put every single new field we know about into the config and their recommended values, if they exist
// Here we go ahead and put every single new field we know about into the config with their recommended values, if they exist (because otherwise how are you supposed to know about them?)
foreach (KeyValuePair<string, Dictionary<string, Func<bool>>> entry in ModHandler.delegates)
{
if (entry.Key == "Calamity" || entry.Key == "Thorium") continue; // We already have hardcoded recommended values for these lists
foreach (KeyValuePair<string, Func<bool>> entry2 in entry.Value)
{
string statement = entry.Key + "." + entry2.Key;
ModHandler.customStatements.TryGetValue(statement, out int determinedValue);
if (determinedValue > -1) result.Add(statement, determinedValue);
if (!result.ContainsKey(statement) && determinedValue > -1) result.Add(statement, determinedValue);
}
}

Expand All @@ -291,6 +291,7 @@ internal void OnDeserializedMethod(StreamingContext context)
if (TaxRates == null || TaxRates.Count == 0) TaxRates = GetTaxDefaults();
if (MoneyCap > 2000000000) MoneyCap = 2000000000;

// We always sort the config file so that it follows the actual progression of the game, just looks nice
var sortedResults = from entry in TaxRates orderby entry.Value ascending select entry;
TaxRates = sortedResults.ToDictionary(pair => pair.Key, pair => pair.Value);
}
Expand Down
2 changes: 1 addition & 1 deletion GateParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public int CalculateRate()
{
if (entry.Value > taxRate && Interpret(entry.Key)) taxRate = entry.Value;
}
if (taxRate == -1) throw new InvalidConfigException("No statement evaluated to true. To avoid this error, you should map the statement \"Base.always\" to a value to fall back on");
if (taxRate < 1) throw new InvalidConfigException("No statement evaluated to true. To avoid this error, you should map the statement \"Base.always\" to a positive value to fall back on");

if (Main.expertMode && TaxWorld.serverConfig.ExpertModeBoost >= 0) taxRate = (int)(taxRate * TaxWorld.serverConfig.ExpertModeBoost); // Expert mode boost
if (Main.xMas) taxRate = (int)(taxRate * 1.1); // Christmas boost
Expand Down
18 changes: 0 additions & 18 deletions ModHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,6 @@ namespace BetterTaxes
{
public class ModHandler
{
/*public static readonly Dictionary<string, string[]> legacyLists = new Dictionary<string, string[]> {
{ "Thorium", new string[7] { "downedRealityBreaker", "downedPatchwerk", "downedBloom", "downedStrider", "downedFallenBeholder", "downedLich", "downedDepthBoss" } }
};
public static readonly Dictionary<string, string> legacySynonyms = new Dictionary<string, string> {
{ "ragnarok", "downedRealityBreaker" },
{ "patchwerk", "downedPatchwerk" },
{ "bloom", "downedBloom" },
{ "strider", "downedStrider" },
{ "coznix", "downedFallenBeholder" },
{ "lich", "downedLich" },
{ "abyssion", "downedDepthBoss" }
};
public static readonly Dictionary<string, string[]> legacyMods = new Dictionary<string, string[]> {
{ "Thorium", new string[2] { "ThoriumMod", "ThoriumWorld" } }
};*/

internal static Dictionary<string, Dictionary<string, Func<bool>>> delegates = new Dictionary<string, Dictionary<string, Func<bool>>>();

public static GateParser parser;
Expand Down

0 comments on commit a906598

Please sign in to comment.