Exemplo n.º 1
0
        public static Boolean validConditions(Player perso, String req)
        {
            if ((req == null) || (req.Equals("")))
            {
                return(true);
            }
            if (req.Contains("BI"))
            {
                return(false);
            }
            JepInstance jep = new JepInstance();

            if (req.Contains("PO"))
            {
                req = havePO(req, perso);
            }
            req = req.Replace("&", "&&").Replace("=", "==").Replace("|", "||").Replace("!", "!=");
            try
            {
                jep.AddVariable("CI", perso.myStats.GetEffect(EffectEnum.AddIntelligence).Total);
                jep.AddVariable("CV", perso.myStats.GetEffect(EffectEnum.AddVitalite).Total);
                jep.AddVariable("CA", perso.myStats.GetEffect(EffectEnum.AddAgilite).Total);
                jep.AddVariable("CW", perso.myStats.GetEffect(EffectEnum.AddSagesse).Total);
                jep.AddVariable("CC", perso.myStats.GetEffect(EffectEnum.AddChance).Total);
                jep.AddVariable("CS", perso.myStats.GetEffect(EffectEnum.AddForce).Total);

                jep.AddVariable("Ci", perso.myStats.GetEffect(126).Base);
                jep.AddVariable("Cs", perso.myStats.GetEffect(118).Base);
                jep.AddVariable("Cv", perso.myStats.GetEffect(125).Base);
                jep.AddVariable("Ca", perso.myStats.GetEffect(119).Base);
                jep.AddVariable("Cw", perso.myStats.GetEffect(124).Base);
                jep.AddVariable("Cc", perso.myStats.GetEffect(123).Base);

                jep.AddVariable("Ps", perso.Alignement);
                jep.AddVariable("Pa", perso.AlignementLevel);
                jep.AddVariable("PP", perso.getGrade());
                jep.AddVariable("PL", perso.Level);
                jep.AddVariable("PK", perso.Kamas);
                jep.AddVariable("PG", perso.Classe);
                jep.AddVariable("PS", perso.Sexe);
                jep.AddVariable("PZ", true);

                jep.AddVariable("MiS", perso.ID);

                jep.Parse(req);
                Object  result = jep.Evaluate();
                Boolean ok     = false;
                if (result != null)
                {
                    ok = Boolean.Parse(result.ToString());
                }
                return(ok);
            }
            catch (JepException e)
            {
                Logger.Error("An error occurred: " + e.ToString());
            }
            return(true);
        }
Exemplo n.º 2
0
 public MathExpr()
 {
     this.jeb = new JepInstance();
     this.jeb.AddFunction("exp", new MathExp_exp());
     this.jeb.AddFunction("sgn", new MathExp_sgn());
     this.jeb.AddFunction("acot", new MathExp_acot());
     this.jeb.AddFunction("sinh", new MathExp_sinh());
     this.jeb.AddFunction("cosh", new MathExp_cosh());
     this.jeb.AddFunction("tanh", new MathExp_tanh());
     this.jeb.AddFunction("coth", new MathExp_coth());
     this.jeb.AddFunction("log10", new MathExp_log10());
     this.jeb.AddFunction("step", new MathExp_step());
     this.jeb.AddStandardConstants();
     // jeb.addStandardFunctions();
     this.variables = new Dictionary <Variable, int>();
 }
 public void Init(JepInstance jep)
 {
     this.jep = jep;
     foreach (ITokenMatcher matcher in this.m)
     {
         matcher.Init(jep);
     }
     foreach (ITokenFilter filter in this.filters)
     {
         filter.Init(jep);
     }
     foreach (IGrammarMatcher matcher2 in this.g)
     {
         matcher2.Init(jep);
     }
 }
Exemplo n.º 4
0
 public virtual void Init(JepInstance jep)
 {
 }
Exemplo n.º 5
0
 public void Init(JepInstance jep)
 {
 }
Exemplo n.º 6
0
 public void Init(JepInstance jep)
 {
     this.nf = jep.NodeFac;
 }
Exemplo n.º 7
0
 public override void Init(JepInstance j)
 {
 }
Exemplo n.º 8
0
 public void init(JepInstance jep)
 {
     this.nf = jep.NumFac;
 }
Exemplo n.º 9
0
 public BooleanExpression(String expression)
 {
     this.expression = expression;
     jep             = new JepInstance();
     variableNames   = GetVariableNamesFromString();//.ToList();
 }
Exemplo n.º 10
0
 public void Init(JepInstance jep)
 {
     this.nf   = jep.NodeFac;
     this.list = jep.OpTab.GetOperator(0x16);
 }
Exemplo n.º 11
0
 public ShuntingYard(JepInstance jep, List <IGrammarMatcher> gm)
 {
     this.jep      = jep;
     this.matchers = gm;
 }
Exemplo n.º 12
0
 public void Init(JepInstance j)
 {
     this.Init(j.OpTab);
 }
Exemplo n.º 13
0
 public void Init(JepInstance j)
 {
     this.startMatcher.Init(j);
     this.endMatcher.Init(j);
     this.completeMatcher.Init(j);
 }
Exemplo n.º 14
0
 public override void Init(JepInstance j)
 {
     this.ft = j.FunTab;
 }
Exemplo n.º 15
0
 public override void Init(JepInstance jep)
 {
     this.nf = jep.NumFac;
 }
Exemplo n.º 16
0
 public void Init(JepInstance jep)
 {
     this.nf = jep.NodeFac;
     this.ot = jep.OpTab;
 }