public Behavior readSettings() //takes same path as carddb { string[] lines = new string[]{}; Helpfunctions.Instance.ErrorLog("read settings.txt"); try { lines = System.IO.File.ReadAllLines(this.path + "settings.txt"); Helpfunctions.Instance.ErrorLog("read carddb.txt"); } catch { Helpfunctions.Instance.logg("cant find settings... take the default ones"); return setDefaultSettings(); } Behavior returnbehav = new BehaviorControl(); foreach (string ss in lines) { string s = ss.Replace(" ", ""); if (s.Contains(";")) s = s.Split(';')[0]; if (s.Contains("#")) s = s.Split('#')[0]; if (s.Contains("//")) s = s.Split(new string[]{"//"}, StringSplitOptions.RemoveEmptyEntries)[0]; if (s.Contains(",")) s = s.Split(',')[0]; if (s == "" || s == " ") continue; s = s.ToLower(); string searchword = "maxwide="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword,""); try { this.maxwide = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "twotsamount="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.twotsamount = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "simenemysecondturn="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.simEnemySecondTurn = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "enfacehp="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.enfacehp = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "playarround="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.playarround = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "playaroundprob="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.playaroundprob = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "playaroundprob2="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.playaroundprob2 = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "enemyturnmaxwide="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.enemyTurnMaxWide = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "enemyturnmaxwidesecondtime="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.enemyTurnMaxWideSecondTime = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "enemysecondturnmaxwide="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.enemySecondTurnMaxWide = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "nextturndeep="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.nextTurnDeep = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "nextturnmaxwide="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.nextTurnMaxWide = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "nextturntotalboards="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.nextTurnTotalBoards = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "usesecretsplayarround="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.useSecretsPlayArround = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "alpha="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.alpha = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "simulateplacement="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.simulatePlacement = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "useexternalprocess="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.useExternalProcess = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "passivewaiting="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.passiveWaiting = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "behave="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); if (a.StartsWith("control")) returnbehav = new BehaviorControl(); if (a.StartsWith("rush")) returnbehav = new BehaviorRush(); if (a.StartsWith("mana")) returnbehav = new BehaviorMana(); if (a.StartsWith("face")) returnbehav = new BehaviorFace(); } } //foreach ended---------- applySettings(); return returnbehav; }
public Behavior readSettings() //takes same path as carddb { string[] lines = new string[] {}; Helpfunctions.Instance.ErrorLog("read settings.txt"); try { lines = System.IO.File.ReadAllLines(this.path + "settings.txt"); Helpfunctions.Instance.ErrorLog("read carddb.txt"); } catch { Helpfunctions.Instance.logg("cant find settings... take the default ones"); return(setDefaultSettings()); } Behavior returnbehav = new BehaviorControl(); foreach (string ss in lines) { string s = ss.Replace(" ", ""); if (s.Contains(";")) { s = s.Split(';')[0]; } if (s.Contains("#")) { s = s.Split('#')[0]; } if (s.Contains("//")) { s = s.Split(new string[] { "//" }, StringSplitOptions.RemoveEmptyEntries)[0]; } if (s.Contains(",")) { s = s.Split(',')[0]; } if (s == "" || s == " ") { continue; } s = s.ToLower(); string searchword = "maxwide="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.maxwide = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "twotsamount="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.twotsamount = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "simenemysecondturn="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.simEnemySecondTurn = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "enfacehp="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.enfacehp = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "playarround="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.playarround = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "playaroundprob="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.playaroundprob = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "playaroundprob2="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.playaroundprob2 = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "enemyturnmaxwide="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.enemyTurnMaxWide = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "enemyturnmaxwidesecondtime="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.enemyTurnMaxWideSecondTime = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "enemysecondturnmaxwide="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.enemySecondTurnMaxWide = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "nextturndeep="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.nextTurnDeep = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "nextturnmaxwide="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.nextTurnMaxWide = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "nextturntotalboards="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.nextTurnTotalBoards = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "usesecretsplayarround="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.useSecretsPlayArround = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "alpha="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.alpha = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "simulateplacement="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.simulatePlacement = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "useexternalprocess="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.useExternalProcess = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "passivewaiting="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.passiveWaiting = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "behave="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); if (a.StartsWith("control")) { returnbehav = new BehaviorControl(); } if (a.StartsWith("rush")) { returnbehav = new BehaviorRush(); } if (a.StartsWith("mana")) { returnbehav = new BehaviorMana(); } if (a.StartsWith("face")) { returnbehav = new BehaviorFace(); } } } //foreach ended---------- applySettings(); return(returnbehav); }
public Behavior readSettings() //takes same path as carddb { string[] lines = new string[]{}; Helpfunctions.Instance.ErrorLog("read settings.txt"); try { lines = System.IO.File.ReadAllLines(this.path + "settings.txt"); Helpfunctions.Instance.ErrorLog("read carddb.txt"); } catch { Helpfunctions.Instance.logg("cant find settings... take the default ones"); return setDefaultSettings(); } Behavior returnbehav = new BehaviorControl(); foreach (string ss in lines) { string s = ss.Replace(" ", ""); if (s.Contains(";")) s = s.Split(';')[0]; if (s.Contains("#")) s = s.Split('#')[0]; if (s.Contains("//")) s = s.Split(new string[]{"//"}, StringSplitOptions.RemoveEmptyEntries)[0]; if (s.Contains(",")) s = s.Split(',')[0]; if (s == "" || s == " ") continue; s = s.ToLower(); string searchword = "maxwide="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword,""); try { this.maxwide = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "twotsamount="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.twotsamount = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "simenemysecondturn="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.simEnemySecondTurn = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "enfacehp="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.enfacehp = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "playarround="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.playarround = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "playaroundprob="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.playaroundprob = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "playaroundprob2="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.playaroundprob2 = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "enemyturnmaxwide="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.enemyTurnMaxWide = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "enemyturnmaxwidesecondtime="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.enemyTurnMaxWideSecondTime = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "enemysecondturnmaxwide="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.enemySecondTurnMaxWide = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "nextturndeep="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.nextTurnDeep = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "nextturnmaxwide="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.nextTurnMaxWide = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "nextturntotalboards="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.nextTurnTotalBoards = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "usesecretsplayarround="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.useSecretsPlayArround = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "alpha="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.alpha = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "simulateplacement="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.simulatePlacement = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "useexternalprocess="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.useExternalProcess = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "passivewaiting="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.passiveWaiting = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "behave="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); if (a.StartsWith("control")) returnbehav = new BehaviorControl(); if (a.StartsWith("rush")) returnbehav = new BehaviorRush(); if (a.StartsWith("mana")) returnbehav = new BehaviorMana(); if (a.StartsWith("face")) returnbehav = new BehaviorFace(); if (a.StartsWith("secretpal")) returnbehav = new BehaviorSecretpal(); if (a.StartsWith("midhunter")) returnbehav = new BehaviorMidHunter(); if (a.StartsWith("tempomage")) returnbehav = new BehaviorTempoMage(); if (a.StartsWith("handlock")) returnbehav = new BehaviorHandlock(); if (a.StartsWith("middruid")) returnbehav = new BehaviorMidDruid(); if (a.StartsWith("midpaladin")) returnbehav = new BehaviorMidPaladin(); } searchword = "concedeonbadboard="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.enemyConcede = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "speed="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.speedy = Convert.ToBoolean(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } //pala searchword = "competitivespiritcount="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.Competitive_Spirit_COUNT = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "noblesacrificecount="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.Noble_Sacrifice_COUNT = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "redemptioncount="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.Redemption_COUNT = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "avengecount="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.Avenge_COUNT = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "repentancecount="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.Repentance_COUNT = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } //hunter secret searchword = "beartrapcount="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.Bear_Trap_COUNT = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "misdirectioncount="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.Misdirection_COUNT = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "snaketrapcount="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.Snake_Trap_COUNT = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "freezingtrapcount="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.Freezing_Trap_COUNT = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "snipecount="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.Snipe_COUNT = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } searchword = "explosivetrapcount="; if (s.StartsWith(searchword)) { string a = s.Replace(searchword, ""); try { this.Explosive_Trap_COUNT = Convert.ToInt32(a); } catch { Helpfunctions.Instance.ErrorLog("ignoring the setting " + searchword); } } } //foreach ended---------- applySettings(); return returnbehav; }