Beispiel #1
0
        public static int GetFianlWingGoodsID(GameClient client, int mergeItemID, int nGoodsID, List <int> nNeedCrystalID)
        {
            List <int> nGoods = MergeNewGoods.GetWingMergeCreateGoodsID(client, mergeItemID);
            int        result;

            if (nGoods == null)
            {
                result = -303;
            }
            else
            {
                int nIndex = -1;
                if (nGoodsID != -1)
                {
                    for (int i = 0; i < nNeedCrystalID.Count; i++)
                    {
                        if (nNeedCrystalID[i] == nGoodsID)
                        {
                            nIndex = i;
                            break;
                        }
                    }
                    if (nIndex == -1)
                    {
                        return(-303);
                    }
                }
                else
                {
                    nIndex = Global.GetRandomNumber(0, 3);
                }
                if (nIndex < 0 || nIndex > 3)
                {
                    nIndex = 0;
                }
                int nWingGoods = nGoods[nIndex];
                result = nWingGoods;
            }
            return(result);
        }
Beispiel #2
0
        public static int Process(GameClient client, int mergeItemID, int luckyGoodsID, int WingDBID, int CrystalDBID, int nUseBindItemFirst)
        {
            CacheMergeItem cacheMergeItem = MergeNewGoods.GetCacheMergeItem(mergeItemID);
            int            result;

            if (null == cacheMergeItem)
            {
                result = -1000;
            }
            else
            {
                if (mergeItemID >= 4 && mergeItemID <= 6)
                {
                    int ret = MergeNewGoods.CanMergeNewGoods(client, cacheMergeItem, cacheMergeItem.NewGoodsID[0], false);
                    if (ret < 0)
                    {
                        return(ret);
                    }
                    ret = MergeNewGoods.ProcessWingMerge(client, mergeItemID, luckyGoodsID, WingDBID, CrystalDBID, cacheMergeItem);
                    if (ret < 0)
                    {
                        return(ret);
                    }
                    ChengJiuManager.OnFirstHeCheng(client);
                    ChengJiuManager.OnRoleGoodsHeCheng(client, cacheMergeItem.NewGoodsID[0]);
                }
                else
                {
                    int ret = MergeNewGoods.ProcessMergeNewGoods(client, mergeItemID, cacheMergeItem, luckyGoodsID, nUseBindItemFirst);
                    if (ret < 0)
                    {
                        return(ret);
                    }
                }
                result = 0;
            }
            return(result);
        }
Beispiel #3
0
 private static int ReloadXmlFile_config_goodsmergeitems()
 {
     return(MergeNewGoods.ReloadCacheMergeItems());
 }
