예제 #1
0
        public bool processCmd(Logic.GameClient client, string[] cmdParams)
        {
            int nID         = (int)TCPGameServerCmds.CMD_SPR_WINGUPGRADE;
            int nRoleID     = Global.SafeConvertToInt32(cmdParams[0]);
            int nUpWingMode = Global.SafeConvertToInt32(cmdParams[1]); //0: 道具进阶, 1: 钻石进阶

            string strCmd = "";

            if (null == client.ClientData.MyWingData)
            {
                strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0);
                client.sendCmd(nID, strCmd);
                return(true);
            }

            // 已到最高级
            if (client.ClientData.MyWingData.WingID >= MUWingsManager.MaxWingID)
            {
                strCmd = string.Format("{0}:{1}:{2}:{3}", -8, nRoleID, 0, 0);
                client.sendCmd(nID, strCmd);
                return(true);
            }

            // 获取进阶信息表
            SystemXmlItem upStarXmlItem = MUWingsManager.GetWingUPCacheItem(client.ClientData.MyWingData.WingID + 1);

            if (null == upStarXmlItem)
            {
                strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0);
                client.sendCmd(nID, strCmd);
                return(true);
            }

            if (0 == nUpWingMode)
            {
                // 获取进阶需要的道具的物品信息
                string strReqItemID = upStarXmlItem.GetStringValue("NeedGoods");

                // 解析物品ID与数量
                string[] itemParams = strReqItemID.Split(',');
                if (null == itemParams || itemParams.Length != 2)
                {
                    strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0);
                    client.sendCmd(nID, strCmd);
                    return(true);
                }

                int originGoodsID  = Convert.ToInt32(itemParams[0]);
                int originGoodsNum = Convert.ToInt32(itemParams[1]);
                if (originGoodsID <= 0 || originGoodsNum <= 0)
                {
                    strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0);
                    client.sendCmd(nID, strCmd);
                    return(true);
                }

                GoodsReplaceResult replaceRet = GoodsReplaceManager.Instance().GetReplaceResult(client, originGoodsID);
                if (replaceRet == null || replaceRet.TotalGoodsCnt() < originGoodsNum)
                {
                    // 物品数量不够
                    strCmd = string.Format("{0}:{1}:{2}:{3}", -4, nRoleID, 0, 0);
                    client.sendCmd(nID, strCmd);
                    return(true);
                }

                List <GoodsReplaceResult.ReplaceItem> realCostList = new List <GoodsReplaceResult.ReplaceItem>();
                // 1:替换后的绑定材料
                // 2:替换后的非绑定材料
                // 3:原始绑定材料
                // 4:原始非绑定材料
                realCostList.AddRange(replaceRet.BindList);
                realCostList.AddRange(replaceRet.UnBindList);
                realCostList.Add(replaceRet.OriginBindGoods);
                realCostList.Add(replaceRet.OriginUnBindGoods);

                int hasUseCnt    = 0;
                int stillNeedCnt = originGoodsNum;
                foreach (var item in realCostList)
                {
                    if (item.GoodsCnt <= 0)
                    {
                        continue;
                    }

                    int realCostCnt = Math.Min(stillNeedCnt, item.GoodsCnt);
                    if (realCostCnt <= 0)
                    {
                        break;
                    }

                    bool bUsedBinding     = false;
                    bool bUsedTimeLimited = false;
                    bool bFailed          = false;
                    if (item.IsBind)
                    {
                        if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool,
                                                                      client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited))
                        {
                            bFailed = true;
                        }
                    }
                    else
                    {
                        if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool,
                                                                         client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited))
                        {
                            bFailed = true;
                        }
                    }

                    stillNeedCnt -= realCostCnt;

                    if (bFailed)
                    {
                        strCmd = string.Format("{0}:{1}:{2}:{3}", -5, nRoleID, 0, 0);
                        client.sendCmd(nID, strCmd);
                        return(true);
                    }
                }
            }
            else
            {
                // 获取进阶需要的钻石数量
                int nReqZuanShi = upStarXmlItem.GetIntValue("NeedZuanShi");
                if (nReqZuanShi <= 0)
                {
                    strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0);
                    client.sendCmd(nID, strCmd);
                    return(true);
                }
                // 判断用户点卷额是否不足【钻石】
                if (client.ClientData.UserMoney < nReqZuanShi)
                {
                    //用户点卷额不足【钻石】
                    strCmd = string.Format("{0}:{1}:{2}:{3}", -6, nRoleID, 0, 0);
                    client.sendCmd(nID, strCmd);
                    return(true);
                }

                //先DBServer请求扣费
                //扣除用户点卷
                if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nReqZuanShi, "翅膀进阶"))
                {
                    //扣除用户点卷失败
                    strCmd = string.Format("{0}:{1}:{2}:{3}", -7, nRoleID, 0, 0);
                    client.sendCmd(nID, strCmd);
                    return(true);
                }
            }

            int nLuckOne     = upStarXmlItem.GetIntValue("LuckyOne");
            int nLuckyTwo    = upStarXmlItem.GetIntValue("LuckyTwo");
            int nLuckTwoRate = (int)(upStarXmlItem.GetDoubleValue("LuckyTwoRate") * 100.0);

            int nNextWingID          = client.ClientData.MyWingData.WingID;
            int nNextJinJieFailedNum = client.ClientData.MyWingData.JinJieFailedNum;
            int nNextStarLevel       = client.ClientData.MyWingData.ForgeLevel;
            int nNextStarExp         = client.ClientData.MyWingData.StarExp;


            // LuckyOne+提升获得幸运点 < LuckyTwo;必定不会提升成功
            if (nLuckOne + client.ClientData.MyWingData.JinJieFailedNum < nLuckyTwo)
            {
                // 幸运点加1
                nNextJinJieFailedNum++;
            }
            // LuckyOne+提升获得幸运点>= LuckyTwo,则根据配置得到LuckyTwoRate概率判定是否能够完成进阶操作
            else if (nLuckOne + client.ClientData.MyWingData.JinJieFailedNum < 110000)
            {
                //
                int nRandNum = Global.GetRandomNumber(0, 100);
                if (nRandNum < nLuckTwoRate)
                {
                    // 进阶成功
                    nNextWingID++;

                    // 幸运点清0
                    nNextJinJieFailedNum = 0;

                    // 星级清0
                    nNextStarLevel = 0;

                    // 星级经验清0
                    nNextStarExp = 0;
                }
                else
                {
                    // 幸运点加1
                    nNextJinJieFailedNum++;
                }
            }
            // LuckyOne+提升获得幸运点>=110000时,进阶必定成功
            else
            {
                // 进阶成功
                nNextWingID++;

                // 幸运点清0
                nNextJinJieFailedNum = 0;

                // 星级清0
                nNextStarLevel = 0;

                // 星级经验清0
                nNextStarExp = 0;
            }

            // 七日活动
            // 翅膀升级和升阶次数,成功失败都算
            GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingSuitStarTimes));

            // 将改变保存到数据库
            int iRet = MUWingsManager.WingUpDBCommand(client, client.ClientData.MyWingData.DbID, nNextWingID, nNextJinJieFailedNum, nNextStarLevel, nNextStarExp, client.ClientData.MyWingData.ZhuLingNum, client.ClientData.MyWingData.ZhuHunNum);

            if (iRet < 0)
            {
                strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0);
                client.sendCmd(nID, strCmd);
                return(true);
            }
            else
            {
                strCmd = string.Format("{0}:{1}:{2}:{3}", 0, nRoleID, nNextWingID, nNextJinJieFailedNum);
                client.sendCmd(nID, strCmd);

                client.ClientData.MyWingData.JinJieFailedNum = nNextJinJieFailedNum;
                if (client.ClientData.MyWingData.WingID != nNextWingID)
                {
                    // 先移除原来的属性
                    if (1 == client.ClientData.MyWingData.Using)
                    {
                        MUWingsManager.UpdateWingDataProps(client, false);
                    }

                    bool oldWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu);

                    // 更新翅膀的新等级,星数
                    client.ClientData.MyWingData.WingID     = nNextWingID;
                    client.ClientData.MyWingData.ForgeLevel = 0;
                    client.ClientData.MyWingData.StarExp    = 0;

                    // 七日活动
                    GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingLevel));

                    bool newWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu);
                    if (!oldWingLingYuOpened && newWingLingYuOpened)
                    {
                        //翎羽功能开启了,初始化
                        LingYuManager.InitAsOpened(client);
                    }

                    // 按新等级增加属性
                    if (1 == client.ClientData.MyWingData.Using)
                    {
                        MUWingsManager.UpdateWingDataProps(client, true);
                        //升阶时候,翅膀的基础属性的改变会影响注魂加成
                        ZhuLingZhuHunManager.UpdateZhuLingZhuHunProps(client);

                        // 通知客户端属性变化
                        GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);

                        // 总生命值和魔法值变化通知(同一个地图才需要通知)
                        GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                    }

                    //[bing] 刷新客户端活动叹号
                    if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriWing))
                    {
                        client._IconStateMgr.AddFlushIconState((ushort)ActivityTipTypes.JieRiActivity, client._IconStateMgr.IsAnyJieRiTipActived());
                        client._IconStateMgr.SendIconStateToClient(client);
                    }
                }
            }

            return(true);
        }
