예제 #1
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);
        }
예제 #2
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);
        }