Exemplo n.º 1
0
        public override void Execute()
        {
            Game g   = Game.GetInstance();
            int  val = rhs.Eval();

            g.Debug("Setting " + obj + "." + attr + " to " + val);

            g.SetObjectAttr(Node.GetLhsObj(obj), attr, val);
        }
Exemplo n.º 2
0
        public override void Execute()
        {
            Game g = Game.GetInstance();

            if (expr.Eval())
            {
                g.Debug("condition is true. executing body");
                body.Execute();
            }
            else if (elseNode != null)
            {
                g.Debug("condition is false. executing else");

                elseNode.Execute();
            }
        }
Exemplo n.º 3
0
        public static Node ToNode(string rhs)
        {
            Game g = Game.GetInstance();

            rhs = rhs.Trim();
            int result;

            if (Int32.TryParse(rhs, out result))
            {
                return(new Constant(result));
            }
            else if (rhs.ToUpper() == "TRUE")
            {
                return(new Constant(1));
            }
            else if (rhs.ToUpper() == "FALSE")
            {
                return(new Constant(0));
            }
            else if (rhs.IndexOf('"') == 0)
            {
                rhs = rhs.Replace("\"", string.Empty);
                return(new Constant(g.GetStringId(rhs)));
            }
            else if (rhs.IndexOf('.') != -1)
            {
                string left  = rhs.Substring(0, rhs.IndexOf('.'));
                string right = rhs.Substring(rhs.IndexOf('.') + 1, rhs.Length - rhs.IndexOf('.') - 1);
                return(new Attr(left, right));
            }
            else if (g.GetObjectId(rhs) != -1)
            {
                return(new Constant(g.GetObjectId(rhs)));
            }
            else if (g.IsVariable(rhs))
            {
                return(new GameVar(rhs));
            }
            else
            {
                throw new Exception("Don't know what to do with " + rhs);
            }
        }
Exemplo n.º 4
0
        public bool Eval()
        {
            Game g = Game.GetInstance();

            g.Debug("Evaluating:" + text);

            if (op.opType == Opr.EQ)
            {
                return(lhs.Eval() == rhs.Eval());
            }
            if (op.opType == Opr.NEQ)
            {
                return(lhs.Eval() != rhs.Eval());
            }
            if (op.opType == Opr.GT)
            {
                return(lhs.Eval() > rhs.Eval());
            }
            if (op.opType == Opr.LT)
            {
                return(lhs.Eval() < rhs.Eval());
            }
            return(false);
        }
Exemplo n.º 5
0
        public override void Execute()
        {
            Game g = Game.GetInstance();

            g.Move();
        }
Exemplo n.º 6
0
        public override void Execute()
        {
            Game g = Game.GetInstance();

            g.PrintStringCr(msg);
        }
Exemplo n.º 7
0
        public override int Eval()
        {
            Game g = Game.GetInstance();

            return(g.GetObjectAttr(GetLhsObj(lhs), attr.ToUpper()));
        }
Exemplo n.º 8
0
        public override int Eval()
        {
            Game g = Game.GetInstance();

            return(g.GetVarVal(name));
        }