예제 #2
0
        /// <summary>
        /// 洗炼操作
        /// 返回值列表: (操作索引:错误码:DBID:绑定状态:属性列表键值对...)
        /// </summary>
        /// <param name="client"></param>
        /// <param name="dbid"></param>
        /// <param name="washIndex"></param>
        /// <param name="firstUseBinding"></param>
        /// <returns></returns>
        public static bool WashProps(GameClient client, int dbid, int washIndex, bool firstUseBinding, int moneyType)
        {
            int        nID    = (int)TCPGameServerCmds.CMD_SPR_EXEC_WASHPROPS;
            List <int> result = new List <int>();

            result.Add(washIndex);
            result.Add(StdErrorCode.Error_Success);
            result.Add(dbid);
            result.Add(0);

            if (washIndex > WashOperations.WashPropsQuantity || washIndex < WashOperations.WashPropsQuery)
            {
                result[1] = (StdErrorCode.Error_Invalid_Operation);
                client.sendCmd(nID, result);
                return(true);
            }
            if (moneyType < 0 || moneyType > 1)
            {
                result[1] = (StdErrorCode.Error_MoneyType_Not_Select);
                client.sendCmd(nID, result);
                return(true);
            }

            //查找物品
            GoodsData goodsData = Global.GetGoodsByDbID(client, dbid);

            if (null == goodsData)
            {
                result[1] = (StdErrorCode.Error_Invalid_DBID);
                client.sendCmd(nID, result);
                return(true);
            }

            //if (goodsData.Using > 0)
            //{
            //    result.Add(StdErrorCode.Error_Goods_Is_Using);
            //    client.sendCmd(nID, result);
            //    return true;
            //}

            SystemXmlItem xml;

            if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(goodsData.GoodsID, out xml))
            {
                //错误的参数
                result[1] = (StdErrorCode.Error_Config_Fault);
                client.sendCmd(nID, result);
                return(true);
            }

            int           id = xml.GetIntValue("XiLian");
            XiLianShuXing xiLianShuXing;

            if (!XiLianShuXingDict.TryGetValue(id, out xiLianShuXing))
            {
                //错误的参数
                result[1] = (StdErrorCode.Error_Config_Fault);
                client.sendCmd(nID, result);
                return(true);
            }

            if (washIndex == WashOperations.WashPropsQuantity || washIndex == WashOperations.WashPropsActive)
            {
                if (moneyType == 0)
                {
                    if (client.ClientData.Money1 + client.ClientData.YinLiang < xiLianShuXing.NeedJinBi)
                    {
                        result[1] = (StdErrorCode.Error_JinBi_Not_Enough);
                        client.sendCmd(nID, result);
                        return(true);
                    }
                }
                else if (moneyType == 1)
                {
                    if (client.ClientData.UserMoney < xiLianShuXing.NeedZuanShi)
                    {
                        result[1] = (StdErrorCode.Error_ZuanShi_Not_Enough);
                        client.sendCmd(nID, result);
                        return(true);
                    }
                }
            }

            // 根据客户端的请求分别处理洗炼数值和洗练属性两种操作
            if (washIndex == WashOperations.WashPropsActive)
            {
                //洗炼激活
                if (null != goodsData.WashProps && goodsData.WashProps.Count > 0)
                {
                    result[1] = (StdErrorCode.Error_Invalid_Operation);
                    client.sendCmd(nID, result);
                    return(true);
                }

                int        color = Global.GetEquipColor(goodsData);
                XiLianType xiLianType;
                if (color <= 0 || !XiLianTypeDict.TryGetValue(color, out xiLianType) || xiLianType.ShuXingNum <= 0)
                {
                    result[1] = (StdErrorCode.Error_Invalid_Operation);
                    client.sendCmd(nID, result);
                    return(true);
                }

                UpdateGoodsArgs updateGoodsArgs = new UpdateGoodsArgs()
                {
                    RoleID = client.ClientData.RoleID, DbID = dbid
                };
                updateGoodsArgs.WashProps = new List <int>();

                //扣除所需物品
                // 新增材料替换功能,chenjingui
                if (xiLianShuXing.NeedGoodsIDs[0] > 0 && xiLianShuXing.NeedGoodsCounts[0] > 0)
                {
                    client.ClientData._ReplaceExtArg.Reset();
                    if (GoodsReplaceManager.Instance().NeedCheckSuit(Global.GetGoodsCatetoriy(goodsData.GoodsID)))
                    {
                        client.ClientData._ReplaceExtArg.CurrEquipSuit = Global.GetEquipGoodsSuitID(goodsData.GoodsID);
                    }

                    GoodsReplaceResult replaceRet = GoodsReplaceManager.Instance().GetReplaceResult(client, xiLianShuXing.NeedGoodsIDs[0]);
                    if (replaceRet == null || replaceRet.TotalGoodsCnt() < xiLianShuXing.NeedGoodsCounts[0])
                    {
                        result[1] = (StdErrorCode.Error_Goods_Not_Enough);
                        client.sendCmd(nID, result);
                        return(true);
                    }
                    List <GoodsReplaceResult.ReplaceItem> realCostList = new List <GoodsReplaceResult.ReplaceItem>();
                    if (firstUseBinding)
                    {
                        // 1:使用替换后的绑定材料
                        // 2:使用原始的绑定材料
                        // 3:使用替换后的非绑定材料
                        // 4:使用原始的非绑定材料
                        realCostList.AddRange(replaceRet.BindList);
                        realCostList.Add(replaceRet.OriginBindGoods);
                        realCostList.AddRange(replaceRet.UnBindList);
                        realCostList.Add(replaceRet.OriginUnBindGoods);
                    }
                    else
                    {
                        // 1:使用替换后的非绑定材料
                        // 2:使用原始的非绑定材料
                        // 3:使用替换后的绑定材料
                        // 4:使用原始的绑定材料
                        realCostList.AddRange(replaceRet.UnBindList);
                        realCostList.Add(replaceRet.OriginUnBindGoods);
                        realCostList.AddRange(replaceRet.BindList);
                        realCostList.Add(replaceRet.OriginBindGoods);
                    }

                    int stillNeedGoodsCnt = xiLianShuXing.NeedGoodsCounts[0];
                    foreach (var item in realCostList)
                    {
                        if (item.GoodsCnt <= 0)
                        {
                            continue;
                        }

                        int realCostCnt = Math.Min(stillNeedGoodsCnt, item.GoodsCnt);
                        if (realCostCnt <= 0)
                        {
                            break;
                        }

                        bool usedBinding_just_placeholder     = false;
                        bool usedTimeLimited_just_placeholder = false;

                        bool bFailed = false;
                        if (item.IsBind)
                        {
                            if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client,
                                                                          item.GoodsID, realCostCnt, false, out usedBinding_just_placeholder, out usedTimeLimited_just_placeholder))
                            {
                                bFailed = true;
                            }
                            updateGoodsArgs.Binding = 1;
                        }
                        else
                        {
                            if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client,
                                                                             item.GoodsID, realCostCnt, false, out usedBinding_just_placeholder, out usedTimeLimited_just_placeholder))
                            {
                                bFailed = true;
                            }
                        }

                        if (bFailed)
                        {
                            result[1] = (StdErrorCode.Error_Goods_Not_Enough);
                            client.sendCmd(nID, result);
                            return(true);
                        }

                        stillNeedGoodsCnt -= realCostCnt;
                    }
                }

                //随机激活属性
                for (int i = 0; i < xiLianType.ShuXingNum; i++)
                {
                    int rand      = Global.GetRandomNumber(0, PropsIds.Count);
                    int propID    = PropsIds[rand];
                    int propLimit = xiLianShuXing.PromotePropLimit[propID];
                    int propValue = (int)Math.Ceiling(propLimit * xiLianType.FirstShuXing * xiLianType.ShuXingLimitMultiplying);
                    updateGoodsArgs.WashProps.Add(propID);
                    updateGoodsArgs.WashProps.Add(propValue);
                }

                //存盘并通知用户结果
                Global.UpdateGoodsProp(client, goodsData, updateGoodsArgs);
                //写入角色物品的得失行为日志(扩展)
                Global.ModRoleGoodsEvent(client, goodsData, 0, "装备洗炼激活");
                EventLogManager.AddGoodsEvent(client, OpTypes.Forge, OpTags.None, goodsData.GoodsID, goodsData.Id, 0, goodsData.GCount, "装备洗炼激活");

                result[3] = (goodsData.Binding > 0 | updateGoodsArgs.Binding > 0) ? 1 : 0;
                result.AddRange(goodsData.WashProps);
                client.sendCmd(nID, result);
                return(true);
            }
            else if (washIndex == WashOperations.WashPropsQuantity)
            {
                UpdateGoodsArgs updateGoodsArgs = new UpdateGoodsArgs()
                {
                    RoleID = client.ClientData.RoleID, DbID = dbid
                };

                //扣除所需物品
                if (xiLianShuXing.NeedGoodsIDs[0] > 0 && xiLianShuXing.NeedGoodsCounts[0] > 0)
                {
                    client.ClientData._ReplaceExtArg.Reset();
                    if (GoodsReplaceManager.Instance().NeedCheckSuit(Global.GetGoodsCatetoriy(goodsData.GoodsID)))
                    {
                        client.ClientData._ReplaceExtArg.CurrEquipSuit = Global.GetEquipGoodsSuitID(goodsData.GoodsID);
                    }

                    GoodsReplaceResult replaceRet = GoodsReplaceManager.Instance().GetReplaceResult(client, xiLianShuXing.NeedGoodsIDs[0]);
                    if (replaceRet == null || replaceRet.TotalGoodsCnt() < xiLianShuXing.NeedGoodsCounts[0])
                    {
                        result[1] = (StdErrorCode.Error_Goods_Not_Enough);
                        client.sendCmd(nID, result);
                        return(true);
                    }
                    List <GoodsReplaceResult.ReplaceItem> realCostList = new List <GoodsReplaceResult.ReplaceItem>();
                    if (firstUseBinding)
                    {
                        // 1:使用替换后的绑定材料
                        // 2:使用原始的绑定材料
                        // 3:使用替换后的非绑定材料
                        // 4:使用原始的非绑定材料
                        realCostList.AddRange(replaceRet.BindList);
                        realCostList.Add(replaceRet.OriginBindGoods);
                        realCostList.AddRange(replaceRet.UnBindList);
                        realCostList.Add(replaceRet.OriginUnBindGoods);
                    }
                    else
                    {
                        // 1:使用替换后的非绑定材料
                        // 2:使用原始的非绑定材料
                        // 3:使用替换后的绑定材料
                        // 4:使用原始的绑定材料
                        realCostList.AddRange(replaceRet.UnBindList);
                        realCostList.Add(replaceRet.OriginUnBindGoods);
                        realCostList.AddRange(replaceRet.BindList);
                        realCostList.Add(replaceRet.OriginBindGoods);
                    }

                    int stillNeedGoodsCnt = xiLianShuXing.NeedGoodsCounts[0];
                    foreach (var item in realCostList)
                    {
                        if (item.GoodsCnt <= 0)
                        {
                            continue;
                        }

                        int realCostCnt = Math.Min(stillNeedGoodsCnt, item.GoodsCnt);
                        if (realCostCnt <= 0)
                        {
                            break;
                        }

                        bool usedBinding_just_placeholder     = false;
                        bool usedTimeLimited_just_placeholder = false;

                        bool bFailed = false;
                        if (item.IsBind)
                        {
                            if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client,
                                                                          item.GoodsID, realCostCnt, false, out usedBinding_just_placeholder, out usedTimeLimited_just_placeholder))
                            {
                                bFailed = true;
                            }
                            updateGoodsArgs.Binding = 1;
                        }
                        else
                        {
                            if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client,
                                                                             item.GoodsID, realCostCnt, false, out usedBinding_just_placeholder, out usedTimeLimited_just_placeholder))
                            {
                                bFailed = true;
                            }
                        }

                        if (bFailed)
                        {
                            result[1] = (StdErrorCode.Error_Goods_Not_Enough);
                            client.sendCmd(nID, result);
                            return(true);
                        }

                        stillNeedGoodsCnt -= realCostCnt;
                    }
                }

                if (moneyType == 0)
                {
                    Global.SubBindTongQianAndTongQian(client, xiLianShuXing.NeedJinBi, "洗炼");
                }
                else if (moneyType == 1)
                {
                    GameManager.ClientMgr.SubUserMoney(client, xiLianShuXing.NeedZuanShi, "洗炼");
                }

                //从装备颜色获取洗炼类型配置,获取洗炼条目最大值
                int        color = Global.GetEquipColor(goodsData);
                XiLianType xiLianType;
                if (color <= 0 || !XiLianTypeDict.TryGetValue(color, out xiLianType) || xiLianType.ShuXingNum <= 0)
                {
                    result[1] = (StdErrorCode.Error_Invalid_Operation);
                    client.sendCmd(nID, result);
                    return(true);
                }

                //如果没有洗练属性,先生成一份
                if (null == goodsData.WashProps || goodsData.WashProps.Count == 0)
                {
                    List <int> washProps = new List <int>(xiLianType.ShuXingNum * 2);
                    int        maxCount  = xiLianType.ShuXingNum;
                    foreach (var kv in xiLianShuXing.PromotePropLimit)
                    {
                        if (kv.Value > 0)
                        {
                            washProps.Add(kv.Key);
                            washProps.Add(0);
                            if (--maxCount <= 0)
                            {
                                break;
                            }
                        }
                    }

                    ////索引值无效
                    //result[1] = (StdErrorCode.Error_Invalid_Operation);
                    //client.sendCmd(nID, result);
                    //return true;
                    updateGoodsArgs.WashProps = washProps;
                }
                else
                {
                    updateGoodsArgs.WashProps = new List <int>(goodsData.WashProps);
                }

                //洗炼数值
                for (int i = 0; i < updateGoodsArgs.WashProps.Count; i += 2)
                {
                    int propID = updateGoodsArgs.WashProps[i];
                    if (!xiLianShuXing.PromotePropLimit.ContainsKey(propID))
                    {
                        //错误的参数
                        result[1] = (StdErrorCode.Error_Config_Fault);
                        client.sendCmd(nID, result);
                        return(true);
                    }
                    int propValue = updateGoodsArgs.WashProps[i + 1];
                    int propLimit = (int)(xiLianShuXing.PromotePropLimit[propID] * xiLianType.ShuXingLimitMultiplying);
                    if (moneyType == UseMoneyTypes.JinBiOrBindJinBi)
                    {
                        int nRandNum = Global.GetRandomNumber(0, xiLianShuXing.PromoteJinBiRange[propID].Count);
                        propValue += (int)xiLianShuXing.PromoteJinBiRange[propID][nRandNum];
                    }
                    else if (moneyType == UseMoneyTypes.ZuanShi)
                    {
                        int nRandNum = Global.GetRandomNumber(0, xiLianShuXing.PromoteZuanShiRange[propID].Count);
                        propValue += (int)xiLianShuXing.PromoteZuanShiRange[propID][nRandNum];
                    }

                    propValue = Global.Clamp(propValue, 0, propLimit);
                    updateGoodsArgs.WashProps[i + 1] = propValue;
                }

                client.ClientData.TempWashPropsDict[updateGoodsArgs.DbID] = updateGoodsArgs;
                client.ClientData.TempWashPropOperationIndex = washIndex;

                result[3] = (goodsData.Binding > 0 | updateGoodsArgs.Binding > 0) ? 1 : 0;
                result.AddRange(updateGoodsArgs.WashProps);
                client.sendCmd(nID, result);
                return(true);
            }
            else if (washIndex == WashOperations.WashPropsCommit)
            {
                //提交洗练结果
                UpdateGoodsArgs tempWashProps;
                if (!client.ClientData.TempWashPropsDict.TryGetValue(goodsData.Id, out tempWashProps))
                {
                    //索引值无效
                    result[1] = (StdErrorCode.Error_Invalid_Index);
                    client.sendCmd(nID, result);
                    return(true);
                }

                Global.UpdateGoodsProp(client, goodsData, tempWashProps);
                //写入角色物品的得失行为日志(扩展)
                Global.ModRoleGoodsEvent(client, goodsData, 0, "装备洗炼");
                EventLogManager.AddGoodsEvent(client, OpTypes.Forge, OpTags.None, goodsData.GoodsID, goodsData.Id, 0, goodsData.GCount, "装备洗炼");

                client.ClientData.TempWashPropsDict.Remove(goodsData.Id);
                result[3] = (goodsData.Binding > 0) ? 1 : 0;
                result.AddRange(goodsData.WashProps);
                client.sendCmd(nID, result);
                return(true);
            }
            else if (washIndex == WashOperations.WashPropsCancle)
            {
                //取消本次洗炼,与提交(替换)相对
                client.ClientData.TempWashPropsDict.Remove(dbid);
                client.sendCmd(nID, result);
                return(true);
            }
            else if (washIndex == WashOperations.WashPropsQuery)
            {
                //查询未提交的洗炼结果
                UpdateGoodsArgs tempWashProps;
                if (!client.ClientData.TempWashPropsDict.TryGetValue(goodsData.Id, out tempWashProps))
                {
                    result[1] = StdErrorCode.Error_Data_Overdue;
                    client.sendCmd(nID, result);
                    return(true);
                }
                result[0] = client.ClientData.TempWashPropOperationIndex;
                result[2] = tempWashProps.DbID;
                result[3] = tempWashProps.Binding | goodsData.Binding;
                result.AddRange(tempWashProps.WashProps);
                client.sendCmd(nID, result);
                return(true);
            }
            else if (washIndex >= WashOperations.WashProps)
            {
                //洗练属性
                if (washIndex < 0 || null == goodsData.WashProps || goodsData.WashProps.Count / 2 <= washIndex)
                {
                    //索引值无效
                    result[1] = (StdErrorCode.Error_Invalid_Index);
                    client.sendCmd(nID, result);
                    return(true);
                }

                int        color = Global.GetEquipColor(goodsData);
                XiLianType xiLianType;
                if (color <= 0 || !XiLianTypeDict.TryGetValue(color, out xiLianType) || xiLianType.ShuXingNum <= washIndex)
                {
                    result[1] = (StdErrorCode.Error_Invalid_Operation);
                    client.sendCmd(nID, result);
                    return(true);
                }

                UpdateGoodsArgs updateGoodsArgs = new UpdateGoodsArgs()
                {
                    RoleID = client.ClientData.RoleID, DbID = dbid
                };
                updateGoodsArgs.WashProps = new List <int>(goodsData.WashProps);

                //扣除所需物品
                if (xiLianShuXing.NeedGoodsIDs[0] > 0 && xiLianShuXing.NeedGoodsCounts[0] > 0)
                {
                    bool bUsedBinding     = firstUseBinding;
                    bool bUsedTimeLimited = false;

                    //扣除物品
                    if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener,
                                                              Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, xiLianShuXing.NeedGoodsIDs[0], xiLianShuXing.NeedGoodsCounts[0], false, out bUsedBinding, out bUsedTimeLimited))
                    {
                        //索引值无效
                        result[1] = StdErrorCode.Error_Goods_Not_Enough;
                        client.sendCmd(nID, result);
                        return(true);
                    }
                    if (goodsData.Binding == 0 && bUsedBinding)
                    {
                        updateGoodsArgs.Binding = 1;
                    }
                }

                int rand      = Global.GetRandomNumber(0, PropsIds.Count);
                int propID    = PropsIds[rand];
                int propLimit = xiLianShuXing.PromotePropLimit[propID];
                int propValue = (int)Math.Ceiling(propLimit * xiLianType.FirstShuXing * xiLianType.ShuXingLimitMultiplying);

                updateGoodsArgs.WashProps[washIndex * 2]     = propID;
                updateGoodsArgs.WashProps[washIndex * 2 + 1] = propValue;

                client.ClientData.TempWashPropsDict[updateGoodsArgs.DbID] = updateGoodsArgs;
                client.ClientData.TempWashPropOperationIndex = washIndex;

                //通知结果
                result[3] = (goodsData.Binding > 0 | updateGoodsArgs.Binding > 0) ? 1 : 0;
                result.Add(propID);
                result.Add(propValue);
                client.sendCmd(nID, result);
                return(true);
            }
            else
            {
                //错误的参数
                result[1] = (StdErrorCode.Error_Invalid_Index);
                client.sendCmd(nID, result);
                return(true);
            }
        }
