示例#1
0
        private bool ProcessHuiJiStarUpCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            int result = 0;
            HuiJiUpdateResultData resultData = new HuiJiUpdateResultData();
            RoleHuiJiData         huiJiData  = client.ClientData.HuiJiData;
            int exp = 0;
            HuiJiUpdateResultData requestData = DataHelper.BytesToObject <HuiJiUpdateResultData>(bytes, 0, bytes.Length);
            int  type     = requestData.Type;
            int  zuanshi  = requestData.ZuanShi;
            int  auto     = requestData.Auto;
            long nowTicks = TimeUtil.NOW();

            if (!this.IsGongNengOpened(client))
            {
                result = -12;
            }
            else
            {
                lock (this.RuntimeData.Mutex)
                {
                    EmblemStarInfo starInfo;
                    EmblemStarInfo starInfo2;
                    if (huiJiData.huiji != requestData.HuiJi)
                    {
                        result = -3;
                    }
                    else if (!this.RuntimeData.EmblemStarDict.Value.TryGetValue(huiJiData.huiji, out starInfo))
                    {
                        result = -3;
                    }
                    else if (!this.RuntimeData.EmblemStarDict.Value.TryGetValue(huiJiData.huiji + 1, out starInfo2))
                    {
                        result = -4004;
                    }
                    else
                    {
                        bool   useBind      = false;
                        bool   useTimeLimit = false;
                        string strCostList;
                        if (type == 0)
                        {
                            if (starInfo.EmblemUpInfo.MaxStarLevel == starInfo.EmblemStar)
                            {
                                result = -4;
                                goto IL_646;
                            }
                            if (Global.UseGoodsBindOrNot(client, starInfo.NeedGoods[0], starInfo.NeedGoods[1], true, out useBind, out useTimeLimit) < 0)
                            {
                                if (zuanshi <= 0 || zuanshi != starInfo.NeedDiamond)
                                {
                                    result = -6;
                                    goto IL_646;
                                }
                                if (!GameManager.ClientMgr.SubUserMoney(client, zuanshi, "徽记升星", true, true, true, true, DaiBiSySType.HuiJiShengXing))
                                {
                                    result = -10;
                                    goto IL_646;
                                }
                                exp         = starInfo.ZuanShiExp;
                                strCostList = EventLogManager.NewResPropString(ResLogType.ZuanShi, new object[]
                                {
                                    -zuanshi,
                                    client.ClientData.UserMoney + zuanshi,
                                    client.ClientData.UserMoney
                                });
                                if (Global.GetRandom() < this.RuntimeData.EmblemShengXing[1])
                                {
                                    exp = (int)((double)exp * this.RuntimeData.EmblemShengXing[2]);
                                }
                            }
                            else
                            {
                                exp         = starInfo.GoodsExp;
                                strCostList = EventLogManager.NewGoodsDataPropString(new GoodsData
                                {
                                    GoodsID = starInfo.NeedGoods[0],
                                    GCount  = starInfo.NeedGoods[1]
                                });
                                if (Global.GetRandom() < this.RuntimeData.EmblemShengXing[0])
                                {
                                    exp = (int)((double)exp * this.RuntimeData.EmblemShengXing[2]);
                                }
                            }
                            huiJiData.Exp += exp;
                            if (huiJiData.Exp >= starInfo.StarExp)
                            {
                                huiJiData.huiji++;
                                if (starInfo.EmblemStar < starInfo.EmblemUpInfo.MaxStarLevel - 1)
                                {
                                    huiJiData.Exp -= starInfo.StarExp;
                                }
                                else
                                {
                                    huiJiData.Exp = 0;
                                }
                            }
                        }
                        else
                        {
                            if (starInfo.EmblemUpInfo.MaxStarLevel != starInfo.EmblemStar)
                            {
                                result = -4;
                                goto IL_646;
                            }
                            if (Global.UseGoodsBindOrNot(client, starInfo.EmblemUpInfo.NeedGoods[0], starInfo.EmblemUpInfo.NeedGoods[1], true, out useBind, out useTimeLimit) < 0)
                            {
                                if (zuanshi <= 0 || zuanshi != starInfo.EmblemUpInfo.NeedDiamond)
                                {
                                    result = -6;
                                    goto IL_646;
                                }
                                if (!GameManager.ClientMgr.SubUserMoney(client, zuanshi, "徽记升阶", true, true, true, true, DaiBiSySType.HuiJiShengJie))
                                {
                                    result = -10;
                                    goto IL_646;
                                }
                                strCostList = EventLogManager.NewResPropString(ResLogType.ZuanShi, new object[]
                                {
                                    -zuanshi,
                                    client.ClientData.UserMoney + zuanshi,
                                    client.ClientData.UserMoney
                                });
                            }
                            else
                            {
                                strCostList = EventLogManager.NewGoodsDataPropString(new GoodsData
                                {
                                    GoodsID = starInfo.EmblemUpInfo.NeedGoods[0],
                                    GCount  = starInfo.EmblemUpInfo.NeedGoods[1]
                                });
                                exp = starInfo.GoodsExp;
                            }
                            huiJiData.Exp++;
                            if (starInfo.EmblemUpInfo.LuckyOne + huiJiData.Exp >= 110000)
                            {
                                huiJiData.huiji++;
                                huiJiData.Exp = 0;
                            }
                            else if (starInfo.EmblemUpInfo.LuckyOne + huiJiData.Exp > starInfo.EmblemUpInfo.LuckyTwo)
                            {
                                if (Global.GetRandom() < starInfo.EmblemUpInfo.LuckyTwoRate)
                                {
                                    huiJiData.huiji++;
                                    huiJiData.Exp = 0;
                                }
                            }
                        }
                        Global.SendToDB <RoleDataCmdT <RoleHuiJiData> >(1446, new RoleDataCmdT <RoleHuiJiData>(client.ClientData.RoleID, huiJiData), client.ServerId);
                        if (huiJiData.huiji > requestData.HuiJi)
                        {
                            client.ClientData.PropsCacheManager.SetExtProps(new object[]
                            {
                                PropsSystemTypes.HuiJiHuTi,
                                starInfo2.ExtPropValues
                            });
                            client.delayExecModule.SetDelayExecProc(new DelayExecProcIds[]
                            {
                                DelayExecProcIds.RecalcProps,
                                DelayExecProcIds.NotifyRefreshProps
                            });
                            EventLogManager.AddHuiJiEvent(client, type, (zuanshi > 0) ? 1 : 0, exp, starInfo.EmblemLevel, starInfo.EmblemStar, starInfo2.EmblemLevel, starInfo2.EmblemStar, huiJiData.Exp, strCostList);
                        }
                        else
                        {
                            EventLogManager.AddHuiJiEvent(client, type, (zuanshi > 0) ? 1 : 0, exp, starInfo.EmblemLevel, starInfo.EmblemStar, starInfo.EmblemLevel, starInfo.EmblemStar, huiJiData.Exp, strCostList);
                        }
                    }
                }
            }
IL_646:
            if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieRiHuiJi))
            {
                client._IconStateMgr.SendIconStateToClient(client);
            }
            resultData.Result = result;
            resultData.HuiJi  = huiJiData.huiji;
            resultData.Exp    = huiJiData.Exp;
            resultData.Auto   = auto;
            resultData.Type   = type;
            client.sendCmd <HuiJiUpdateResultData>(nID, resultData, false);
            return(true);
        }