Ejemplo n.º 1
0
        private Answer ParseAnswer(int answerNum, Regex langEndLine, string[] parts, IEnumerable<string> languages, int nodeNum)
        {
            Answer ans = new Answer();
            ans.ToNode = Int32.Parse(parts[0]);
            foreach (String lang in languages)
            {
                Regex langStartLine = new Regex("^\\[" + lang + "\\]");
                ans.Text[lang] = _textStrings.GetMSGValue(nodeNum*1000 + (answerNum*10), langStartLine, langEndLine);
            }

            if (parts.Length > 3)
            {
                int i = 2;
                bool noRecheck = false;
                Dynamic dyn = null;
                do
                {
                    if (parts[i] == "_script")
                    {
                        FuncCall call = new FuncCall();
                        call.ScriptString = parts[++i];
                        int argsNum = Int32.Parse(parts[++i]);
                        if (argsNum != 0)
                        {
                            for (int k = 0; k < argsNum; k++)
                                call.Args.Add(parts[++i]);
                        }
                        dyn.FuncCall = call;
                        AddDynamic(ans, dyn, noRecheck);
                    }
                    else if (parts[i] == "_item")
                    {
                        dyn.Item = new DialogItem();
                        dyn.ForPlayer = (parts[++i] == "p");
                        dyn.Item.PidDefine = parts[++i];
                        dyn.Operator = Dialog.Dialog.GetOperator(parts[++i]);
                        dyn.Value = Int32.Parse(parts[++i]);
                        AddDynamic(ans, dyn, noRecheck);
                    }
                    else if (parts[i] == "_var")
                    {
                        dyn.Var = new GameVariable();
                        dyn.ForPlayer = (parts[++i] == "p");
                        dyn.Var.Name = parts[++i];
                        dyn.Operator = Dialog.Dialog.GetOperator(parts[++i]);
                        dyn.Value = Int32.Parse(parts[++i]);
                        AddDynamic(ans, dyn, noRecheck);
                    }
                    else if (parts[i] == "_param")
                    {
                        dyn.Param = new Parameter();
                        dyn.ForPlayer = (parts[++i] == "p");
                        dyn.Param.ParamDefine = parts[++i];
                        dyn.Operator = Dialog.Dialog.GetOperator(parts[++i]);
                        dyn.Value = Int32.Parse(parts[++i]);
                        AddDynamic(ans, dyn, noRecheck);
                    }
                    else if (parts[i] == "no_recheck")
                    {
                        noRecheck = true;
                    }
                    else if (parts[i] == "R")
                    {
                        dyn = new Result();
                        noRecheck = false;
                    }
                    else if (parts[i] == "D")
                    {
                        dyn = new Demand();
                        noRecheck = false;
                    }

                    i++;
                } while (i < parts.Length - 1);
            }
            return ans;
        }
Ejemplo n.º 2
0
 private void AddDynamic(Answer answer, Dynamic dynamic, bool recheck)
 {
     if (dynamic is Demand)
     {
         var demand = (Demand)dynamic;
         demand.NoRecheck = recheck;
         answer.Demands.Add(demand);
     }
     if (dynamic is Result)
     {
         var result = (Result)dynamic;
         answer.Results.Add(result);
     }
 }