Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove superfaction option #65

Merged
merged 1 commit into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
Loading