diff --git a/RTWLibPlus/dataWrappers/ds.cs b/RTWLibPlus/dataWrappers/ds.cs index e8e2aca..77f44a1 100644 --- a/RTWLibPlus/dataWrappers/ds.cs +++ b/RTWLibPlus/dataWrappers/ds.cs @@ -96,8 +96,6 @@ public void AddUnitToArmy(IBaseObj faction, IBaseObj character, IBaseObj unit) bool add = InsertNewObjectByCriteria(this.Data, unit, faction.Tag, character.Tag, "unit"); } - - public string GetFactionByRegion(string region) { string s = this.GetTagByContentsValue(this.Data, "faction", region); @@ -110,6 +108,8 @@ public string GetFactionByRegion(string region) return s.Split('\t')[1].Trim(','); } + public void RemoveSuperFaction() => this.DeleteChunks("denari", "superfaction"); + public static string GetUnitName(IBaseObj unit) { string name = string.Format("{0} {1}", unit.Tag.Split('\t', StringSplitOptions.RemoveEmptyEntries)[1], unit.Value.GetFirstWord('\t')); diff --git a/RTWLib_CLI/cmd/modules/randomiser.cs b/RTWLib_CLI/cmd/modules/randomiser.cs index ae7bc05..496d522 100644 --- a/RTWLib_CLI/cmd/modules/randomiser.cs +++ b/RTWLib_CLI/cmd/modules/randomiser.cs @@ -87,6 +87,18 @@ public string StratRandomRelations(int range) return RandDS.RandRelations(this.ds, this.smf, this.cm, range); } + public string RemoveSuperfaction() + { + if (this.ds == null) + { + return "DS not loaded - run 'rand initialsetup'"; + } + + this.ds.RemoveSuperFaction(); + + return "Superfaction removed"; + } + public string PaintFactionMap() { FactionMap factionMap = new(); diff --git a/RTWLib_Tests/wrappers/Tests_ds.cs b/RTWLib_Tests/wrappers/Tests_ds.cs index 405e7a9..de78f86 100644 --- a/RTWLib_Tests/wrappers/Tests_ds.cs +++ b/RTWLib_Tests/wrappers/Tests_ds.cs @@ -244,4 +244,14 @@ public void GetFactionRegionsDict() Assert.IsTrue(closestMockOne.SequenceEqual(closeFactions["romans_senate"])); Assert.IsTrue(closestMockTwo.SequenceEqual(closeFactions["britons"])); } + [TestMethod] + public void RemoveSuperFaction() + { + string[] ds = this.dp.ReadFile(RFH.CurrDirPath("resources", "descr_strat.txt"), false); + List dsParse = this.dp.Parse(ds, Creator.DScreator); + DS parsedds = new(dsParse, this.config); + parsedds.RemoveSuperFaction(); + List results = parsedds.GetItemsByIdent("superfaction"); + Assert.AreEqual(0, results.Count); + } }