Beispiel #1
0
        public bool CheckCanUse_ByToType(GameClient client, int goodsID, out string failedMsg)
        {
            failedMsg = "";
            SystemXmlItem systemGoodsItem = null;
            bool          result;

            if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(goodsID, out systemGoodsItem))
            {
                result = false;
            }
            else
            {
                string condIdx = systemGoodsItem.GetStringValue("ToType");
                string condArg = systemGoodsItem.GetStringValue("ToTypeProperty");
                if (string.IsNullOrEmpty(condIdx) || condIdx == "-1")
                {
                    result = true;
                }
                else
                {
                    condIdx = condIdx.ToLower();
                    ICondJudger judger = null;
                    result = (!this.canUseDict.TryGetValue(condIdx, out judger) || judger.Judge(client, condArg, out failedMsg));
                }
            }
            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// 限制类物品检测是否可以使用
        /// </summary>
        /// <param name="client">GameClient</param>
        /// <param name="goodsID">物品ID</param>
        /// <param name="failedMsg">[out]不可使用的信息提示</param>
        /// <returns>可以使用返回True,同时failedMsg为NULL。否则返回False,failedMsg指示不可使用原因</returns>
        public bool CheckCanUse_ByToType(GameClient client, int goodsID, out string failedMsg)
        {
            failedMsg = "";

            SystemXmlItem systemGoodsItem = null;

            if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(goodsID, out systemGoodsItem))
            {
                return(false);
            }

            string condIdx = systemGoodsItem.GetStringValue("ToType");
            string condArg = systemGoodsItem.GetStringValue("ToTypeProperty");

            // 未配置限制条件,认为可以使用
            if (string.IsNullOrEmpty(condIdx) || condIdx == "-1")
            {
                return(true);
            }

            condIdx = condIdx.ToLower();

            ICondJudger judger = null;

            if (!canUseDict.TryGetValue(condIdx, out judger))
            {
                // 没有找到限制处理程序,默认可以使用
                return(true);
            }

            return(judger.Judge(client, condArg, out failedMsg));
        }
Beispiel #3
0
        public GoodsReplaceResult GetReplaceResult(GameClient client, int OriginGoods)
        {
            GoodsReplaceResult result2;

            if (client == null)
            {
                result2 = null;
            }
            else
            {
                GoodsReplaceResult result = new GoodsReplaceResult();
                result.OriginBindGoods.IsBind     = true;
                result.OriginBindGoods.GoodsID    = OriginGoods;
                result.OriginBindGoods.GoodsCnt   = Global.GetTotalBindGoodsCountByID(client, OriginGoods);
                result.OriginUnBindGoods.IsBind   = false;
                result.OriginUnBindGoods.GoodsID  = OriginGoods;
                result.OriginUnBindGoods.GoodsCnt = Global.GetTotalNotBindGoodsCountByID(client, OriginGoods);
                List <GoodsReplaceManager.ReplaceRecord> records = null;
                if (this.replaceDict.TryGetValue(OriginGoods, out records))
                {
                    foreach (GoodsReplaceManager.ReplaceRecord record in records)
                    {
                        ICondJudger judger = null;
                        if (this.replaceJudgerDict.TryGetValue(record.condIdx, out judger))
                        {
                            string strPlaceHolder = string.Empty;
                            if (judger.Judge(client, record.condArg, out strPlaceHolder))
                            {
                                int replaceGoodsID = record.newGoods;
                                int bindCnt        = Global.GetTotalBindGoodsCountByID(client, replaceGoodsID);
                                int unBindCnt      = Global.GetTotalNotBindGoodsCountByID(client, replaceGoodsID);
                                if (bindCnt > 0)
                                {
                                    GoodsReplaceResult.ReplaceItem item = new GoodsReplaceResult.ReplaceItem();
                                    item.IsBind          = true;
                                    item.GoodsID         = replaceGoodsID;
                                    item.GoodsCnt        = bindCnt;
                                    result.TotalBindCnt += bindCnt;
                                    result.BindList.Add(item);
                                }
                                if (unBindCnt > 0)
                                {
                                    GoodsReplaceResult.ReplaceItem item = new GoodsReplaceResult.ReplaceItem();
                                    item.IsBind            = false;
                                    item.GoodsID           = replaceGoodsID;
                                    item.GoodsCnt          = unBindCnt;
                                    result.TotalUnBindCnt += unBindCnt;
                                    result.UnBindList.Add(item);
                                }
                            }
                        }
                    }
                }
                result2 = result;
            }
            return(result2);
        }
Beispiel #4
0
        public GoodsReplaceResult GetReplaceResult(GameClient client, int OriginGoods)
        {
            if (client == null)
            {
                return(null);
            }

            GoodsReplaceResult result = new GoodsReplaceResult();

            result.OriginBindGoods.IsBind   = true;
            result.OriginBindGoods.GoodsID  = OriginGoods;
            result.OriginBindGoods.GoodsCnt = Global.GetTotalBindGoodsCountByID(client, OriginGoods);

            result.OriginUnBindGoods.IsBind   = false;
            result.OriginUnBindGoods.GoodsID  = OriginGoods;
            result.OriginUnBindGoods.GoodsCnt = Global.GetTotalNotBindGoodsCountByID(client, OriginGoods);

            List <ReplaceRecord> records = null;

            if (replaceDict.TryGetValue(OriginGoods, out records))
            {
                foreach (var record in records)
                {
                    ICondJudger judger = null;
                    if (!replaceJudgerDict.TryGetValue(record.condIdx, out judger))
                    {
                        // 抄不到替换规则不可替换
                        continue;
                    }

                    string strPlaceHolder = string.Empty;
                    if (!judger.Judge(client, record.condArg, out strPlaceHolder))
                    {
                        // 不满足替换条件
                        continue;
                    }

                    int replaceGoodsID = record.newGoods;
                    int bindCnt        = Global.GetTotalBindGoodsCountByID(client, replaceGoodsID);
                    int unBindCnt      = Global.GetTotalNotBindGoodsCountByID(client, replaceGoodsID);

                    if (bindCnt > 0)
                    {
                        GoodsReplaceResult.ReplaceItem item = new GoodsReplaceResult.ReplaceItem();
                        item.IsBind          = true;
                        item.GoodsID         = replaceGoodsID;
                        item.GoodsCnt        = bindCnt;
                        result.TotalBindCnt += bindCnt;
                        result.BindList.Add(item);
                    }

                    if (unBindCnt > 0)
                    {
                        GoodsReplaceResult.ReplaceItem item = new GoodsReplaceResult.ReplaceItem();
                        item.IsBind            = false;
                        item.GoodsID           = replaceGoodsID;
                        item.GoodsCnt          = unBindCnt;
                        result.TotalUnBindCnt += unBindCnt;
                        result.UnBindList.Add(item);
                    }
                }
            }

            return(result);
        }