Beispiel #4
0
        public static int ProcessWingMerge(GameClient client, int mergeItemID, int luckyGoodsID, int WingDBID, int CrystalDBID, CacheMergeItem cacheMergeItem)
        {
            GoodsData goodData = null;

            if (mergeItemID == 5 || mergeItemID == 6)
            {
                if (WingDBID < 0)
                {
                    return(-304);
                }
                goodData = Global.GetGoodsByDbID(client, WingDBID);
                if (goodData == null)
                {
                    return(-305);
                }
            }
            bool usedBinding     = false;
            bool usedTimeLimited = false;

            if (cacheMergeItem.OrigGoodsIDList != null)
            {
                for (int i = 0; i < cacheMergeItem.OrigGoodsIDList.Count; i++)
                {
                    GoodsData goodsData = Global.GetGoodsByID(client, cacheMergeItem.OrigGoodsIDList[i]);
                    if (null == goodsData)
                    {
                        return(-301);
                    }
                    if (goodsData.GCount < cacheMergeItem.OrigGoodsNumList[i])
                    {
                        return(-301);
                    }
                }
                for (int i = 0; i < cacheMergeItem.OrigGoodsIDList.Count; i++)
                {
                    if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, cacheMergeItem.OrigGoodsIDList[i], cacheMergeItem.OrigGoodsNumList[i], false, out usedBinding, out usedTimeLimited, true))
                    {
                        return(-301);
                    }
                }
            }
            int        newGoodsBinding = 0;
            List <int> nNeedCrystalID  = MergeNewGoods.GetCrystalIDForWingMerge(client, mergeItemID);
            int        result;

            if (nNeedCrystalID == null)
            {
                result = -302;
            }
            else
            {
                int  nGoodsID         = -1;
                bool usedBinding2     = false;
                bool usedTimeLimited2 = false;
                if (CrystalDBID > 0)
                {
                    GoodsData goodsinfo = Global.GetGoodsByDbID(client, CrystalDBID);
                    if (goodsinfo != null)
                    {
                        nGoodsID = goodsinfo.GoodsID;
                        if (nNeedCrystalID.Count > 0 && !nNeedCrystalID.Contains(nGoodsID))
                        {
                            return(-302);
                        }
                        if (GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodsinfo.GoodsID, 1, false, out usedBinding2, out usedTimeLimited2, false))
                        {
                            if (newGoodsBinding <= 0)
                            {
                                newGoodsBinding = (usedBinding2 ? 1 : 0);
                            }
                        }
                    }
                }
                if (!MergeNewGoods.RollWingMergeSuccess(client, cacheMergeItem, luckyGoodsID))
                {
                    result = -300;
                }
                else
                {
                    int nWingGoods         = MergeNewGoods.GetFianlWingGoodsID(client, mergeItemID, nGoodsID, nNeedCrystalID);
                    int ExcellenceProperty = MergeNewGoods.RollWingGoodsExcellenceProperty(mergeItemID);
                    int nForge             = 0;
                    if (goodData != null)
                    {
                        nForge = goodData.Forge_level;
                    }
                    int dbRet = Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, nWingGoods, 1, 0, "", nForge, newGoodsBinding, 0, "", true, 1, "材料合成新物品--翅膀合成", "1900-01-01 12:00:00", 0, 0, 0, 0, ExcellenceProperty, 0, 0, null, null, 0, true);
                    if (dbRet < 0)
                    {
                        result = -20;
                    }
                    else
                    {
                        if (goodData != null)
                        {
                            bool usedBinding3     = false;
                            bool usedTimeLimited3 = false;
                            GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodData.GoodsID, 1, false, out usedBinding3, out usedTimeLimited3, false);
                        }
                        result = 0;
                    }
                }
            }
            return(result);
        }
