コード例 #1
0
        public static SystemXmlItem GetEquipUpgradeItemByGoodsID(int goodsID, int maxSuiItID)
        {
            SystemXmlItem systemGoods = null;
            SystemXmlItem result;

            if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(goodsID, out systemGoods))
            {
                result = null;
            }
            else
            {
                int categoriy = systemGoods.GetIntValue("Categoriy", -1);
                if (categoriy < 0 || categoriy >= 49)
                {
                    result = null;
                }
                else
                {
                    int suitID = systemGoods.GetIntValue("SuitID", -1);
                    if (suitID < 1 || suitID > maxSuiItID)
                    {
                        suitID = 1;
                    }
                    result = EquipUpgradeCacheMgr.GetEquipUpgradeCacheItem(categoriy, suitID);
                }
            }
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// 处理装备进阶
        /// </summary>
        /// <param name="goodsDbID"></param>
        /// <param name="ironNum"></param>
        /// <param name="goldRock"></param>
        /// <param name="luckyNum"></param>
        /// <returns></returns>
        public static int ProcessUpgrade(GameClient client, int goodsDbID)
        {
            //判断背包中是否有此物品
            GoodsData goodsData = Global.GetGoodsByDbID(client, goodsDbID);

            if (null == goodsData)
            {
                return(-1);
            }

            if (goodsData.Site != 0) //如果物品不在背包中,拒绝操作
            {
                return(-9998);
            }

            if (goodsData.Using > 0) //如果物品被佩戴在身上, 拒绝操作
            {
                return(-9999);
            }

            //首先判断要进阶的物品是否是装备,如果不是,则返回失败代码
            SystemXmlItem systemGoods = null;

            if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(goodsData.GoodsID, out systemGoods))
            {
                return(-2);
            }

            //判断是否是武器装备
            int categoriy = systemGoods.GetIntValue("Categoriy");

            if (categoriy < (int)ItemCategories.TouKui || categoriy >= (int)ItemCategories.EquipMax)
            {
                return(-3);
            }

            //判断是否已经是最高阶的装备
            int suitID = systemGoods.GetIntValue("SuitID");

            //不用判断,便于将来自由扩展,也不用维护MaxSuitID的值

            /*
             * if (suitID >= Global.MaxSuitID)
             * {
             *  return -4;
             * }
             */

            int toOccupation = systemGoods.GetIntValue("ToOccupation");
            int toSex        = systemGoods.GetIntValue("ToSex");

            int           newGoodsID             = -1;
            SystemXmlItem newGoodsXmlItem        = null;
            Dictionary <int, SystemXmlItem> dict = GameManager.SystemGoods.SystemXmlItemDict;

            foreach (var goodsItem in dict.Values)
            {
                if (categoriy == goodsItem.GetIntValue("Categoriy") &&
                    goodsItem.GetIntValue("SuitID") == (suitID + 1) &&
                    goodsItem.GetIntValue("ToOccupation") == toOccupation &&
                    goodsItem.GetIntValue("ToSex") == toSex)
                {
                    newGoodsXmlItem = goodsItem;
                    newGoodsID      = goodsItem.GetIntValue("ID");
                    break;
                }
            }

            //没有找到下一阶的装备
            if (newGoodsID < 0)
            {
                return(-5);
            }

            //下一阶装备ID
            int nextSuitID = suitID + 1;

            //返回装备进阶配置项
            SystemXmlItem systemEquipUpgradeItem = EquipUpgradeCacheMgr.GetEquipUpgradeCacheItem(categoriy, nextSuitID);

            //相当于前面的最高阶判断
            if (null == systemEquipUpgradeItem)
            {
                return(-4);
            }

            //需要物品 女娲石
            int needGoodsID = systemEquipUpgradeItem.GetIntValue("NeedGoodsID");

            if (needGoodsID < 0)
            {
                return(-6);
            }

            //需要物品数量
            int needGoodsNum = systemEquipUpgradeItem.GetIntValue("GoodsNum");

            if (needGoodsNum <= 0)
            {
                return(-7);
            }

            //需要积分
            int needJiFen = systemEquipUpgradeItem.GetIntValue("JiFen");

            if (needJiFen <= 0)
            {
                return(-8);
            }

            //成功率
            int succeed = systemEquipUpgradeItem.GetIntValue("Succeed") * 100;//为了以10000为标准进行概率判定,乘100

            if (succeed < 0)
            {
                return(-9);
            }

            int  newGoodsBinding = goodsData.Binding;
            bool usedBinding     = false;
            bool usedTimeLimited = false;

            //女娲石数量不够
            if (Global.GetTotalGoodsCountByID(client, needGoodsID) < needGoodsNum)
            {
                return(-10);
            }

            //积分是否足够
            int jiFen = GameManager.ClientMgr.GetZhuangBeiJiFenValue(client);

            if (jiFen < needJiFen)
            {
                return(-11);//装备积分先屏蔽,主要方便测试
            }

            //扣除进阶道具
            if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool,
                                                      Global._TCPManager.TcpOutPacketPool, client, needGoodsID, needGoodsNum, false, out usedBinding, out usedTimeLimited))
            {
                return(-12);
            }

            //成功与否判断
            if (Global.GetRandomNumber(0, 10001) > succeed)
            {
                return(-1000); //进阶没有成功
            }

            //进阶成功,开始装备扣除
            //扣除积分
            GameManager.ClientMgr.ModifyZhuangBeiJiFenValue(client, -needJiFen, true);

            //扣除原有的装备
            if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool,
                                                      Global._TCPManager.TcpOutPacketPool, client, goodsDbID, false))
            {
                return(-14);
            }

            int currentStrong = Math.Max(goodsData.Strong, 0);
            //int currentLucky = Math.Max(0, goodsData.Lucky);
            int currentLucky = 0; //幸运值不带过去

            //给予新的装备
            int dbRet = Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, newGoodsID, 1, goodsData.Quality, "", goodsData.Forge_level,
                                                 goodsData.Binding, 0, goodsData.Jewellist, false, 1, "装备进阶", Global.ConstGoodsEndTime, goodsData.AddPropIndex, goodsData.BornIndex, currentLucky, currentStrong, goodsData.ExcellenceInfo, goodsData.AppendPropLev, goodsData.ChangeLifeLevForEquip, goodsData.WashProps);

            if (dbRet < 0)
            {
                return(-2000);
            }

            //进阶成功(紫色 + 6级以上提示)
            Global.BroadcastEquipUpgradeOk(client, goodsData.GoodsID, newGoodsID, goodsData.Quality, goodsData.Forge_level);

            //处理成就,第一次炼化,炼化就是神装进阶,的确不好理解
            //ChengJiuManager.OnFirstLianHua(client);

            return(dbRet);
        }
