diff --git a/RTWLibPlus/randomiser/randEDU.cs b/RTWLibPlus/randomiser/randEDU.cs index 2dba29f..db768bf 100644 --- a/RTWLibPlus/randomiser/randEDU.cs +++ b/RTWLibPlus/randomiser/randEDU.cs @@ -28,34 +28,37 @@ public static string RandomiseOwnership(EDU edu, RandWrap rnd, SMF smf, int maxP { rnd.RefreshRndSeed(); - + List attributes = edu.GetItemsByIdent("attributes"); List ownerships = edu.GetItemsByIdent("ownership"); List factionList = smf.GetFactions(); factionList.Shuffle(rnd.RND); - - foreach (EDUObj ownership in ownerships) + for (int io = 0; io < ownerships.Count; io++) { - + EDUObj ownership = (EDUObj)ownerships[io]; if (factionList.Count < maxPerUnit) { factionList = smf.GetFactions(); factionList.Shuffle(rnd.RND); } - string[] newFactions = new string[maxPerUnit + 1]; + if (attributes[io].Value.Contains("general")) + { + continue; + } + + string[] newFactions = new string[maxPerUnit]; for (int i = 0; i < maxPerUnit; i++) { newFactions[i] = factionList.GetRandom(out int index, rnd.RND); factionList.RemoveAt(index); } - newFactions[^1] = "slave"; - ownership.Value = newFactions.ToString(',', ' '); + ownership.Value = newFactions.ToString(',', ' ') + ", slave"; } AddAttributeAll(edu, "mercenary_unit"); - SetGeneralUnits(edu, smf, rnd, 700, 950); + //SetGeneralUnits(edu, smf, rnd, 700, 950); return "Random ownership complete"; } public static string SetGeneralUnits(EDU edu, SMF smf, RandWrap rnd, int minPriceEarly, int minPriceLate) diff --git a/RTWLib_CLI/Program.cs b/RTWLib_CLI/Program.cs index a149d11..47dce8e 100644 --- a/RTWLib_CLI/Program.cs +++ b/RTWLib_CLI/Program.cs @@ -6,6 +6,7 @@ using RTWLibPlus.data; using RTWLibPlus.helpers; using System; +using System.IO; using System.Reflection; using System.Runtime.CompilerServices; @@ -19,6 +20,9 @@ class Program static void Main(string[] args) { + string wdir = AppDomain.CurrentDomain.BaseDirectory; + Directory.SetCurrentDirectory(wdir); + Console.WriteLine(CMDProcess.LoadTemplates()); Console.WriteLine(CMDProcess.LoadConfigs()); diff --git a/RTWLib_Tests/wrappers/Tests_SMF.cs b/RTWLib_Tests/wrappers/Tests_SMF.cs index 2e445bf..a218858 100644 --- a/RTWLib_Tests/wrappers/Tests_SMF.cs +++ b/RTWLib_Tests/wrappers/Tests_SMF.cs @@ -59,5 +59,18 @@ public void SMFCheckDataIsParsedDepth4() Assert.AreEqual(expected, result); } + [TestMethod] + public void SMFGetFactions() + { + string[] smf = this.dp.ReadFile(RFH.CurrDirPath("resources", "descr_sm_factions.txt"), false); + List smfParse = this.dp.Parse(smf, Creator.SMFcreator, ':'); + SMF parsedsmf = new(smfParse, this.config); + + int result = parsedsmf.GetFactions().Count; + int expected = 21; + + Assert.AreEqual(expected, result); + + } } diff --git a/randomiser_config/remaster.json b/randomiser_config/remaster.json index 82b1b04..eae088a 100644 --- a/randomiser_config/remaster.json +++ b/randomiser_config/remaster.json @@ -42,11 +42,11 @@ "roman" ], "FactionCultures": [ - "roman", - "greek", - "carthaginian", - "eastern", - "egyptian", + "roman", + "greek", + "carthaginian", + "eastern", + "egyptian", "barbarian" ], "Paths": { @@ -62,4 +62,4 @@ "BaseFolder": "Mods\\My Mods\\randomiser", "Save": "data", "Load": "vanilla" -} \ No newline at end of file +} diff --git a/randomiser_templates/basic.txt b/randomiser_templates/basic.txt index 3c3987d..4621610 100644 --- a/randomiser_templates/basic.txt +++ b/randomiser_templates/basic.txt @@ -1,6 +1,6 @@ -randcmd setseed yeet yes +randcmd setseed testseed randcmd initialsetup randcmd citiesbasic randcmd ownership 0 3 1 randcmd PaintFactionMap -randcmd output \ No newline at end of file +randcmd output diff --git a/randomiser_templates/default.txt b/randomiser_templates/default.txt index dbcba7c..d23c65d 100644 --- a/randomiser_templates/default.txt +++ b/randomiser_templates/default.txt @@ -1,6 +1,6 @@ -randcmd setseed yeet yes +randcmd setseed testseed randcmd initialsetup randcmd citiesvoronoi randcmd ownership 3 1 randcmd PaintFactionMap -randcmd output \ No newline at end of file +randcmd output