Esempio n. 1
0
        private bool ProcessArmorStarUpCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            int result = 0;
            ArmorUpdateResultData resultData = new ArmorUpdateResultData();
            RoleArmorData         ArmorData  = client.ClientData.ArmorData;
            int exp = 0;
            ArmorUpdateResultData requestData = DataHelper.BytesToObject <ArmorUpdateResultData>(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
            {
                bool updateProps = false;
                lock (this.RuntimeData.Mutex)
                {
                    if (ArmorData.Armor != requestData.Armor)
                    {
                        result = -3;
                        goto IL_611;
                    }
                    ArmorStarInfo starInfo;
                    if (!this.RuntimeData.ArmorStarDict.Value.TryGetValue(ArmorData.Armor, out starInfo))
                    {
                        result = -3;
                        goto IL_611;
                    }
                    ArmorStarInfo starInfo2;
                    if (!this.RuntimeData.ArmorStarDict.Value.TryGetValue(ArmorData.Armor + 1, out starInfo2))
                    {
                        result = -4004;
                        goto IL_611;
                    }
                    bool   useBind      = false;
                    bool   useTimeLimit = false;
                    string strCostList;
                    if (type == 0)
                    {
                        if (starInfo.ArmorUpInfo.MaxStarLevel == starInfo.StarLevel)
                        {
                            result = -4;
                            goto IL_611;
                        }
                        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_611;
                            }
                            if (!GameManager.ClientMgr.SubUserMoney(client, zuanshi, "神圣护盾升星", true, true, true, true, DaiBiSySType.None))
                            {
                                result = -10;
                                goto IL_611;
                            }
                            exp         = starInfo.ZuanShiExp;
                            strCostList = EventLogManager.NewResPropString(ResLogType.ZuanShi, new object[]
                            {
                                -zuanshi,
                                client.ClientData.UserMoney + zuanshi,
                                client.ClientData.UserMoney
                            });
                            if (Global.GetRandom() < this.RuntimeData.HudunBaoji[1])
                            {
                                exp = (int)((double)exp * this.RuntimeData.HudunBaoji[2]);
                            }
                        }
                        else
                        {
                            exp         = starInfo.GoodsExp;
                            strCostList = EventLogManager.NewGoodsDataPropString(new GoodsData
                            {
                                GoodsID = starInfo.NeedGoods[0],
                                GCount  = starInfo.NeedGoods[1]
                            });
                            if (Global.GetRandom() < this.RuntimeData.HudunBaoji[0])
                            {
                                exp = (int)((double)exp * this.RuntimeData.HudunBaoji[2]);
                            }
                        }
                        ArmorData.Exp += exp;
                        if (ArmorData.Exp >= starInfo.StarExp)
                        {
                            ArmorData.Armor++;
                            if (starInfo.StarLevel < starInfo.ArmorUpInfo.MaxStarLevel - 1)
                            {
                                ArmorData.Exp -= starInfo.StarExp;
                            }
                            else
                            {
                                ArmorData.Exp = 0;
                            }
                        }
                    }
                    else
                    {
                        if (starInfo.ArmorUpInfo.MaxStarLevel != starInfo.StarLevel)
                        {
                            result = -4;
                            goto IL_611;
                        }
                        if (Global.UseGoodsBindOrNot(client, starInfo.ArmorUpInfo.NeedGoods[0], starInfo.ArmorUpInfo.NeedGoods[1], true, out useBind, out useTimeLimit) < 0)
                        {
                            if (zuanshi <= 0 || zuanshi != starInfo.ArmorUpInfo.NeedDiamond)
                            {
                                result = -6;
                                goto IL_611;
                            }
                            if (!GameManager.ClientMgr.SubUserMoney(client, zuanshi, "神圣护盾升阶", true, true, true, true, DaiBiSySType.None))
                            {
                                result = -10;
                                goto IL_611;
                            }
                            strCostList = EventLogManager.NewResPropString(ResLogType.ZuanShi, new object[]
                            {
                                -zuanshi,
                                client.ClientData.UserMoney + zuanshi,
                                client.ClientData.UserMoney
                            });
                        }
                        else
                        {
                            strCostList = EventLogManager.NewGoodsDataPropString(new GoodsData
                            {
                                GoodsID = starInfo.ArmorUpInfo.NeedGoods[0],
                                GCount  = starInfo.ArmorUpInfo.NeedGoods[1]
                            });
                            exp = starInfo.GoodsExp;
                        }
                        ArmorData.Exp++;
                        if (starInfo.ArmorUpInfo.LuckyOne + ArmorData.Exp >= 110000)
                        {
                            ArmorData.Armor++;
                            ArmorData.Exp = 0;
                        }
                        else if (starInfo.ArmorUpInfo.LuckyOne + ArmorData.Exp > starInfo.ArmorUpInfo.LuckyTwo)
                        {
                            if (Global.GetRandom() < starInfo.ArmorUpInfo.LuckyTwoRate)
                            {
                                ArmorData.Armor++;
                                ArmorData.Exp = 0;
                            }
                        }
                    }
                    Global.SendToDB <RoleDataCmdT <RoleArmorData> >(1447, new RoleDataCmdT <RoleArmorData>(client.ClientData.RoleID, ArmorData), client.ServerId);
                    if (ArmorData.Armor > requestData.Armor)
                    {
                        updateProps = true;
                        EventLogManager.AddArmorEvent(client, type, (zuanshi > 0) ? 1 : 0, exp, starInfo.ArmorupStage, starInfo.StarLevel, starInfo2.ArmorupStage, starInfo2.StarLevel, ArmorData.Exp, strCostList);
                    }
                    else
                    {
                        EventLogManager.AddArmorEvent(client, type, (zuanshi > 0) ? 1 : 0, exp, starInfo.ArmorupStage, starInfo.StarLevel, starInfo.ArmorupStage, starInfo.StarLevel, ArmorData.Exp, strCostList);
                    }
                }
                if (updateProps)
                {
                    this.ResetArmor(client, true);
                }
            }
IL_611:
            resultData.Result = result;
            resultData.Armor  = ArmorData.Armor;
            resultData.Exp    = ArmorData.Exp;
            resultData.Auto   = auto;
            resultData.Type   = type;
            client.sendCmd <ArmorUpdateResultData>(nID, resultData, false);
            return(true);
        }