public static void Repeat(GameContext context, int times, IOJMethod method) { for (int i = 0; i < times; i++) { method.Invoke(context); } }
public static void If(GameContext context, bool condition, IOJMethod action) { if (condition) { action.Invoke(context); } }
public void MulTest2() { string code = "IncreaseHealth: 4*2"; IOJMethod method = parser.Parse(code, Filename); method.Invoke(context); Assert.AreEqual(18, context.hostCard.health); }
public void CmpTest2() { string code = "if:2 > 1, IncreaseHealth"; IOJMethod method = parser.Parse(code, Filename); method.Invoke(context); Assert.AreEqual(15, context.hostCard.health); }
public void AndTest1() { string code = "if:true && false, IncreaseHealth"; IOJMethod method = parser.Parse(code, Filename); method.Invoke(context); Assert.AreEqual(10, context.hostCard.health); }
public static void ForCards(GameContext context, List <Card> list, IOJMethod method) { foreach (var card in list) { context.cursor = card; method.Invoke(context); } }
public void NegTest1() { string code = "if:not false, IncreaseHealth: -1"; IOJMethod method = parser.Parse(code, Filename); method.Invoke(context); Assert.AreEqual(9, context.hostCard.health); }
public void ExceptionTest() { string code = "setHealth:,,,"; IOJMethod method = parser.Parse(code, Filename); method.Invoke(context); Assert.AreEqual(15, context.hostCard.health); }
public void NullTest() { string code = "setHealth:GetNullCard, 111"; IOJMethod method = parser.Parse(code, Filename); method.Invoke(context); Assert.AreEqual(10, context.hostCard.health); }
public void DefalutArgTest() { string code = "IncreaseHealth"; IOJMethod method = parser.Parse(code, Filename); method.Invoke(context); Assert.AreEqual(15, context.hostCard.health); }
public void ORTest3() { string code = "if:false or true, IncreaseHealth"; IOJMethod method = parser.Parse(code, Filename); method.Invoke(context); Assert.AreEqual(15, context.hostCard.health); }
public void RemapTest1() { string code = "iftrue: {IncreaseHealth:5}, IncreaseHealth:1"; IOJMethod method = parser.Parse(code, Filename); method.Invoke(context); Assert.AreEqual(15, context.hostCard.health); }
public void ForeachTest() { string code = "ForCards:AllEnemyCards, cur.setHealth:111"; IOJMethod method = parser.Parse(code, Filename); method.Invoke(context); foreach (var card in context.enemies) { Assert.AreEqual(111, card.health); } }
public static void Ifelse(GameContext context, bool condition, IOJMethod action, IOJMethod other) { if (condition) { action.Invoke(context); } else { other.Invoke(context); } }
public static void TestMethod2() { //string code = @"if: true, {IncreaseHealth:;Log:'in ',health; iftrue}"; string code = "if:true or false, log:'in'"; Dictionary <string, string> remaps = new Dictionary <string, string>(); remaps.Add("iftrue", "if:{Equals:health,10},$1"); var parser = new OJParser(typeof(CardCommondDefiner), remaps); IOJMethod method = parser.Parse(code, Filename); GameContext context = new GameContext(); context.hostCard = new Card() { health = 10 }; DateTime time = DateTime.Now; for (int i = 0; i < 1; i++) { method.Invoke(context); } Console.WriteLine($"{DateTime.Now - time}"); }
public Stmt(IOJMethod method, List <Block> args) { this.args = args; this.method = method; }
public Stmt(MethodInfo methodInfo, List <Block> args) { this.args = args; method = new OJMethodImpl(methodInfo); }
internal Block SetValue(IOJMethod method) { FinalType = FinalReturnType.OJMethod; this.method = method; return(this); }
public void AddMethod(string name, IOJMethod method) { data[name] = method; }
public static void Do(GameContext gameContext, IOJMethod oJMethod1, IOJMethod oJMethod2) { // 改装成可变参数 }
public static void StartTurn(GameContext context, IOJMethod method) { context.hostCard.TurnStart = method; }