Beispiel #1
0
 public static void Repeat(GameContext context, int times, IOJMethod method)
 {
     for (int i = 0; i < times; i++)
     {
         method.Invoke(context);
     }
 }
Beispiel #2
0
 public static void If(GameContext context, bool condition, IOJMethod action)
 {
     if (condition)
     {
         action.Invoke(context);
     }
 }
Beispiel #3
0
        public void MulTest2()
        {
            string    code   = "IncreaseHealth: 4*2";
            IOJMethod method = parser.Parse(code, Filename);

            method.Invoke(context);
            Assert.AreEqual(18, context.hostCard.health);
        }
Beispiel #4
0
        public void CmpTest2()
        {
            string    code   = "if:2 > 1, IncreaseHealth";
            IOJMethod method = parser.Parse(code, Filename);

            method.Invoke(context);
            Assert.AreEqual(15, context.hostCard.health);
        }
Beispiel #5
0
        public void AndTest1()
        {
            string    code   = "if:true && false, IncreaseHealth";
            IOJMethod method = parser.Parse(code, Filename);

            method.Invoke(context);
            Assert.AreEqual(10, context.hostCard.health);
        }
Beispiel #6
0
 public static void ForCards(GameContext context, List <Card> list, IOJMethod method)
 {
     foreach (var card in list)
     {
         context.cursor = card;
         method.Invoke(context);
     }
 }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        public void ExceptionTest()
        {
            string    code   = "setHealth:,,,";
            IOJMethod method = parser.Parse(code, Filename);

            method.Invoke(context);
            Assert.AreEqual(15, context.hostCard.health);
        }
Beispiel #9
0
        public void NullTest()
        {
            string    code   = "setHealth:GetNullCard, 111";
            IOJMethod method = parser.Parse(code, Filename);

            method.Invoke(context);
            Assert.AreEqual(10, context.hostCard.health);
        }
Beispiel #10
0
        public void DefalutArgTest()
        {
            string    code   = "IncreaseHealth";
            IOJMethod method = parser.Parse(code, Filename);

            method.Invoke(context);
            Assert.AreEqual(15, context.hostCard.health);
        }
Beispiel #11
0
        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);
        }
Beispiel #12
0
        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);
        }
Beispiel #13
0
        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);
            }
        }
Beispiel #14
0
 public static void Ifelse(GameContext context, bool condition, IOJMethod action, IOJMethod other)
 {
     if (condition)
     {
         action.Invoke(context);
     }
     else
     {
         other.Invoke(context);
     }
 }
Beispiel #15
0
        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}");
        }
Beispiel #16
0
 public Stmt(IOJMethod method, List <Block> args)
 {
     this.args   = args;
     this.method = method;
 }
Beispiel #17
0
 public Stmt(MethodInfo methodInfo, List <Block> args)
 {
     this.args = args;
     method    = new OJMethodImpl(methodInfo);
 }
Beispiel #18
0
 internal Block SetValue(IOJMethod method)
 {
     FinalType   = FinalReturnType.OJMethod;
     this.method = method;
     return(this);
 }
Beispiel #19
0
 public void AddMethod(string name, IOJMethod method)
 {
     data[name] = method;
 }
Beispiel #20
0
 public static void Do(GameContext gameContext, IOJMethod oJMethod1, IOJMethod oJMethod2)
 {
     // 改装成可变参数
 }
Beispiel #21
0
 public static void StartTurn(GameContext context, IOJMethod method)
 {
     context.hostCard.TurnStart = method;
 }