Ejemplo n.º 1
0
 public virtual String toPPString(IParameter[] params_Renamed, int indents)
 {
     if (params_Renamed != null && params_Renamed.Length > 0)
     {
         StringBuilder buf = new StringBuilder();
         buf.Append("(modify ");
         buf.Append("?" + ((BoundParam)params_Renamed[0]).VariableName + " ");
         for (int idx = 1; idx < params_Renamed.Length; idx++)
         {
             // the parameter should be a deffact
             SlotParam sp = (SlotParam)params_Renamed[idx];
             Slot      s  = sp.SlotValue;
             if (s.Value is BoundParam)
             {
                 buf.Append("(" + s.Name + " ?" + ((BoundParam)s.Value).VariableName + ")");
             }
             else
             {
                 buf.Append("(" + s.Name + " " + s.Value + ")");
             }
         }
         buf.Append(" )");
         return(buf.ToString());
     }
     else
     {
         return("(modify [binding] [deffact])\n" + "Function description:\n" + "\tAllows the user to modify template facts on the fact-list.");
     }
 }
Ejemplo n.º 2
0
        public virtual IReturnVector executeFunction(Rete engine, IParameter[] params_Renamed)
        {
            bool exec = false;

            if (engine != null && params_Renamed != null && params_Renamed.Length >= 2 && params_Renamed[0].ObjectBinding)
            {
                BoundParam bp   = (BoundParam)params_Renamed[0];
                Deffact    fact = (Deffact)bp.Fact;
                try
                {
                    // first retract the fact
                    engine.retractFact(fact);
                    // now modify the fact
                    SlotParam[] sp = new SlotParam[params_Renamed.Length - 1];
                    for (int idx = 0; idx < sp.Length; idx++)
                    {
                        IParameter p = params_Renamed[idx + 1];
                        if (p is SlotParam)
                        {
                            sp[idx] = (SlotParam)p;
                        }
                    }
                    fact.updateSlots(engine, convertToSlots(sp, fact.Deftemplate));
                    if (fact.hasBinding())
                    {
                        fact.resolveValues(engine, triggerFacts);
                        fact = fact.cloneFact();
                    }
                    // now assert the fact using the same fact-id
                    engine.assertFact(fact);
                    exec = true;
                }
                catch (RetractException e)
                {
                    engine.writeMessage(e.Message);
                }
                catch (AssertException e)
                {
                    engine.writeMessage(e.Message);
                }
            }

            DefaultReturnVector rv   = new DefaultReturnVector();
            DefaultReturnValue  rval = new DefaultReturnValue(Constants.BOOLEAN_OBJECT, exec);

            rv.addReturnValue(rval);
            return(rv);
        }
Ejemplo n.º 3
0
 public int StartSlot(int slotType, long slotCost = 0, int playerId = 0, string token = "")
 {
     if (ParseToken(playerId, token))
     {
         SlotParam param = new SlotParam();
         param.player_id = apiPlayerId;
         param.token     = apiToken;
         param.slot_type = slotType;
         param.slot_cost = slotCost;
         string paramJson = JsonUtility.ToJson(param);
         API    api       = new API("startslot.php", "RStartSlot", paramJson, 1);
         param = null; paramJson = "";
         StartCoroutine(Congest.SendPOST(this, api));
         return(api.seed);
     }
     return(0);
 }