Beispiel #5
0
        private static int ProcessMergeNewGoods(GameClient client, int mergeItemID, CacheMergeItem cacheMergeItem, int luckyGoodsID, int nUseBindItemFirst)
        {
            int  newGoodsBinding   = 0;
            int  addSuccessPercent = 0;
            bool bLeftGrid         = false;
            int  nNewGoodsID       = cacheMergeItem.NewGoodsID[0];

            if (cacheMergeItem.NewGoodsID.Count > 1)
            {
                if (!Global.CanAddGoodsNum(client, 1))
                {
                    return(-1);
                }
                nNewGoodsID = cacheMergeItem.NewGoodsID[Global.GetRandomNumber(0, cacheMergeItem.NewGoodsID.Count)];
                bLeftGrid   = true;
            }
            int ret = MergeNewGoods.CanMergeNewGoods(client, cacheMergeItem, nNewGoodsID, bLeftGrid);
            int result;

            if (ret < 0)
            {
                result = ret;
            }
            else
            {
                if (luckyGoodsID > 0)
                {
                    int luckyPercent = Global.GetLuckyValue(luckyGoodsID);
                    if (luckyPercent > 0)
                    {
                        bool usedBinding     = false;
                        bool usedTimeLimited = false;
                        if (GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, luckyGoodsID, 1, false, out usedBinding, out usedTimeLimited, false))
                        {
                            if (newGoodsBinding <= 0)
                            {
                                newGoodsBinding = (usedBinding ? 1 : 0);
                            }
                            addSuccessPercent = luckyPercent;
                        }
                    }
                }
                bool success = MergeNewGoods.JugeSucess(mergeItemID, cacheMergeItem, addSuccessPercent);
                for (int i = 0; i < cacheMergeItem.OrigGoodsIDList.Count; i++)
                {
                    int usingGoodsNum   = MergeNewGoods.GetUsingGoodsNum(success, cacheMergeItem, cacheMergeItem.OrigGoodsIDList[i], cacheMergeItem.OrigGoodsNumList[i]);
                    int nBindGoodNum    = Global.GetTotalBindGoodsCountByID(client, cacheMergeItem.OrigGoodsIDList[i]);
                    int nNotBindGoodNum = Global.GetTotalNotBindGoodsCountByID(client, cacheMergeItem.OrigGoodsIDList[i]);
                    if (usingGoodsNum > nBindGoodNum + nNotBindGoodNum)
                    {
                        return(-10);
                    }
                    bool usedBinding     = false;
                    bool usedTimeLimited = false;
                    if (nUseBindItemFirst > 0 && nBindGoodNum > 0)
                    {
                        int nSum;
                        int nSubNum;
                        if (usingGoodsNum > nBindGoodNum)
                        {
                            nSum    = nBindGoodNum;
                            nSubNum = usingGoodsNum - nBindGoodNum;
                        }
                        else
                        {
                            nSum    = usingGoodsNum;
                            nSubNum = 0;
                        }
                        if (nSum > 0)
                        {
                            if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, cacheMergeItem.OrigGoodsIDList[i], nSum, false, out usedBinding, out usedTimeLimited, true))
                            {
                                return(-10);
                            }
                        }
                        if (nSubNum > 0)
                        {
                            if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, cacheMergeItem.OrigGoodsIDList[i], nSubNum, false, out usedBinding, out usedTimeLimited, true))
                            {
                                return(-10);
                            }
                        }
                        newGoodsBinding = 1;
                    }
                    else
                    {
                        int nSum;
                        int nSubNum;
                        if (usingGoodsNum > nNotBindGoodNum)
                        {
                            nSum    = nNotBindGoodNum;
                            nSubNum = usingGoodsNum - nNotBindGoodNum;
                        }
                        else
                        {
                            nSum    = usingGoodsNum;
                            nSubNum = 0;
                        }
                        if (nSum > 0)
                        {
                            if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, cacheMergeItem.OrigGoodsIDList[i], nSum, false, out usedBinding, out usedTimeLimited, true))
                            {
                                return(-10);
                            }
                        }
                        if (nSubNum > 0)
                        {
                            if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, cacheMergeItem.OrigGoodsIDList[i], nSubNum, false, out usedBinding, out usedTimeLimited, true))
                            {
                                return(-10);
                            }
                            newGoodsBinding = 1;
                        }
                    }
                }
                if (cacheMergeItem.DianJuan > 0)
                {
                    if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, cacheMergeItem.DianJuan, "合成新物品", true, true, false, DaiBiSySType.None))
                    {
                        return(-11);
                    }
                }
                if (cacheMergeItem.Money > 0)
                {
                    if (!Global.SubBindTongQianAndTongQian(client, cacheMergeItem.Money, "材料合成"))
                    {
                        return(-12);
                    }
                }
                if (cacheMergeItem.JingYuan > 0)
                {
                    GameManager.ClientMgr.ModifyTianDiJingYuanValue(client, -cacheMergeItem.JingYuan, "材料合成", true, true, false);
                }
                if (!success)
                {
                    result = -1000;
                }
                else
                {
                    int dbRet = Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, nNewGoodsID, 1, 0, "", 0, newGoodsBinding, 0, "", true, 1, "材料合成新物品", "1900-01-01 12:00:00", 0, 0, 0, 0, 0, 0, 0, null, null, 0, true);
                    if (dbRet < 0)
                    {
                        result = -20;
                    }
                    else
                    {
                        if (90 == Global.GetGoodsCatetoriy(nNewGoodsID))
                        {
                            if (Global.GetJewelLevel(nNewGoodsID) >= 6)
                            {
                                Global.BroadcastMergeJewelOk(client, nNewGoodsID);
                            }
                        }
                        if (120 == Global.GetGoodsCatetoriy(nNewGoodsID))
                        {
                        }
                        ChengJiuManager.OnFirstHeCheng(client);
                        ChengJiuManager.OnRoleGoodsHeCheng(client, nNewGoodsID);
                        SevenDayGoalEventObject evObj = SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.HeChengTimes);
                        evObj.Arg1 = nNewGoodsID;
                        GlobalEventSource.getInstance().fireEvent(evObj);
                        ProcessTask.ProcessAddTaskVal(client, TaskTypes.Merge_GuoShi, cacheMergeItem.MergeType, 1, new object[0]);
                        result = 0;
                    }
                }
            }
            return(result);
        }