private void LoadFromFile() { try { //SaveFileDialog saveDialog = new SaveFileDialog(); //var res = saveDialog.ShowDialog(); Warlock.Reset(); Warlock.LoadGrimoires(LoadGrimoires("./grimoires.dat")); UpdateGrimoireList(); } catch { //Generate(); SaveGrimoires("./grimoires.dat", Warlock.Grimoires); } }
void Generate() { Warlock.Reset(); for (int i = 0; i < 4; i++) { Grimoire grimoire = new Grimoire(); grimoire.Name = $"Default{i}"; Spell a = new Spell(); var eqA = new FirstEqualsSecond("a", "d"); a.SetConditional(eqA); a.AddAction(new WarlockActionEcho("Test")); a.AddAction(new WarlockActionEcho("Test 1")); a.AddAction(new WarlockActionEcho("Test 1")); grimoire.LoadSpells.Add(a); string[] s = new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i" }; Random r = new Random(); stressTestVal = (int)numericUpDownStress.Value; for (int j = 0; j < stressTestVal; j++) { string N() { return(s[r.Next(9)]); } Spell a1 = new Spell(); var aeqC = new EWConditionGroup(); var aeqC1 = new EWConditionGroup(); var aeqC2 = new EWConditionGroup(); //Group1 aeqC1.AddConditional(new FirstEqualsSecond(N(), N())); aeqC1.AddOperator(QuestionOp.AND); aeqC1.AddConditional(new FirstEqualsSecond(N(), N())); aeqC.AddConditional(aeqC1); //if (r.Next(0, 2) == 0) //{ aeqC.AddOperator(QuestionOp.OR); //Group 2 aeqC2.AddConditional(new FirstEqualsSecond("a", "a")); aeqC2.AddOperator(QuestionOp.AND); aeqC2.AddConditional(new FirstEqualsSecond("a", "a")); aeqC.AddConditional(aeqC2); //} a1.SetConditional(aeqC); a1.AddAction(new WarlockActionNone()); grimoire.LoadSpells.Add(a1); } //a.AddAction(new WarlockActionMega()); Spell b = new Spell(); var eqB = new FirstEqualsSecond("a", "b"); b.SetConditional(eqB, true); b.AddAction(new WarlockActionEcho("Test Else")); grimoire.LoadSpells.Add(b); Spell b2 = new Spell(); var eqB2 = new FirstEqualsSecond("a", "a"); b2.SetConditional(eqB2, true); b2.AddAction(new WarlockActionEcho("Test Else 2")); b2.AddAction(new WarlockActionCoroutineTest()); grimoire.LoadSpells.Add(b2); Spell c = new Spell(); //(("a"=="l" AND "c"=="c") OR ("b"=="b" AND "c"=="c")) //should always create group as base, otherwise if only one conditional just set as that conditional var eqC = new EWConditionGroup(); var eqC1 = new EWConditionGroup(); var eqC2 = new EWConditionGroup(); //Group1 eqC1.AddConditional(new FirstEqualsSecond("a", "l")); eqC1.AddOperator(QuestionOp.AND); eqC1.AddConditional(new FirstEqualsSecond("c", "c")); eqC.AddConditional(eqC1); eqC.AddOperator(QuestionOp.OR); //Group 2 eqC2.AddConditional(new FirstEqualsSecond("b", "b")); eqC2.AddOperator(QuestionOp.AND); eqC2.AddConditional(new FirstEqualsSecond("c", "c")); eqC.AddConditional(eqC2); c.SetConditional(eqC); c.AddAction(new WarlockActionEcho("Big Test")); var wam = (WarlockActionMega)FormatterServices.GetUninitializedObject(typeof(WarlockActionMega)); c.AddAction(wam); //c.AddAction(new WarlockActionMega()); //c.AddAction(new WarlockActionMega()); grimoire.PostExecuteSpells.Add(c); Warlock.AddGrimoire(grimoire); buttonTest.Enabled = true; Console.WriteLine("Spell c: " + eqC.ToString()); } UpdateGrimoireList(); //LoadEditor(); }