-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fix issue where MRB ratings were downshifted by 1 (from 1->0, 5-4, etc) - Fix issue where Allies chosen after Career end were not treated as allied.
- Loading branch information
Showing
5 changed files
with
155 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using BattleTech; | ||
using Harmony; | ||
using LootMagnet; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.Serialization; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace LootMagnetTests | ||
{ | ||
[TestClass] | ||
public class MRBLevelTests | ||
{ | ||
public TestContext TestContext { get; set; } | ||
|
||
public SimGameState SimGameState; | ||
|
||
const string FactionName = "MRB"; | ||
|
||
[TestInitialize] | ||
public void TestInitialize() | ||
{ | ||
// SGS tries to invoke a LazyInitialize for the queue, which will throw a security error. Work around this. | ||
SimGameState = (SimGameState)FormatterServices.GetUninitializedObject(typeof(SimGameState)); | ||
|
||
// Init story constants | ||
StoryConstantsDef storyConstantsDef = new StoryConstantsDef(); | ||
storyConstantsDef.MRBRepCap = new float[] { 50f, 200f, 500f, 700f, 900f }; | ||
SimGameConstants constants = new SimGameConstants(null, null, null, null, null, null, null, storyConstantsDef, null, null, null, null, null); | ||
|
||
Traverse constantsT = Traverse.Create(SimGameState).Property("Constants"); | ||
constantsT.SetValue(constants); | ||
|
||
// Init the MRB faction | ||
FactionValue mrbFactionValue = new FactionValue(); | ||
Traverse factionValueNameT = Traverse.Create(mrbFactionValue).Property("Name"); | ||
factionValueNameT.SetValue(FactionName); | ||
|
||
Dictionary<int, FactionValue> factionValuesDict = new Dictionary<int, FactionValue> | ||
{ | ||
[12] = mrbFactionValue | ||
}; | ||
|
||
FactionEnumeration factionEnum = FactionEnumeration.Instance; | ||
Traverse initFactionDictT = Traverse.Create(factionEnum).Field("intFactionDict"); | ||
initFactionDictT.SetValue(factionValuesDict); | ||
|
||
// Add the company stat manually (since constructor did not run) | ||
StatCollection companyStats = new StatCollection(); | ||
Traverse companyStatsT = Traverse.Create(SimGameState).Field("companyStats"); | ||
companyStatsT.SetValue(companyStats); | ||
SimGameState.CompanyStats.AddStatistic<int>($"Reputation.{FactionName}", 0); | ||
} | ||
|
||
// RT and BTA both use: MRBRepCap" : [ 50, 200, 500, 700, 900 ], | ||
[TestMethod] | ||
public void TestMRBLevels() | ||
{ | ||
SimGameState.CompanyStats.Set<int>($"Reputation.{FactionName}", 0); | ||
Assert.AreEqual(0, SimGameState.GetCurrentMRBLevel()); | ||
|
||
SimGameState.CompanyStats.Set<int>($"Reputation.{FactionName}", 49); | ||
Assert.AreEqual(0, SimGameState.GetCurrentMRBLevel()); | ||
|
||
SimGameState.CompanyStats.Set<int>($"Reputation.{FactionName}", 50); | ||
Assert.AreEqual(1, SimGameState.GetCurrentMRBLevel()); | ||
|
||
SimGameState.CompanyStats.Set<int>($"Reputation.{FactionName}", 199); | ||
Assert.AreEqual(1, SimGameState.GetCurrentMRBLevel()); | ||
|
||
SimGameState.CompanyStats.Set<int>($"Reputation.{FactionName}", 200); | ||
Assert.AreEqual(2, SimGameState.GetCurrentMRBLevel()); | ||
|
||
SimGameState.CompanyStats.Set<int>($"Reputation.{FactionName}", 499); | ||
Assert.AreEqual(2, SimGameState.GetCurrentMRBLevel()); | ||
|
||
SimGameState.CompanyStats.Set<int>($"Reputation.{FactionName}", 500); | ||
Assert.AreEqual(3, SimGameState.GetCurrentMRBLevel()); | ||
|
||
SimGameState.CompanyStats.Set<int>($"Reputation.{FactionName}", 699); | ||
Assert.AreEqual(3, SimGameState.GetCurrentMRBLevel()); | ||
|
||
SimGameState.CompanyStats.Set<int>($"Reputation.{FactionName}", 700); | ||
Assert.AreEqual(4, SimGameState.GetCurrentMRBLevel()); | ||
|
||
SimGameState.CompanyStats.Set<int>($"Reputation.{FactionName}", 899); | ||
Assert.AreEqual(4, SimGameState.GetCurrentMRBLevel()); | ||
|
||
SimGameState.CompanyStats.Set<int>($"Reputation.{FactionName}", 900); | ||
Assert.AreEqual(5, SimGameState.GetCurrentMRBLevel()); | ||
|
||
SimGameState.CompanyStats.Set<int>($"Reputation.{FactionName}", 1500); | ||
Assert.AreEqual(5, SimGameState.GetCurrentMRBLevel()); | ||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using LootMagnet; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace LootMagnetTests | ||
{ | ||
[TestClass] | ||
public static class TestGlobalInit | ||
{ | ||
[AssemblyInitialize] | ||
public static void TestInitialize(TestContext testContext) | ||
{ | ||
Mod.Config = new ModConfig(); | ||
Mod.Log = new DeferringLogger(testContext.DeploymentDirectory, "tests", true, true); | ||
} | ||
|
||
[AssemblyCleanup] | ||
public static void TearDown() | ||
{ | ||
|
||
} | ||
} | ||
} |