Пример #1
0
 public static void Repeat(GameContext context, int times, IOJMethod method)
 {
     for (int i = 0; i < times; i++)
     {
         method.Invoke(context);
     }
 }
Пример #2
0
 public static void If(GameContext context, bool condition, IOJMethod action)
 {
     if (condition)
     {
         action.Invoke(context);
     }
 }
Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #6
0
 public static void ForCards(GameContext context, List <Card> list, IOJMethod method)
 {
     foreach (var card in list)
     {
         context.cursor = card;
         method.Invoke(context);
     }
 }
Пример #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);
        }
Пример #8
0
        public void ExceptionTest()
        {
            string    code   = "setHealth:,,,";
            IOJMethod method = parser.Parse(code, Filename);

            method.Invoke(context);
            Assert.AreEqual(15, context.hostCard.health);
        }
Пример #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);
        }
Пример #10
0
        public void DefalutArgTest()
        {
            string    code   = "IncreaseHealth";
            IOJMethod method = parser.Parse(code, Filename);

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