예제 #3
0
        /// <summary>
        /// 翅膀升星处理
        /// </summary>
        public bool processCmd(Logic.GameClient client, string[] cmdParams)
        {
            //int nID = (int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR;
            int nRoleID     = Global.SafeConvertToInt32(cmdParams[0]);
            int nUpStarMode = Global.SafeConvertToInt32(cmdParams[1]); //0: 道具升星, 1: 钻石升星

            //string strCmd = "";
            SCWingStarUp scData = null;

            if (null == client.ClientData.MyWingData)
            {
                //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0);
                //client.sendCmd(nID, strCmd);

                scData = new SCWingStarUp(-3, nRoleID, 0, 0);
                client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData);

                return(true);
            }

            // 获取升星信息表
            SystemXmlItem upStarXmlItem = WingStarCacheManager.GetWingStarCacheItem(Global.CalcOriginalOccupationID(client), client.ClientData.MyWingData.WingID, client.ClientData.MyWingData.ForgeLevel + 1);

            if (null == upStarXmlItem)
            {
                //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0);
                //client.sendCmd(nID, strCmd);

                scData = new SCWingStarUp(StdErrorCode.Error_Level_Reach_Max_Level, nRoleID, 0, 0);
                client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData);

                return(true);
            }

            string strWingShengXing = GameManager.systemParamsList.GetParamValueByName("WingShengXing");

            if ("" == strWingShengXing)
            {
                //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0);
                //client.sendCmd(nID, strCmd);

                scData = new SCWingStarUp(-3, nRoleID, 0, 0);
                client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData);

                return(true);
            }

            // 解析升级暴率
            string[] wingShengXing = strWingShengXing.Split(',');
            if (3 != wingShengXing.Length)
            {
                //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0);
                //client.sendCmd(nID, strCmd);
                scData = new SCWingStarUp(-3, nRoleID, 0, 0);
                client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData);

                return(true);
            }

            // 暴率
            int nPowRate = 0;
            // 增加的星经验
            int nAddExp = 0;

            if (0 == nUpStarMode)
            {
                nPowRate = (int)(Convert.ToDouble(wingShengXing[0]) * 100.0);
                nAddExp  = Convert.ToInt32(upStarXmlItem.GetIntValue("GoodsExp"));
            }
            else
            {
                nPowRate = (int)(Convert.ToDouble(wingShengXing[1]) * 100.0);
                nAddExp  = Convert.ToInt32(upStarXmlItem.GetIntValue("ZuanShiExp"));
            }

            // 暴升,乘以经验倍数
            int nRandNum = Global.GetRandomNumber(0, 100);

            if (nRandNum < nPowRate)
            {
                nAddExp *= Convert.ToInt32(wingShengXing[2]);
            }

            int nUpStarReqExp  = upStarXmlItem.GetIntValue("StarExp");
            int nNextStarLevel = client.ClientData.MyWingData.ForgeLevel;
            int nNextStarExp   = 0;

            if (client.ClientData.MyWingData.StarExp + nAddExp >= nUpStarReqExp)
            {
                if (nNextStarLevel < MUWingsManager.MaxWingEnchanceLevel)
                {
                    // 改变星级,剩余的经验改到下级
                    nNextStarLevel += 1;
                    nNextStarExp    = client.ClientData.MyWingData.StarExp + nAddExp - nUpStarReqExp;

                    // 连续升星
                    while (true)
                    {
                        if (nNextStarLevel >= MUWingsManager.MaxWingEnchanceLevel)
                        {
                            break;
                        }

                        SystemXmlItem nextStarXmlItem = WingStarCacheManager.GetWingStarCacheItem(Global.CalcOriginalOccupationID(client), client.ClientData.MyWingData.WingID, nNextStarLevel + 1);
                        if (null == upStarXmlItem)
                        {
                            break;
                        }

                        int nNextUpStarReqExp = nextStarXmlItem.GetIntValue("StarExp");
                        if (nNextStarExp >= nNextUpStarReqExp)
                        {
                            nNextStarLevel += 1;
                            nNextStarExp    = nNextStarExp - nNextUpStarReqExp;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    // 已经达到最高星
                    nNextStarExp = nUpStarReqExp;
                }
            }
            else
            {
                nNextStarExp = client.ClientData.MyWingData.StarExp + nAddExp;
            }

            if (0 == nUpStarMode)
            {
                //获取强化需要的道具的物品ID
                string strReqItemID = upStarXmlItem.GetStringValue("NeedGoods");

                // 解析物品ID与数量
                string[] itemParams = strReqItemID.Split(',');
                if (null == itemParams || itemParams.Length != 2)
                {
                    //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0);
                    //client.sendCmd(nID, strCmd);

                    scData = new SCWingStarUp(-3, nRoleID, 0, 0);
                    client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData);

                    return(true);
                }

                int originGoodsID  = Convert.ToInt32(itemParams[0]);
                int originGoodsNum = Convert.ToInt32(itemParams[1]);
                if (originGoodsID <= 0 || originGoodsNum <= 0)
                {
                    //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0);
                    //client.sendCmd(nID, strCmd);

                    scData = new SCWingStarUp(-3, nRoleID, 0, 0);
                    client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData);

                    return(true);
                }

                GoodsReplaceResult replaceRet = GoodsReplaceManager.Instance().GetReplaceResult(client, originGoodsID);
                if (replaceRet == null || replaceRet.TotalGoodsCnt() < originGoodsNum)
                {
                    // 物品数量不够
                    //strCmd = string.Format("{0}:{1}:{2}:{3}", -4, nRoleID, 0, 0);
                    //client.sendCmd(nID, strCmd);

                    scData = new SCWingStarUp(-4, nRoleID, 0, 0);
                    client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData);

                    return(true);
                }

                List <GoodsReplaceResult.ReplaceItem> realCostList = new List <GoodsReplaceResult.ReplaceItem>();
                // 1:替换后的绑定材料
                // 2:替换后的非绑定材料
                // 3:原始绑定材料
                // 4:原始非绑定材料
                realCostList.AddRange(replaceRet.BindList);
                realCostList.AddRange(replaceRet.UnBindList);
                realCostList.Add(replaceRet.OriginBindGoods);
                realCostList.Add(replaceRet.OriginUnBindGoods);

                int hasUseCnt    = 0;
                int stillNeedCnt = originGoodsNum;
                foreach (var item in realCostList)
                {
                    if (item.GoodsCnt <= 0)
                    {
                        continue;
                    }

                    int realCostCnt = Math.Min(stillNeedCnt, item.GoodsCnt);
                    if (realCostCnt <= 0)
                    {
                        break;
                    }

                    bool bUsedBinding     = false;
                    bool bUsedTimeLimited = false;
                    bool bFailed          = false;
                    if (item.IsBind)
                    {
                        if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool,
                                                                      client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited))
                        {
                            bFailed = true;
                        }
                    }
                    else
                    {
                        if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool,
                                                                         client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited))
                        {
                            bFailed = true;
                        }
                    }

                    stillNeedCnt -= realCostCnt;

                    if (bFailed)
                    {
                        //strCmd = string.Format("{0}:{1}:{2}:{3}", -5, nRoleID, 0, 0);
                        //client.sendCmd(nID, strCmd);

                        scData = new SCWingStarUp(-5, nRoleID, 0, 0);
                        client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData);

                        return(true);
                    }
                }
            }
            else
            {
                // 获取强化需要的钻石数量
                int nReqZuanShi = upStarXmlItem.GetIntValue("NeedZuanShi");
                if (nReqZuanShi <= 0)
                {
                    //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0);
                    //client.sendCmd(nID, strCmd);

                    scData = new SCWingStarUp(-3, nRoleID, 0, 0);
                    client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData);

                    return(true);
                }
                //判断用户点卷额是否不足【钻石】
                if (client.ClientData.UserMoney < nReqZuanShi)
                {
                    //用户点卷额不足【钻石】
                    //strCmd = string.Format("{0}:{1}:{2}:{3}", -6, nRoleID, 0, 0);
                    //client.sendCmd(nID, strCmd);

                    scData = new SCWingStarUp(-6, nRoleID, 0, 0);
                    client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData);

                    return(true);
                }

                //先DBServer请求扣费
                //扣除用户点卷
                if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nReqZuanShi, "翅膀升星"))
                {
                    //扣除用户点卷失败
                    //strCmd = string.Format("{0}:{1}:{2}:{3}", -7, nRoleID, 0, 0);
                    //client.sendCmd(nID, strCmd);

                    scData = new SCWingStarUp(-7, nRoleID, 0, 0);
                    client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData);

                    return(true);
                }
            }

            // 七日活动
            // 翅膀升级和升阶次数,成功失败都算
            GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingSuitStarTimes));

            // 将改变保存到数据库
            int iRet = MUWingsManager.WingUpStarDBCommand(client, client.ClientData.MyWingData.DbID, nNextStarLevel, nNextStarExp);

            if (iRet < 0)
            {
                //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0);
                //client.sendCmd(nID, strCmd);

                scData = new SCWingStarUp(-3, nRoleID, 0, 0);
                client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData);

                return(true);
            }
            else
            {
                //strCmd = string.Format("{0}:{1}:{2}:{3}", 0, nRoleID, nNextStarLevel, nNextStarExp);
                //client.sendCmd(nID, strCmd);

                scData = new SCWingStarUp(0, nRoleID, nNextStarLevel, nNextStarExp);
                client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData);

                client.ClientData.MyWingData.StarExp = nNextStarExp;
                if (client.ClientData.MyWingData.ForgeLevel != nNextStarLevel)
                {
                    // 先移除原来的属性
                    if (1 == client.ClientData.MyWingData.Using)
                    {
                        MUWingsManager.UpdateWingDataProps(client, false);
                    }

                    bool oldWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu);

                    client.ClientData.MyWingData.ForgeLevel = nNextStarLevel;

                    // 七日活动
                    GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingLevel));

                    bool newWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu);
                    if (!oldWingLingYuOpened && newWingLingYuOpened)
                    {
                        // 翎羽功能开启了,执行初始化
                        LingYuManager.InitAsOpened(client);
                    }

                    // 按新等级增加属性
                    if (1 == client.ClientData.MyWingData.Using)
                    {
                        MUWingsManager.UpdateWingDataProps(client, true);
                        //升星时候,翅膀的基础属性的改变会影响注魂加成
                        ZhuLingZhuHunManager.UpdateZhuLingZhuHunProps(client);

                        // 通知客户端属性变化
                        GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);

                        // 总生命值和魔法值变化通知(同一个地图才需要通知)
                        GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                    }

                    //[bing] 刷新客户端活动叹号
                    if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriWing) ||
                        client._IconStateMgr.CheckSpecialActivity(client))
                    {
                        client._IconStateMgr.AddFlushIconState((ushort)ActivityTipTypes.JieRiActivity, client._IconStateMgr.IsAnyJieRiTipActived());
                        client._IconStateMgr.SendIconStateToClient(client);
                    }
                }
            }

            return(true);
        }
