コード例 #1
0
ファイル: Expression.cs プロジェクト: bestm80eva/Lantern
        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);
        }
コード例 #2
0
ファイル: Expression.cs プロジェクト: bestm80eva/Lantern
        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();
            }
        }
コード例 #3
0
ファイル: Expression.cs プロジェクト: bestm80eva/Lantern
        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);
            }
        }
コード例 #4
0
ファイル: Expression.cs プロジェクト: bestm80eva/Lantern
        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);
        }
コード例 #5
0
ファイル: Expression.cs プロジェクト: bestm80eva/Lantern
        public override void Execute()
        {
            Game g = Game.GetInstance();

            g.Move();
        }
コード例 #6
0
ファイル: Expression.cs プロジェクト: bestm80eva/Lantern
        public override void Execute()
        {
            Game g = Game.GetInstance();

            g.PrintStringCr(msg);
        }
コード例 #7
0
ファイル: Expression.cs プロジェクト: bestm80eva/Lantern
        public override int Eval()
        {
            Game g = Game.GetInstance();

            return(g.GetObjectAttr(GetLhsObj(lhs), attr.ToUpper()));
        }
コード例 #8
0
ファイル: Expression.cs プロジェクト: bestm80eva/Lantern
        public override int Eval()
        {
            Game g = Game.GetInstance();

            return(g.GetVarVal(name));
        }