Пример #1
0
        public bool GetDoerValue_User_Missions(User user, string key, string typeString, out string result)
        {
            bool isBreak = false;

            result = null;
            if (key.StartsWith(StringConst.String_missions_dot))             //任务对象
            {
                key = key.Substring(StringConst.String_missions_dot.Length);
                string missionId;
                int    pos = key.IndexOf(CharConst.Char_Dot);
                if (pos != -1)
                {
                    missionId = key.Substring(0, pos);
                    key       = key.Substring(pos);
                    if (missionId.EndsWith(StringConst.String_t))                     //修改tmpValue
                    {
                        missionId = missionId.Substring(0, missionId.Length - 1);
                        key       = StringConst.String_t + key;
                    }
                }
                else
                {
                    missionId = key;
                    key       = StringConst.String_Empty;
                }

                Mission mission = user.GetMission(missionId);
                if (mission != null)                 //身上有这个任务
                {
                    if (key.Length > 0)
                    {
                        DoerAttrParser doerAttrParser = new DoerAttrParser(mission);
                        result = doerAttrParser.ParseString(typeString + StringConst.String_u + key);
                        return(true);
                    }

                    result = ConvertValue(StringConst.String_1, typeString);
                    return(true);
                }

                if (key.StartsWith(StringConst.String_dot_status))
                {
                    if (user.GetFinishedMissionIds().Contains(missionId))
                    {
                        result = ConvertValue(4, typeString);                         // 已完成
                        return(true);
                    }

                    result = ConvertValue(0, typeString);                     // 未接到
                    return(true);
                }

                return(true);
            }

            return(isBreak);
        }
Пример #2
0
        public static void Test()
        {
            DoerAttrParser doerAttrParser = new DoerAttrParser(Client.instance.user);
            var            result         = "";

            //    result = doerAttrParser.ParseString("{#u.pos2}");
            //    result = doerAttrParser.Parse("{eval((5+4)*6)}");//eval()
            //    result = doerAttrParser.Parse("{#cfgData.CfgItemData.1.icon_path}");//
            //    result = doerAttrParser.Parse("{@hasSubString(abcdef,de)}");//
            //   for (int i = 1; i < 100; i++)
            //   {
            //     result = doerAttrParser.Parse("{random(4,8)}"); //random()
            //     LogCat.log(result);
            //   }
            LogCat.log(result);
        }
        public bool GetDoerValue_User_Items(User user, string key, string typeString, out string result)
        {
            bool isBreak = false;

            result = null;
            if (key.StartsWith(StringConst.String_items_dot))             //物品对象
            {
                key = key.Substring(StringConst.String_items_dot.Length);
                int pos = key.IndexOf(CharConst.Char_Dot);
                if (pos != -1)
                {
                    string itemId = key.Substring(0, pos);
                    key = key.Substring(pos);
                    if (itemId.EndsWith(StringConst.String_t))
                    {
                        itemId = itemId.Substring(0, itemId.Length - 1);
                        key    = StringConst.String_t + key;
                    }

                    if (key.Equals(StringConst.String_dot_count))
                    {
                        result = ConvertValue(user.GetItemCount(itemId), typeString);
                        return(true);
                    }

                    Item item = user.GetItem(itemId);
                    if (item != null)                     //身上有这个物品
                    {
                        var doerAttrParser = new DoerAttrParser(item);
                        result = doerAttrParser.ParseString(typeString + StringConst.String_u + key);
                        return(true);
                    }
                }

                result = ConvertValue(StringConst.String_Empty, typeString);
                return(true);
            }

            return(isBreak);
        }