예제 #4
0
        public bool processCmd(GameClient client, string[] cmdParams)
        {
            int  nID         = 609;
            int  nRoleID     = Global.SafeConvertToInt32(cmdParams[0]);
            int  nUpWingMode = Global.SafeConvertToInt32(cmdParams[1]);
            bool result;

            if (null == client.ClientData.MyWingData)
            {
                string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[]
                {
                    -3,
                    nRoleID,
                    0,
                    0
                });
                client.sendCmd(nID, strCmd, false);
                result = true;
            }
            else if (client.ClientData.MyWingData.WingID >= MUWingsManager.MaxWingID)
            {
                string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[]
                {
                    -8,
                    nRoleID,
                    0,
                    0
                });
                client.sendCmd(nID, strCmd, false);
                result = true;
            }
            else
            {
                SystemXmlItem upStarXmlItem = MUWingsManager.GetWingUPCacheItem(client.ClientData.MyWingData.WingID + 1);
                if (null == upStarXmlItem)
                {
                    string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[]
                    {
                        -3,
                        nRoleID,
                        0,
                        0
                    });
                    client.sendCmd(nID, strCmd, false);
                    result = true;
                }
                else
                {
                    SystemXmlItem upStarXmlItem2 = WingStarCacheManager.GetWingStarCacheItem(Global.CalcOriginalOccupationID(client), client.ClientData.MyWingData.WingID, client.ClientData.MyWingData.ForgeLevel + 1);
                    if (null != upStarXmlItem2)
                    {
                        string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[]
                        {
                            -3,
                            nRoleID,
                            0,
                            0
                        });
                        client.sendCmd(nID, strCmd, false);
                        result = true;
                    }
                    else
                    {
                        string strCostList = "";
                        if (0 == nUpWingMode)
                        {
                            string   strReqItemID = upStarXmlItem.GetStringValue("NeedGoods");
                            string[] itemParams   = strReqItemID.Split(new char[]
                            {
                                ','
                            });
                            if (itemParams == null || itemParams.Length != 2)
                            {
                                string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[]
                                {
                                    -3,
                                    nRoleID,
                                    0,
                                    0
                                });
                                client.sendCmd(nID, strCmd, false);
                                return(true);
                            }
                            int originGoodsID  = Convert.ToInt32(itemParams[0]);
                            int originGoodsNum = Convert.ToInt32(itemParams[1]);
                            if (originGoodsID <= 0 || originGoodsNum <= 0)
                            {
                                string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[]
                                {
                                    -3,
                                    nRoleID,
                                    0,
                                    0
                                });
                                client.sendCmd(nID, strCmd, false);
                                return(true);
                            }
                            GoodsReplaceResult replaceRet = SingletonTemplate <GoodsReplaceManager> .Instance().GetReplaceResult(client, originGoodsID);

                            if (replaceRet == null || replaceRet.TotalGoodsCnt() < originGoodsNum)
                            {
                                string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[]
                                {
                                    -4,
                                    nRoleID,
                                    0,
                                    0
                                });
                                client.sendCmd(nID, strCmd, false);
                                return(true);
                            }
                            List <GoodsReplaceResult.ReplaceItem> realCostList = new List <GoodsReplaceResult.ReplaceItem>();
                            realCostList.AddRange(replaceRet.BindList);
                            realCostList.AddRange(replaceRet.UnBindList);
                            realCostList.Add(replaceRet.OriginBindGoods);
                            realCostList.Add(replaceRet.OriginUnBindGoods);
                            int stillNeedCnt = originGoodsNum;
                            foreach (GoodsReplaceResult.ReplaceItem item in realCostList)
                            {
                                if (item.GoodsCnt > 0)
                                {
                                    int realCostCnt = Math.Min(stillNeedCnt, item.GoodsCnt);
                                    if (realCostCnt <= 0)
                                    {
                                        break;
                                    }
                                    bool bUsedBinding     = false;
                                    bool bUsedTimeLimited = false;
                                    bool bFailed          = false;
                                    if (item.IsBind)
                                    {
                                        if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited, false))
                                        {
                                            bFailed = true;
                                        }
                                    }
                                    else if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited, false))
                                    {
                                        bFailed = true;
                                    }
                                    stillNeedCnt -= realCostCnt;
                                    if (bFailed)
                                    {
                                        string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[]
                                        {
                                            -5,
                                            nRoleID,
                                            0,
                                            0
                                        });
                                        client.sendCmd(nID, strCmd, false);
                                        return(true);
                                    }
                                    GoodsData goodsDataLog = new GoodsData
                                    {
                                        GoodsID = item.GoodsID,
                                        GCount  = realCostCnt
                                    };
                                    strCostList = EventLogManager.NewGoodsDataPropString(goodsDataLog);
                                }
                            }
                        }
                        else
                        {
                            int nReqZuanShi = upStarXmlItem.GetIntValue("NeedZuanShi", -1);
                            if (nReqZuanShi <= 0)
                            {
                                string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[]
                                {
                                    -3,
                                    nRoleID,
                                    0,
                                    0
                                });
                                client.sendCmd(nID, strCmd, false);
                                return(true);
                            }
                            int oldUserMoney = client.ClientData.UserMoney;
                            int oldUserGlod  = client.ClientData.Gold;
                            if (client.ClientData.UserMoney < nReqZuanShi && !HuanLeDaiBiManager.GetInstance().HuanledaibiEnough(client, nReqZuanShi))
                            {
                                string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[]
                                {
                                    -6,
                                    nRoleID,
                                    0,
                                    0
                                });
                                client.sendCmd(nID, strCmd, false);
                                return(true);
                            }
                            if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nReqZuanShi, "翅膀进阶", true, true, false, DaiBiSySType.ChiBangShengJie))
                            {
                                string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[]
                                {
                                    -7,
                                    nRoleID,
                                    0,
                                    0
                                });
                                client.sendCmd(nID, strCmd, false);
                                return(true);
                            }
                            strCostList = EventLogManager.NewResPropString(ResLogType.FristBindZuanShi, new object[]
                            {
                                -nReqZuanShi,
                                oldUserGlod,
                                client.ClientData.Gold,
                                oldUserMoney,
                                client.ClientData.UserMoney
                            });
                        }
                        int nLuckOne             = upStarXmlItem.GetIntValue("LuckyOne", -1);
                        int nLuckyTwo            = upStarXmlItem.GetIntValue("LuckyTwo", -1);
                        int nLuckTwoRate         = (int)(upStarXmlItem.GetDoubleValue("LuckyTwoRate") * 100.0);
                        int nNextWingID          = client.ClientData.MyWingData.WingID;
                        int nNextJinJieFailedNum = client.ClientData.MyWingData.JinJieFailedNum;
                        int nNextStarLevel       = client.ClientData.MyWingData.ForgeLevel;
                        int nNextStarExp         = client.ClientData.MyWingData.StarExp;
                        int nOldWingID           = client.ClientData.MyWingData.WingID;
                        int nOldJinJieFailedNum  = client.ClientData.MyWingData.JinJieFailedNum;
                        int nOldStarLevel        = client.ClientData.MyWingData.ForgeLevel;
                        int nOldStarExp          = client.ClientData.MyWingData.StarExp;
                        if (nLuckOne + client.ClientData.MyWingData.JinJieFailedNum < nLuckyTwo)
                        {
                            nNextJinJieFailedNum++;
                        }
                        else if (nLuckOne + client.ClientData.MyWingData.JinJieFailedNum < 110000)
                        {
                            int nRandNum = Global.GetRandomNumber(0, 100);
                            if (nRandNum < nLuckTwoRate)
                            {
                                nNextWingID++;
                                nNextJinJieFailedNum = 0;
                                nNextStarLevel       = 0;
                                nNextStarExp         = 0;
                            }
                            else
                            {
                                nNextJinJieFailedNum++;
                            }
                        }
                        else
                        {
                            nNextWingID++;
                            nNextJinJieFailedNum = 0;
                            nNextStarLevel       = 0;
                            nNextStarExp         = 0;
                        }
                        GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingSuitStarTimes));
                        int iRet = MUWingsManager.WingUpDBCommand(client, client.ClientData.MyWingData.DbID, nNextWingID, nNextJinJieFailedNum, nNextStarLevel, nNextStarExp, client.ClientData.MyWingData.ZhuLingNum, client.ClientData.MyWingData.ZhuHunNum);
                        if (iRet < 0)
                        {
                            string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[]
                            {
                                -3,
                                nRoleID,
                                0,
                                0
                            });
                            client.sendCmd(nID, strCmd, false);
                            result = true;
                        }
                        else
                        {
                            string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[]
                            {
                                0,
                                nRoleID,
                                nNextWingID,
                                nNextJinJieFailedNum
                            });
                            client.sendCmd(nID, strCmd, false);
                            client.ClientData.MyWingData.JinJieFailedNum = nNextJinJieFailedNum;
                            if (client.ClientData.MyWingData.WingID != nNextWingID)
                            {
                                if (1 == client.ClientData.MyWingData.Using)
                                {
                                    MUWingsManager.UpdateWingDataProps(client, false);
                                }
                                bool oldWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu, false);
                                client.ClientData.MyWingData.WingID     = nNextWingID;
                                client.ClientData.MyWingData.ForgeLevel = 0;
                                client.ClientData.MyWingData.StarExp    = 0;
                                GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingLevel));
                                bool newWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu, false);
                                if (!oldWingLingYuOpened && newWingLingYuOpened)
                                {
                                    LingYuManager.InitAsOpened(client);
                                }
                                if (1 == client.ClientData.MyWingData.Using)
                                {
                                    MUWingsManager.UpdateWingDataProps(client, true);
                                    ZhuLingZhuHunManager.UpdateZhuLingZhuHunProps(client);
                                    GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                                    GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7);
                                }
                                if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriWing) || client._IconStateMgr.CheckReborn(client))
                                {
                                    client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived());
                                    client._IconStateMgr.SendIconStateToClient(client);
                                }
                                EventLogManager.AddWingStarEvent(client, 2, 0, nOldStarLevel, client.ClientData.MyWingData.WingID, client.ClientData.MyWingData.ForgeLevel, client.ClientData.MyWingData.StarExp, strCostList);
                            }
                            EventLogManager.AddWingUpgradeEvent(client, nUpWingMode, nOldJinJieFailedNum, client.ClientData.MyWingData.JinJieFailedNum, nOldWingID, client.ClientData.MyWingData.WingID, nOldStarLevel, client.ClientData.MyWingData.ForgeLevel, nOldStarExp, client.ClientData.MyWingData.StarExp, strCostList);
                            ProcessTask.ProcessRoleTaskVal(client, TaskTypes.WingIDLevel, -1);
                            result = true;
                        }
                    }
                }
            }
            return(result);
        }