コード例 #3
0
        public static int ProcessUpgrade(GameClient client, int goodsDbID)
        {
            GoodsData goodsData = Global.GetGoodsByDbID(client, goodsDbID);
            int       result;

            if (null == goodsData)
            {
                result = -1;
            }
            else if (goodsData.Site != 0)
            {
                result = -9998;
            }
            else if (goodsData.Using > 0)
            {
                result = -9999;
            }
            else
            {
                SystemXmlItem systemGoods = null;
                if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(goodsData.GoodsID, out systemGoods))
                {
                    result = -2;
                }
                else
                {
                    int categoriy = systemGoods.GetIntValue("Categoriy", -1);
                    if (categoriy < 0 || categoriy >= 49)
                    {
                        result = -3;
                    }
                    else
                    {
                        int suitID       = systemGoods.GetIntValue("SuitID", -1);
                        int toOccupation = Global.GetMainOccupationByGoodsID(goodsData.GoodsID);
                        int toSex        = systemGoods.GetIntValue("ToSex", -1);
                        int newGoodsID   = -1;
                        Dictionary <int, SystemXmlItem> dict = GameManager.SystemGoods.SystemXmlItemDict;
                        foreach (SystemXmlItem goodsItem in dict.Values)
                        {
                            int nCmpCategoriy = goodsItem.GetIntValue("Categoriy", -1);
                            int nCmpSuitID    = goodsItem.GetIntValue("SuitID", -1);
                            int nCmpToSex     = goodsItem.GetIntValue("ToSex", -1);
                            int nCmpOccu      = goodsItem.GetIntValue("MainOccupation", -1);
                            if (nCmpCategoriy == categoriy && nCmpSuitID == suitID + 1 && nCmpOccu == toOccupation && nCmpToSex == toSex)
                            {
                                newGoodsID = goodsItem.GetIntValue("ID", -1);
                                break;
                            }
                        }
                        if (newGoodsID < 0)
                        {
                            result = -5;
                        }
                        else
                        {
                            int           nextSuitID             = suitID + 1;
                            SystemXmlItem systemEquipUpgradeItem = EquipUpgradeCacheMgr.GetEquipUpgradeCacheItem(categoriy, nextSuitID);
                            if (null == systemEquipUpgradeItem)
                            {
                                result = -4;
                            }
                            else
                            {
                                int needGoodsID = systemEquipUpgradeItem.GetIntValue("NeedGoodsID", -1);
                                if (needGoodsID < 0)
                                {
                                    result = -6;
                                }
                                else
                                {
                                    int needGoodsNum = systemEquipUpgradeItem.GetIntValue("GoodsNum", -1);
                                    if (needGoodsNum <= 0)
                                    {
                                        result = -7;
                                    }
                                    else
                                    {
                                        int needJiFen = systemEquipUpgradeItem.GetIntValue("JiFen", -1);
                                        if (needJiFen <= 0)
                                        {
                                            result = -8;
                                        }
                                        else
                                        {
                                            int succeed = systemEquipUpgradeItem.GetIntValue("Succeed", -1) * 100;
                                            if (succeed < 0)
                                            {
                                                result = -9;
                                            }
                                            else
                                            {
                                                int  newGoodsBinding = goodsData.Binding;
                                                bool usedBinding     = false;
                                                bool usedTimeLimited = false;
                                                if (Global.GetTotalGoodsCountByID(client, needGoodsID) < needGoodsNum)
                                                {
                                                    result = -10;
                                                }
                                                else
                                                {
                                                    int jiFen = GameManager.ClientMgr.GetZhuangBeiJiFenValue(client);
                                                    if (jiFen < needJiFen)
                                                    {
                                                        result = -11;
                                                    }
                                                    else if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, needGoodsID, needGoodsNum, false, out usedBinding, out usedTimeLimited, false))
                                                    {
                                                        result = -12;
                                                    }
                                                    else if (Global.GetRandomNumber(0, 10001) > succeed)
                                                    {
                                                        result = -1000;
                                                    }
                                                    else
                                                    {
                                                        GameManager.ClientMgr.ModifyZhuangBeiJiFenValue(client, -needJiFen, true, true);
                                                        if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodsDbID, false, false))
                                                        {
                                                            result = -14;
                                                        }
                                                        else
                                                        {
                                                            int currentStrong = Math.Max(goodsData.Strong, 0);
                                                            int currentLucky  = 0;
                                                            int dbRet         = Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, newGoodsID, 1, goodsData.Quality, "", goodsData.Forge_level, goodsData.Binding, 0, goodsData.Jewellist, false, 1, "装备进阶", "1900-01-01 12:00:00", goodsData.AddPropIndex, goodsData.BornIndex, currentLucky, currentStrong, goodsData.ExcellenceInfo, goodsData.AppendPropLev, goodsData.ChangeLifeLevForEquip, goodsData.WashProps, null, 0, true);
                                                            if (dbRet < 0)
                                                            {
                                                                result = -2000;
                                                            }
                                                            else
                                                            {
                                                                Global.BroadcastEquipUpgradeOk(client, goodsData.GoodsID, newGoodsID, goodsData.Quality, goodsData.Forge_level);
                                                                result = dbRet;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }