public void ClearCustomCultures( Options options ) { m_log.Log( "Clearing custom cultures from data.", Logger.LogType.Data ); foreach( var pair in m_customCultureGroups ) { options.RuleSet.MaleCultures.Remove( pair.Key ); options.RuleSet.FemaleCultures.Remove( pair.Key ); options.RuleSet.MuslimLawFollowers.Remove( pair.Key ); foreach( Law law in options.RuleSet.LawRules.GenderLaws ) { law.AllowedCultures.Remove( pair.Key ); law.BannedCultures.Remove( pair.Key ); } foreach( Law law in options.RuleSet.LawRules.SuccessionLaws ) { law.AllowedCultures.Remove( pair.Key ); law.BannedCultures.Remove( pair.Key ); } } foreach( var pair in m_customCultures ) { options.RuleSet.MaleCultures.Remove( pair.Key ); options.RuleSet.FemaleCultures.Remove( pair.Key ); options.RuleSet.MuslimLawFollowers.Remove( pair.Key ); foreach( Law law in options.RuleSet.LawRules.GenderLaws ) { law.AllowedCultures.Remove( pair.Key ); law.BannedCultures.Remove( pair.Key ); } foreach( Law law in options.RuleSet.LawRules.SuccessionLaws ) { law.AllowedCultures.Remove( pair.Key ); law.BannedCultures.Remove( pair.Key ); } } m_useCustomCulture = false; m_customCultureGroups.Clear(); m_customCultures.Clear(); }
private Options GetOptions() { m_log.Log( "Getting Options", Logger.LogType.Data ); Options o = new Options(); Options.CultureOption co; Options.ReligionOption ro; Options.HistoryOption ho; Options.CreateHistoryOption cho; Mod m = GetMod(); #region Culture/Religion if( cbTitleRestrictCulture.SelectedIndex == 0 ) co = Options.CultureOption.None; else if( cbTitleRestrictCulture.SelectedIndex == 1 ) co = Options.CultureOption.Culture; else co = Options.CultureOption.CultureGroup; if( cbTitleRestrictReligion.SelectedIndex == 0 ) ro = Options.ReligionOption.None; else if( cbTitleRestrictReligion.SelectedIndex == 1 ) ro = Options.ReligionOption.Religion; else ro = Options.ReligionOption.ReligionGroup; #endregion #region History if( cbHistoryMode.SelectedIndex == 0 ) { ho = Options.HistoryOption.None; cho = Options.CreateHistoryOption.None; } else if( cbHistoryMode.SelectedIndex == 1 ) { // Clear history mode. cho = Options.CreateHistoryOption.None; if( cbHistoryClearLevel.SelectedIndex == 0 ) ho = Options.HistoryOption.Duchy; else if( cbHistoryClearLevel.SelectedIndex == 1 ) ho = Options.HistoryOption.Kingdom; else ho = Options.HistoryOption.Empire; } else { // Create history mode. ho = Options.HistoryOption.County; if( cbHistoryCreateType.SelectedIndex == 0 ) cho = Options.CreateHistoryOption.Counts; else if( cbHistoryCreateType.SelectedIndex == 1 ) cho = Options.CreateHistoryOption.Dukes; else if( cbHistoryCreateType.SelectedIndex == 2 ) cho = Options.CreateHistoryOption.Kings; else if( cbHistoryCreateType.SelectedIndex == 3 ) cho = Options.CreateHistoryOption.Empires; else cho = Options.CreateHistoryOption.Random; } #endregion o.ReplaceDeJure = cbTitleReplaceDeJure.Checked; #region Replaces foreach( Mod mod in m_selectedMods ) { if( mod.Replaces.Contains( @"common\landed_titles" ) ) o.Replaces |= Options.EReplace.Titles; if( mod.Replaces.Contains( @"common\cultures" ) ) o.Replaces |= Options.EReplace.Cultures; if( mod.Replaces.Contains( @"common\Religions" ) ) o.Replaces |= Options.EReplace.Religions; if( mod.Replaces.Contains( @"gfx\flags" ) ) o.Replaces |= Options.EReplace.Flags; if( mod.Replaces.Contains( @"localisation" ) ) o.Replaces |= Options.EReplace.Localisation; if( mod.Replaces.Contains( @"history\provinces" ) ) o.Replaces |= Options.EReplace.Provinces; if( mod.Replaces.Contains( @"common\dynasties" ) ) o.Replaces |= Options.EReplace.Dynasties; if( mod.Replaces.Contains( @"common\eu4_converter" ) ) o.Replaces |= Options.EReplace.Converter; } #endregion o.Data = m_ck2Data; o.HistoryState = new HistoryState(); o.ReligionLimit = ro; o.CultureLimit = co; o.History = ho; o.CreateHistoryType = cho; int seed; if( cbHistorySeed.Checked ) seed = (int)nudHistorySeed.Value; else { TimeSpan time = DateTime.Now - new DateTime( 1970, 1, 1, 0, 0, 0 ); seed = (int)time.TotalSeconds; } o.Seed = seed; o.Random = new Random( seed ); o.Data.SetMarkovRandom( o.Random ); o.StartDate = (int)nudStartDate.Value; o.HistoryMaxChar = (int)nudHistoryMaxRealms.Value; o.HistoryMinChar = (int)nudHistoryMinRealms.Value; o.HistoryMaxReps = (int)nudHistoryMaxRepublics.Value; o.HistoryMinReps = (int)nudHistoryMinRepublics.Value; o.HistoryMinTheoc = (int)nudHistoryMinTheocracies.Value; o.HistoryMaxTheoc = (int)nudHistoryMaxTheocracies.Value; o.HistoryCulGroupMin = (int)nudHistoryCulGroupMin.Value; o.HistoryCulGroupMax = (int)nudHistoryCulGroupMax.Value; o.HistoryCulMin = (int)nudHistoryCulMin.Value; o.HistoryCulMax = (int)nudHistoryCulMax.Value; o.Mod = m; o.SelectedMods = m_selectedMods; o.KingdomShortNames = cbTitleShortKingdoms.Checked; o.EmpireShortNames = cbTitleShortEmpires.Checked; o.UseMod = m_selectedMods.Count > 0; o.CreateDuchies = cbTitleCreateDuchies.Checked; o.CreateKingdoms = cbTitleCreateKingdoms.Checked; o.CreateEmpires = cbTitleCreateEmpires.Checked; o.CountyLimit = (int)nudTitleLowerCounty.Value; o.DuchyLimit = (int)nudTitleLowerDuchy.Value; o.KingdomLimit = (int)nudTitleLowerKingdom.Value; o.RandomTitleColour = cbTitleRandomColour.Checked; ParseScripts( o ); o.RuleSet = m_rules; o.CharID = m_rules.CharacterStartID != -1 ? m_rules.CharacterStartID : 100000000; return o; }
private bool UsingCondition( string line, Options o, char level ) { if( line.Equals( "$IfNoCul", StringComparison.InvariantCultureIgnoreCase ) && o.CultureLimit == Options.CultureOption.None ) return true; if( line.Equals( "$IfCul", StringComparison.InvariantCultureIgnoreCase ) && o.CultureLimit == Options.CultureOption.Culture ) return true; if( line.Equals( "$IfCulGroup", StringComparison.InvariantCultureIgnoreCase ) && o.CultureLimit == Options.CultureOption.CultureGroup ) return true; if( line.Equals( "$IfNoRel", StringComparison.InvariantCultureIgnoreCase ) && o.ReligionLimit == Options.ReligionOption.None ) return true; if( line.Equals( "$IfRel", StringComparison.InvariantCultureIgnoreCase ) && o.ReligionLimit == Options.ReligionOption.Religion ) return true; if( line.Equals( "$IfRelGroup", StringComparison.InvariantCultureIgnoreCase ) && o.ReligionLimit == Options.ReligionOption.ReligionGroup ) return true; if( line.Equals( "$IfIsDuchy", StringComparison.InvariantCultureIgnoreCase ) && level == 'd' ) return true; if( line.Equals( "$IfIsKingdom", StringComparison.InvariantCultureIgnoreCase ) && level == 'k' ) return true; if( line.Equals( "$IfIsEmpire", StringComparison.InvariantCultureIgnoreCase ) && level == 'e' ) return true; if( line.Equals( "$IfMakeDeJure", StringComparison.InvariantCultureIgnoreCase ) && o.ReplaceDeJure ) return true; return false; }
private string Parse( List<string> lines, Options o, char level ) { StringBuilder sb = new StringBuilder(); string line; int condLvl = 0, delLevel = 0; bool delLine = false; for( int i = 0; i < lines.Count; i++ ) { line = lines[i].Trim(); if( line.StartsWith( "$EndIf", true, System.Globalization.CultureInfo.InvariantCulture ) ) { if( condLvl == delLevel ) delLine = false; condLvl--; continue; } if( line.StartsWith( "$If", true, System.Globalization.CultureInfo.InvariantCulture ) ) { condLvl++; if( !delLine && !UsingCondition( line, o, level ) ) { delLine = true; delLevel = condLvl; } continue; } if( !delLine ) { sb.AppendLine( lines[i] ); continue; } } return sb.ToString(); }
private void ParseScripts( Options o ) { List<string> scriptLines = new List<string>(); string scriptName; m_log.Log( "Parsing Allows Scripts", Logger.LogType.Data ); scriptName = m_allowsScripts[(string)lbAllowsList.SelectedItem].FullName; scriptLines.AddRange( File.ReadAllLines( scriptName ) ); o.DuchyAllowsScript = Parse( scriptLines, o, 'd' ); o.KingdomAllowsScript = Parse( scriptLines, o, 'k' ); o.EmpireAllowsScript = Parse( scriptLines, o, 'e' ); m_log.Log( "Parsing Gains Scripts", Logger.LogType.Data ); scriptLines.Clear(); scriptName = m_gainsScripts[(string)lbGainsList.SelectedItem].FullName; scriptLines.AddRange( File.ReadAllLines( scriptName ) ); o.DuchyEffectsScript = Parse( scriptLines, o, 'd' ); o.KingdomEffectsScript = Parse( scriptLines, o, 'k' ); o.EmpireEffectsScript = Parse( scriptLines, o, 'e' ); }
private void GetHistoryTasks( List<ITask> taskList, Options options ) { if( options.History != Options.HistoryOption.None ) { if( options.History == Options.HistoryOption.County ) { taskList.Add( new ClearCountsTask( options, m_log ) ); taskList.Add( new ClearDukesTask( options, m_log ) ); taskList.Add( new ClearKingsTask( options, m_log ) ); taskList.Add( new ClearEmperorsTask( options, m_log ) ); } if( options.History == Options.HistoryOption.Duchy ) { taskList.Add( new ClearDukesTask( options, m_log ) ); taskList.Add( new ClearKingsTask( options, m_log ) ); taskList.Add( new ClearEmperorsTask( options, m_log ) ); } if( options.History == Options.HistoryOption.Kingdom ) { taskList.Add( new ClearKingsTask( options, m_log ) ); taskList.Add( new ClearEmperorsTask( options, m_log ) ); } if( options.History == Options.HistoryOption.Empire ) { taskList.Add( new ClearEmperorsTask( options, m_log ) ); } } if( options.CreateHistoryType != Options.CreateHistoryOption.None ) { if( options.RuleSet.ClearCharacters == true ) taskList.Add( new ClearCharactersTask( options, m_log ) ); if( options.CreateHistoryType == Options.CreateHistoryOption.Counts ) taskList.Add( new IndependentCountsTask( options, m_log ) ); if( options.CreateHistoryType == Options.CreateHistoryOption.Dukes ) taskList.Add( new IndependentDukesTask( options, m_log ) ); if( options.CreateHistoryType == Options.CreateHistoryOption.Kings ) taskList.Add( new IndependentKingsTask( options, m_log ) ); if( options.CreateHistoryType == Options.CreateHistoryOption.Empires ) taskList.Add( new IndependentEmperorsTask( options, m_log ) ); if( options.CreateHistoryType == Options.CreateHistoryOption.Random ) taskList.Add( new FullHistoryTask( options, m_log ) ); } }