예제 #5
0
        public bool processCmd(GameClient client, string[] cmdParams)
        {
            int    nRoleID     = Global.SafeConvertToInt32(cmdParams[0]);
            int    nUpStarMode = Global.SafeConvertToInt32(cmdParams[1]);
            string strCostList = "";
            bool   result;

            if (null == client.ClientData.MyWingData)
            {
                SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0);
                client.sendCmd <SCWingStarUp>(608, scData, false);
                result = true;
            }
            else
            {
                SystemXmlItem upStarXmlItem = WingStarCacheManager.GetWingStarCacheItem(Global.CalcOriginalOccupationID(client), client.ClientData.MyWingData.WingID, client.ClientData.MyWingData.ForgeLevel + 1);
                if (null == upStarXmlItem)
                {
                    SCWingStarUp scData = new SCWingStarUp(-23, nRoleID, 0, 0);
                    client.sendCmd <SCWingStarUp>(608, scData, false);
                    result = true;
                }
                else
                {
                    string strWingShengXing = GameManager.systemParamsList.GetParamValueByName("WingShengXing");
                    if ("" == strWingShengXing)
                    {
                        SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0);
                        client.sendCmd <SCWingStarUp>(608, scData, false);
                        result = true;
                    }
                    else
                    {
                        string[] wingShengXing = strWingShengXing.Split(new char[]
                        {
                            ','
                        });
                        if (3 != wingShengXing.Length)
                        {
                            SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0);
                            client.sendCmd <SCWingStarUp>(608, scData, false);
                            result = true;
                        }
                        else
                        {
                            int nAddExp = 0;
                            int nPowRate;
                            if (0 == nUpStarMode)
                            {
                                nPowRate = (int)(Convert.ToDouble(wingShengXing[0]) * 100.0);
                                nAddExp  = Convert.ToInt32(upStarXmlItem.GetIntValue("GoodsExp", -1));
                            }
                            else
                            {
                                nPowRate = (int)(Convert.ToDouble(wingShengXing[1]) * 100.0);
                                nAddExp  = Convert.ToInt32(upStarXmlItem.GetIntValue("ZuanShiExp", -1));
                            }
                            int nRandNum = Global.GetRandomNumber(0, 100);
                            if (nRandNum < nPowRate)
                            {
                                nAddExp *= Convert.ToInt32(wingShengXing[2]);
                            }
                            int nUpStarReqExp  = upStarXmlItem.GetIntValue("StarExp", -1);
                            int nOldStarLevel  = client.ClientData.MyWingData.ForgeLevel;
                            int nNextStarLevel = client.ClientData.MyWingData.ForgeLevel;
                            int nNextStarExp   = 0;
                            if (client.ClientData.MyWingData.StarExp + nAddExp >= nUpStarReqExp)
                            {
                                if (nNextStarLevel < MUWingsManager.MaxWingEnchanceLevel)
                                {
                                    nNextStarLevel++;
                                    nNextStarExp = client.ClientData.MyWingData.StarExp + nAddExp - nUpStarReqExp;
                                    while (nNextStarLevel < MUWingsManager.MaxWingEnchanceLevel)
                                    {
                                        SystemXmlItem nextStarXmlItem = WingStarCacheManager.GetWingStarCacheItem(Global.CalcOriginalOccupationID(client), client.ClientData.MyWingData.WingID, nNextStarLevel + 1);
                                        if (null != upStarXmlItem)
                                        {
                                            int nNextUpStarReqExp = nextStarXmlItem.GetIntValue("StarExp", -1);
                                            if (nNextStarExp >= nNextUpStarReqExp)
                                            {
                                                nNextStarLevel++;
                                                nNextStarExp -= nNextUpStarReqExp;
                                                continue;
                                            }
                                        }
                                        break;
                                    }
                                }
                                else
                                {
                                    nNextStarExp = nUpStarReqExp;
                                }
                            }
                            else
                            {
                                nNextStarExp = client.ClientData.MyWingData.StarExp + nAddExp;
                            }
                            if (0 == nUpStarMode)
                            {
                                string   strReqItemID = upStarXmlItem.GetStringValue("NeedGoods");
                                string[] itemParams   = strReqItemID.Split(new char[]
                                {
                                    ','
                                });
                                if (itemParams == null || itemParams.Length != 2)
                                {
                                    SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0);
                                    client.sendCmd <SCWingStarUp>(608, scData, false);
                                    return(true);
                                }
                                int originGoodsID  = Convert.ToInt32(itemParams[0]);
                                int originGoodsNum = Convert.ToInt32(itemParams[1]);
                                if (originGoodsID <= 0 || originGoodsNum <= 0)
                                {
                                    SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0);
                                    client.sendCmd <SCWingStarUp>(608, scData, false);
                                    return(true);
                                }
                                GoodsReplaceResult replaceRet = SingletonTemplate <GoodsReplaceManager> .Instance().GetReplaceResult(client, originGoodsID);

                                if (replaceRet == null || replaceRet.TotalGoodsCnt() < originGoodsNum)
                                {
                                    SCWingStarUp scData = new SCWingStarUp(-4, nRoleID, 0, 0);
                                    client.sendCmd <SCWingStarUp>(608, scData, false);
                                    return(true);
                                }
                                List <GoodsReplaceResult.ReplaceItem> realCostList = new List <GoodsReplaceResult.ReplaceItem>();
                                realCostList.AddRange(replaceRet.BindList);
                                realCostList.AddRange(replaceRet.UnBindList);
                                realCostList.Add(replaceRet.OriginBindGoods);
                                realCostList.Add(replaceRet.OriginUnBindGoods);
                                int stillNeedCnt = originGoodsNum;
                                foreach (GoodsReplaceResult.ReplaceItem item in realCostList)
                                {
                                    if (item.GoodsCnt > 0)
                                    {
                                        int realCostCnt = Math.Min(stillNeedCnt, item.GoodsCnt);
                                        if (realCostCnt <= 0)
                                        {
                                            break;
                                        }
                                        bool bUsedBinding     = false;
                                        bool bUsedTimeLimited = false;
                                        bool bFailed          = false;
                                        if (item.IsBind)
                                        {
                                            if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited, false))
                                            {
                                                bFailed = true;
                                            }
                                        }
                                        else if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited, false))
                                        {
                                            bFailed = true;
                                        }
                                        stillNeedCnt -= realCostCnt;
                                        if (bFailed)
                                        {
                                            SCWingStarUp scData = new SCWingStarUp(-5, nRoleID, 0, 0);
                                            client.sendCmd <SCWingStarUp>(608, scData, false);
                                            return(true);
                                        }
                                        GoodsData goodsData = new GoodsData
                                        {
                                            GoodsID = item.GoodsID,
                                            GCount  = realCostCnt
                                        };
                                        strCostList = EventLogManager.NewGoodsDataPropString(goodsData);
                                    }
                                }
                            }
                            else
                            {
                                int nReqZuanShi = upStarXmlItem.GetIntValue("NeedZuanShi", -1);
                                if (nReqZuanShi <= 0)
                                {
                                    SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0);
                                    client.sendCmd <SCWingStarUp>(608, scData, false);
                                    return(true);
                                }
                                if (client.ClientData.UserMoney < nReqZuanShi)
                                {
                                    SCWingStarUp scData = new SCWingStarUp(-6, nRoleID, 0, 0);
                                    client.sendCmd <SCWingStarUp>(608, scData, false);
                                    return(true);
                                }
                                int oldUserMoney = client.ClientData.UserMoney;
                                int oldUserGlod  = client.ClientData.Gold;
                                if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nReqZuanShi, "翅膀升星", true, true, false, DaiBiSySType.ChiBangShengXing))
                                {
                                    SCWingStarUp scData = new SCWingStarUp(-7, nRoleID, 0, 0);
                                    client.sendCmd <SCWingStarUp>(608, scData, false);
                                    return(true);
                                }
                                strCostList = EventLogManager.NewResPropString(ResLogType.FristBindZuanShi, new object[]
                                {
                                    -nReqZuanShi,
                                    oldUserGlod,
                                    client.ClientData.Gold,
                                    oldUserMoney,
                                    client.ClientData.UserMoney
                                });
                            }
                            GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingSuitStarTimes));
                            int iRet = MUWingsManager.WingUpStarDBCommand(client, client.ClientData.MyWingData.DbID, nNextStarLevel, nNextStarExp);
                            if (iRet < 0)
                            {
                                SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0);
                                client.sendCmd <SCWingStarUp>(608, scData, false);
                                result = true;
                            }
                            else
                            {
                                SCWingStarUp scData = new SCWingStarUp(0, nRoleID, nNextStarLevel, nNextStarExp);
                                client.sendCmd <SCWingStarUp>(608, scData, false);
                                client.ClientData.MyWingData.StarExp = nNextStarExp;
                                if (client.ClientData.MyWingData.ForgeLevel != nNextStarLevel)
                                {
                                    if (1 == client.ClientData.MyWingData.Using)
                                    {
                                        MUWingsManager.UpdateWingDataProps(client, false);
                                    }
                                    bool oldWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu, false);
                                    client.ClientData.MyWingData.ForgeLevel = nNextStarLevel;
                                    GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingLevel));
                                    bool newWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu, false);
                                    if (!oldWingLingYuOpened && newWingLingYuOpened)
                                    {
                                        LingYuManager.InitAsOpened(client);
                                    }
                                    if (1 == client.ClientData.MyWingData.Using)
                                    {
                                        MUWingsManager.UpdateWingDataProps(client, true);
                                        ZhuLingZhuHunManager.UpdateZhuLingZhuHunProps(client);
                                        GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                                        GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7);
                                    }
                                    if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriWing) || client._IconStateMgr.CheckSpecialActivity(client) || client._IconStateMgr.CheckEverydayActivity(client) || client._IconStateMgr.CheckReborn(client))
                                    {
                                        client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived());
                                        client._IconStateMgr.SendIconStateToClient(client);
                                    }
                                }
                                EventLogManager.AddWingStarEvent(client, nUpStarMode, nAddExp, nOldStarLevel, client.ClientData.MyWingData.WingID, client.ClientData.MyWingData.ForgeLevel, client.ClientData.MyWingData.StarExp, strCostList);
                                ProcessTask.ProcessRoleTaskVal(client, TaskTypes.WingIDLevel, -1);
                                result = true;
                            }
                        }
                    }
                }
            }
            return(result);
        }