Skip to content

Commit

Permalink
feat: remove superfaction option (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
sargeantPig authored Sep 8, 2024
1 parent 7d9e909 commit bc151b3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions RTWLibPlus/dataWrappers/ds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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'));
Expand Down
12 changes: 12 additions & 0 deletions RTWLib_CLI/cmd/modules/randomiser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions RTWLib_Tests/wrappers/Tests_ds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IBaseObj> dsParse = this.dp.Parse(ds, Creator.DScreator);
DS parsedds = new(dsParse, this.config);
parsedds.RemoveSuperFaction();
List<IBaseObj> results = parsedds.GetItemsByIdent("superfaction");
Assert.AreEqual(0, results.Count);
}
}

0 comments on commit bc151b3

Please sign in to comment.