示例#1
0
        public bool processCmdEx(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            bool result;

            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.Building, false))
            {
                GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(3, new object[0]), new object[0]), GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox, 0);
                result = true;
            }
            else
            {
                switch (nID)
                {
                case 1080:
                    result = this.ProcessShenJiAddEffectCmd(client, nID, bytes, cmdParams);
                    break;

                case 1081:
                    result = this.ProcessShenJiAddExpCmd(client, nID, bytes, cmdParams);
                    break;

                case 1082:
                    result = this.ProcessShenJiWashCmd(client, nID, bytes, cmdParams);
                    break;

                default:
                    result = true;
                    break;
                }
            }
            return(result);
        }
示例#2
0
        /// <summary>
        /// 判断功能是否开启
        /// </summary>
        public static bool IsGongNengOpened(GameClient client, bool hint = false)
        {
            if (!GameManager.VersionSystemOpenMgr.IsVersionSystemOpen(VersionSystemOpenKey.Fund))
            {
                return(false);
            }

            return(GlobalNew.IsGongNengOpened(client, GongNengIDs.Fund, hint));
        }
示例#3
0
        //登录时处理采集数据
        public static void InitRoleDailyCaiJiData(GameClient client, bool isLogin, bool isNewday)
        {
            //是否开启了水晶幻境采集
            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.CrystalCollect))
            {
                return;
            }

            //登录时需要取得上次采集的日期和次数,在线跨天就不需要取
            if (isLogin)
            {
                client.ClientData.DailyCrystalCollectNum = Global.GetRoleParamsInt32FromDB(client, RoleParamName.CaiJiCrystalNum);
                client.ClientData.CrystalCollectDayID    = Global.GetRoleParamsInt32FromDB(client, RoleParamName.CaiJiCrystalDayID);
            }

            bool bClear = false;

            //是否跨天了(今天第一次登录或者在线跨天)
            if (isNewday)
            {
                //昨天或昨天之前是否开启了水晶幻境采集
                if (client.ClientData.DailyCrystalCollectNum >= 0 && client.ClientData.CrystalCollectDayID > 0)
                {
                    //这个数据是水晶幻境资源找回用的
                    client.ClientData.OldCrystalCollectData        = new OldCaiJiData();
                    client.ClientData.OldCrystalCollectData.OldDay = client.ClientData.CrystalCollectDayID;
                    client.ClientData.OldCrystalCollectData.OldNum = client.ClientData.DailyCrystalCollectNum;
                }

                //跨天清零次数
                bClear = true;
            }
            else if (0 == client.ClientData.CrystalCollectDayID)
            {
                //之前没保存过采集次数,现在需要保存一下
                bClear = true;
            }

            if (bClear)
            {
                //清次数,重设日期
                client.ClientData.DailyCrystalCollectNum = 0;
                client.ClientData.CrystalCollectDayID    = (int)DateTime.Now.DayOfYear;

                Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.CaiJiCrystalNum, 0, true);
                Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.CaiJiCrystalDayID, client.ClientData.CrystalCollectDayID, true);

                //通知玩家水晶幻境的采集次数清零
                if (Global.GetMapSceneType(client.ClientData.MapCode) == SceneUIClasses.ShuiJingHuanJing)
                {
                    NotifyCollectLastNum(client, 0, DailyNum);
                }
            }

            client._IconStateMgr.CheckCaiJiState(client);
        }
示例#4
0
 public static bool HasLeftnum(GameClient client)
 {
     if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.CrystalCollect))
     {
         return(false);
     }
     else
     {
         return(client.ClientData.DailyCrystalCollectNum < DailyNum);
     }
 }
示例#5
0
 public static void InitRoleShenQiData(GameClient client)
 {
     client.ClientData.ShenLiJingHuaPoints = Global.GetRoleParamsInt32FromDB(client, "10157");
     if (GlobalNew.IsGongNengOpened(client, GongNengIDs.ShenQi, false))
     {
         client.ClientData.shenQiData = ShenQiManager.GetShenQiData(client);
         ShenQiManager.getInstance().UpdateRoleShenQiProps(client);
         ShenQiManager.getInstance().UpdateRoleTouhgnessProps(client);
         ShenQiManager.getInstance().UpdateRoleGodProps(client);
     }
 }
示例#6
0
 public void AlchemyRollBack(GameClient client, string rollbackType)
 {
     if (GlobalNew.IsGongNengOpened(client, GongNengIDs.Alchemy, false))
     {
         if (!string.IsNullOrEmpty(rollbackType))
         {
             string[] valueFields = rollbackType.Split(new char[]
             {
                 ','
             });
             if (valueFields.Length == 2)
             {
                 int costType = Global.SafeConvertToInt32(valueFields[0]);
                 int useNum   = Global.SafeConvertToInt32(valueFields[1]);
                 Dictionary <int, AlchemyConfigData> tempAlchemyConfig = null;
                 lock (this.ConfigMutex)
                 {
                     tempAlchemyConfig = this.AlchemyConfig;
                 }
                 AlchemyConfigData alchemyConfig = null;
                 if (!tempAlchemyConfig.TryGetValue(costType, out alchemyConfig) || useNum < alchemyConfig.Unit)
                 {
                     LogManager.WriteLog(LogTypes.SQL, string.Format("根据GM的要求为角色:【{0}】回滚炼金灌注【{1}】 失败!", client.ClientData.RoleID, rollbackType), null, true);
                     client.ClientData.AlchemyInfo.rollbackType = "";
                     this.AlchemyRollBackOffline(client.ClientData.RoleID, "");
                 }
                 else
                 {
                     useNum -= useNum % alchemyConfig.Unit;
                     int element  = useNum / alchemyConfig.Unit * alchemyConfig.Element;
                     int histCost = 0;
                     client.ClientData.AlchemyInfo.HistCost.TryGetValue(costType, out histCost);
                     if (histCost < useNum || client.ClientData.AlchemyInfo.BaseData.Element < element)
                     {
                         LogManager.WriteLog(LogTypes.SQL, string.Format("根据GM的要求为角色:【{0}】回滚炼金灌注【{1}】 失败!", client.ClientData.RoleID, rollbackType), null, true);
                         client.ClientData.AlchemyInfo.rollbackType = "";
                         this.AlchemyRollBackOffline(client.ClientData.RoleID, "");
                     }
                     else
                     {
                         GameManager.ClientMgr.ModifyAlchemyElementValue(client, -element, "GM命令-alchemy", false, false);
                         this.ModifyAddElementCost(client, costType, useNum, true);
                         client.ClientData.AlchemyInfo.HistCost[costType] = histCost - useNum;
                         this.UpdateAlchemyDataDB(client);
                         client.ClientData.AlchemyInfo.rollbackType = "";
                         this.AlchemyRollBackOffline(client.ClientData.RoleID, "");
                         LogManager.WriteLog(LogTypes.SQL, string.Format("根据GM的要求为角色:【{0}】回滚炼金灌注【{1}】 成功!", client.ClientData.RoleID, rollbackType), null, true);
                     }
                 }
             }
         }
     }
 }
示例#7
0
        /// <summary>
        /// 判断功能是否开启
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public bool IsGongNengOpened(GameClient client, bool hint = false)
        {
            if (!GameManager.VersionSystemOpenMgr.IsVersionSystemOpen(VersionSystemOpenKey.HuanYingSiYuan))
            {
                return(false);
            }

            // 如果1.4.1的功能没开放
            if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot4Dot1))
            {
                return(false);
            }

            return(GlobalNew.IsGongNengOpened(client, GongNengIDs.HuanYingSiYuan, hint));
        }
示例#8
0
        /// <summary>
        /// 判断功能是否开启
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public bool IsGongNengOpened(GameClient client, bool hint = false)
        {
            if (!GameManager.VersionSystemOpenMgr.IsVersionSystemOpen(VersionSystemOpenKey.TianTi))
            {
                return(false);
            }

            // 如果1.6的功能没开放
            if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot6))
            {
                return(false);
            }

            return(GlobalNew.IsGongNengOpened(client, GongNengIDs.TianTi, hint));
        }
示例#9
0
        /// <summary>
        /// 判断功能是否开启
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public bool IsGongNengOpened(GameClient client, bool hint = false)
        {
            // 如果1.7的功能没开放
            if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot7))
            {
                return(false);
            }

            if (!GameManager.VersionSystemOpenMgr.IsVersionSystemOpen(VersionSystemOpenKey.YongZheZhanChang))
            {
                return(false);
            }

            return(GlobalNew.IsGongNengOpened(client, GongNengIDs.YongZheZhanChang, hint));
        }
示例#10
0
        public static ShenQiData GetShenQiData(GameClient client)
        {
            ShenQiData result;

            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.ShenQi, false))
            {
                result = new ShenQiData
                {
                    UpResultType = -1
                };
            }
            else
            {
                ShenQiData data = client.ClientData.shenQiData;
                try
                {
                    if (null == data)
                    {
                        data = new ShenQiData();
                        List <int> props = Global.GetRoleParamsIntListFromDB(client, "36");
                        if (props == null || props.Count < 5)
                        {
                            props = new List <int>();
                            for (int i = 0; i < 5; i++)
                            {
                                props.Add(0);
                            }
                            props[0] = 1;
                            Global.SaveRoleParamsIntListToDB(client, props, "36", true);
                        }
                        data.ShenQiID                = props[0];
                        data.LifeAdd                 = props[1];
                        data.AttackAdd               = props[2];
                        data.DefenseAdd              = props[3];
                        data.ToughnessAdd            = props[4];
                        client.ClientData.shenQiData = data;
                    }
                    data.ShenLiJingHuaLeft = client.ClientData.ShenLiJingHuaPoints;
                    data.UpResultType      = -100;
                }
                catch (Exception ex)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("ShenQi :: 获取角色神器数据错误 ex:{0}", ex.Message), null, true);
                }
                result = data;
            }
            return(result);
        }
示例#11
0
 public static void InitRoleDailyCaiJiData(GameClient client, bool isLogin, bool isNewday)
 {
     if (GlobalNew.IsGongNengOpened(client, GongNengIDs.CrystalCollect, false))
     {
         if (isLogin)
         {
             client.ClientData.DailyCrystalCollectNum = Global.GetRoleParamsInt32FromDB(client, "CaiJiCrystalNum");
             client.ClientData.CrystalCollectDayID    = Global.GetRoleParamsInt32FromDB(client, "CaiJiCrystalDayID");
         }
         bool bClear = false;
         if (isNewday)
         {
             if (client.ClientData.DailyCrystalCollectNum >= 0 && client.ClientData.CrystalCollectDayID > 0)
             {
                 client.ClientData.OldCrystalCollectData        = new OldCaiJiData();
                 client.ClientData.OldCrystalCollectData.OldDay = client.ClientData.CrystalCollectDayID;
                 client.ClientData.OldCrystalCollectData.OldNum = client.ClientData.DailyCrystalCollectNum;
             }
             bClear = true;
         }
         else if (0 == client.ClientData.CrystalCollectDayID)
         {
             bClear = true;
         }
         if (bClear)
         {
             client.ClientData.DailyCrystalCollectNum = 0;
             client.ClientData.CrystalCollectDayID    = TimeUtil.NowDateTime().DayOfYear;
             Global.SaveRoleParamsInt32ValueToDB(client, "CaiJiCrystalNum", 0, true);
             Global.SaveRoleParamsInt32ValueToDB(client, "CaiJiCrystalDayID", client.ClientData.CrystalCollectDayID, true);
             if (Global.GetMapSceneType(client.ClientData.MapCode) == SceneUIClasses.ShuiJingHuanJing)
             {
                 CaiJiLogic.NotifyCollectLastNum(client, 0, CaiJiLogic.DailyNum);
             }
         }
         client._IconStateMgr.CheckCaiJiState(client);
     }
 }
示例#12
0
 public bool IsGongNengOpened(GameClient client, bool hint = false)
 {
     return(GameManager.VersionSystemOpenMgr.IsVersionSystemOpen("ElementWar") && GlobalNew.IsGongNengOpened(client, GongNengIDs.ElementWar, hint));
 }
示例#13
0
 private bool IsGongNengOpened(GameClient client)
 {
     return(GlobalNew.IsGongNengOpened(client, GongNengIDs.Armor, false));
 }
示例#14
0
        public int ActivationStarConstellation(GameClient client, int nStarSiteID)
        {
            int result;

            if (nStarSiteID < 1 || nStarSiteID > this.m_MaxStarSiteID)
            {
                result = -1;
            }
            else
            {
                if (client.ClientData.RoleStarConstellationInfo == null)
                {
                    client.ClientData.RoleStarConstellationInfo = new Dictionary <int, int>();
                }
                int nStarSlot = 0;
                client.ClientData.RoleStarConstellationInfo.TryGetValue(nStarSiteID, out nStarSlot);
                if (nStarSlot >= this.m_MaxStarSlotID)
                {
                    result = -1;
                }
                else if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.GamePayerRolePartXingZuo, false))
                {
                    result = -1;
                }
                else
                {
                    nStarSlot++;
                    int nOccupation = client.ClientData.Occupation;
                    Dictionary <int, Dictionary <int, StarConstellationDetailInfo> > dicTmp = null;
                    if (!this.m_StarConstellationDetailInfo.TryGetValue(nOccupation, out dicTmp) || dicTmp == null)
                    {
                        result = -2;
                    }
                    else
                    {
                        Dictionary <int, StarConstellationDetailInfo> dicTmpInfo = null;
                        if (!dicTmp.TryGetValue(nStarSiteID, out dicTmpInfo) || dicTmpInfo == null)
                        {
                            result = -2;
                        }
                        else
                        {
                            StarConstellationDetailInfo tmpInfo = null;
                            if (!dicTmpInfo.TryGetValue(nStarSlot, out tmpInfo) || tmpInfo == null)
                            {
                                result = -2;
                            }
                            else
                            {
                                int nNeeChangeLife = tmpInfo.ChangeLifeLimit;
                                int nNeedLev       = tmpInfo.LevelLimit;
                                int nReqUnionLevel = Global.GetUnionLevel(nNeeChangeLife, nNeedLev, false);
                                if (Global.GetUnionLevel(client.ClientData.ChangeLifeCount, client.ClientData.Level, false) < nReqUnionLevel)
                                {
                                    result = -3;
                                }
                                else
                                {
                                    int nGoods = tmpInfo.NeedGoodsID;
                                    int nNum   = tmpInfo.NeedGoodsNum;
                                    if (nGoods > 0 && nNum > 0)
                                    {
                                        GoodsData goods = Global.GetGoodsByID(client, nGoods);
                                        if (goods == null || goods.GCount < nNum)
                                        {
                                            GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(533, new object[0]), new object[0]), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0);
                                            return(-5);
                                        }
                                    }
                                    int nNeedStarSoul = tmpInfo.NeedStarSoul;
                                    if (nNeedStarSoul > 0)
                                    {
                                        if (nNeedStarSoul > client.ClientData.StarSoul)
                                        {
                                            GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(534, new object[0]), new object[0]), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0);
                                            return(-9);
                                        }
                                    }
                                    int nNeedMoney = tmpInfo.NeedJinBi;
                                    if (nNeedMoney > 0)
                                    {
                                        if (!Global.SubBindTongQianAndTongQian(client, nNeedMoney, "激活星座"))
                                        {
                                            GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(535, new object[0]), new object[0]), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0);
                                            return(-10);
                                        }
                                    }
                                    if (nGoods > 0 && nNum > 0)
                                    {
                                        bool usedBinding     = false;
                                        bool usedTimeLimited = false;
                                        if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nGoods, nNum, false, out usedBinding, out usedTimeLimited, false))
                                        {
                                            return(-6);
                                        }
                                    }
                                    if (nNeedStarSoul > 0)
                                    {
                                        GameManager.ClientMgr.ModifyStarSoulValue(client, -nNeedStarSoul, "激活星座", true, true);
                                    }
                                    int nRate = Global.GetRandomNumber(1, 10001);
                                    if (nRate > tmpInfo.SuccessRate)
                                    {
                                        GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(536, new object[0]), new object[0]), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0);
                                        result = -100;
                                    }
                                    else
                                    {
                                        TCPOutPacket         tcpOutPacket    = null;
                                        string               strDbCmd        = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, nStarSiteID, nStarSlot);
                                        TCPProcessCmdResults dbRequestResult = Global.RequestToDBServer2(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, 10166, strDbCmd, out tcpOutPacket, client.ServerId);
                                        if (TCPProcessCmdResults.RESULT_FAILED == dbRequestResult)
                                        {
                                            result = -7;
                                        }
                                        else
                                        {
                                            Global.PushBackTcpOutPacket(tcpOutPacket);
                                            PropertyInfo tmpProp = tmpInfo.Propertyinfo;
                                            if (tmpProp == null)
                                            {
                                                result = -8;
                                            }
                                            else
                                            {
                                                client.ClientData.RoleStarConstellationInfo[nStarSiteID] = nStarSlot;
                                                this.ActivationStarConstellationProp(client, tmpProp, 1);
                                                if (0 == nStarSlot % 12)
                                                {
                                                    this.ActivationStarConstellationExtendProp(client, nStarSiteID);
                                                    GameManager.StarConstellationMgr.InitPlayerStarConstellationPorperty(client);
                                                }
                                                GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.ActiveXingZuo));
                                                ProcessTask.ProcessRoleTaskVal(client, TaskTypes.XingZuoStar, -1);
                                                GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                                                client.ClientData.LifeV  = (int)RoleAlgorithm.GetMaxLifeV(client);
                                                client.ClientData.MagicV = (int)RoleAlgorithm.GetMaxMagicV(client);
                                                GameManager.ClientMgr.NotifySelfLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                                                result = 1;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
示例#15
0
        public static MarryResult MarryInit(GameClient client, int spouseID)
        {
            MarryResult result;

            if (!client.ClientData.IsMainOccupation)
            {
                result = MarryResult.Error_Denied_For_Minor_Occupation;
            }
            else if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.Marriage, true) || !MarryLogic.IsVersionSystemOpenOfMarriage())
            {
                result = MarryResult.NotOpen;
            }
            else if (client.ClientData.MyMarriageData.byMarrytype > 0)
            {
                result = MarryResult.SelfMarried;
            }
            else if (client.ClientData.ChangeLifeCount < 3)
            {
                result = MarryResult.SelfLevelNotEnough;
            }
            else if (client.ClientData.ExchangeID > 0 || client.ClientSocket.IsKuaFuLogin || client.ClientData.CopyMapID > 0)
            {
                result = MarryResult.SelfBusy;
            }
            else
            {
                GameClient spouseClient = GameManager.ClientMgr.FindClient(spouseID);
                if (spouseClient == null)
                {
                    result = MarryResult.TargetOffline;
                }
                else if (!spouseClient.ClientData.IsMainOccupation)
                {
                    result = MarryResult.Error_Denied_For_Minor_Occupation;
                }
                else if (!GlobalNew.IsGongNengOpened(spouseClient, GongNengIDs.Marriage, false))
                {
                    result = MarryResult.TargetNotOpen;
                }
                else
                {
                    if (!MarryLogic.SameSexMarry(false))
                    {
                        if (client.ClientData.RoleSex == spouseClient.ClientData.RoleSex)
                        {
                            return(MarryResult.InvalidSex);
                        }
                    }
                    if (spouseClient.ClientData.MyMarriageData.byMarrytype > 0)
                    {
                        result = MarryResult.TargetMarried;
                    }
                    else if (spouseClient.ClientData.ChangeLifeCount < 3)
                    {
                        result = MarryResult.TargetLevelNotEnough;
                    }
                    else if (spouseClient.ClientData.ExchangeID > 0 || spouseClient.ClientSocket.IsKuaFuLogin || spouseClient.ClientData.CopyMapID > 0)
                    {
                        result = MarryResult.TargetBusy;
                    }
                    else if (MarryLogic.ApplyExist(spouseID))
                    {
                        result = MarryResult.TargetBusy;
                    }
                    else if (spouseClient.ClientData.MyMarriageData.byAutoReject == 1)
                    {
                        result = MarryResult.AutoReject;
                    }
                    else if (MarryLogic.AddMarryApply(client.ClientData.RoleID, MarryApplyType.ApplyInit, spouseID) == null)
                    {
                        result = MarryResult.ApplyCD;
                    }
                    else if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, MarryLogic.MarryCost, "结婚", false, true, false, DaiBiSySType.None))
                    {
                        MarryLogic.RemoveMarryApply(client.ClientData.RoleID, MarryApplyType.ApplyNull);
                        result = MarryResult.MoneyNotEnough;
                    }
                    else
                    {
                        string notifyData = string.Format("{0}:{1}:{2}", 0, client.ClientData.RoleID, client.ClientData.RoleName);
                        spouseClient.sendCmd(894, notifyData, false);
                        result = MarryResult.Success;
                    }
                }
            }
            return(result);
        }
示例#16
0
 public bool IsGongNengOpened(GameClient client, bool hint = false)
 {
     return(GlobalNew.IsGongNengOpened(client, GongNengIDs.WanMoXiaGu, hint));
 }
示例#17
0
        /// <summary>
        /// 求婚
        /// </summary>
        public static MarryResult MarryInit(GameClient client, int spouseID)
        {
            if (GlobalNew.IsGongNengOpened(client, GongNengIDs.Marriage, true) == false ||
                !MarryLogic.IsVersionSystemOpenOfMarriage())
            {
                return(MarryResult.NotOpen);
            }
            if (client.ClientData.MyMarriageData.byMarrytype > 0)
            {
                return(MarryResult.SelfMarried);
            }
            if (client.ClientData.ChangeLifeCount < 3)
            {
                return(MarryResult.SelfLevelNotEnough);
            }
            if (client.ClientData.ExchangeID > 0 || true == client.ClientSocket.IsKuaFuLogin || client.ClientData.CopyMapID > 0)
            {
                return(MarryResult.SelfBusy);
            }

            GameClient spouseClient = GameManager.ClientMgr.FindClient(spouseID);

            if (spouseClient == null)
            {
                return(MarryResult.TargetOffline);
            }
            if (GlobalNew.IsGongNengOpened(spouseClient, GongNengIDs.Marriage) == false)
            {
                return(MarryResult.TargetNotOpen);
            }
            if (client.ClientData.RoleSex == spouseClient.ClientData.RoleSex)
            {
                return(MarryResult.InvalidSex);
            }
            if (spouseClient.ClientData.MyMarriageData.byMarrytype > 0)
            {
                return(MarryResult.TargetMarried);
            }
            if (spouseClient.ClientData.ChangeLifeCount < 3)
            {
                return(MarryResult.TargetLevelNotEnough);
            }
            if (spouseClient.ClientData.ExchangeID > 0 || true == spouseClient.ClientSocket.IsKuaFuLogin || spouseClient.ClientData.CopyMapID > 0)
            {
                return(MarryResult.TargetBusy);
            }
            if (ApplyExist(spouseID) == true)
            {
                return(MarryResult.TargetBusy);
            }

            //如果自动拒绝结婚
            if (spouseClient.ClientData.MyMarriageData.byAutoReject == (sbyte)1)
            {
                return(MarryResult.AutoReject);
            }
            if (AddMarryApply(client.ClientData.RoleID, MarryApplyType.ApplyInit, spouseID) == null)
            {
                return(MarryResult.ApplyCD);
            }

            //能求婚才会扣除钻石
            if (GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, MarryCost, "结婚", false) == false)
            {
                RemoveMarryApply(client.ClientData.RoleID);
                return(MarryResult.MoneyNotEnough);
            }

            string notifyData = string.Format("{0}:{1}:{2}", (int)MarryNotifyType.NotifyInit, client.ClientData.RoleID, client.ClientData.RoleName);

            spouseClient.sendCmd((int)TCPGameServerCmds.CMD_SPR_MARRY_NOTIFY, notifyData);

            return(MarryResult.Success);
        }
示例#18
0
        /// <summary>
        /// 神器再造
        /// </summary>
        /// <param name="client"></param>
        /// <param name="equipID"></param>
        /// <returns></returns>
        public static ArtifactResultData UpArtifact(GameClient client, int equipID, bool isUseBind)
        {
            ArtifactResultData result = new ArtifactResultData();

            #region 检查
            //神器再造功能开放
            bool isOpen = GlobalNew.IsGongNengOpened(client, GongNengIDs.Artifact);
            if (!isOpen)
            {
                result.State = (int)ArtifactResultType.EnoOpen;
                return(result);
            }

            // 从背包中找装备
            GoodsData equipData = Global.GetGoodsByDbID(client, equipID);
            if (equipData == null)
            {
                result.State = (int)ArtifactResultType.EnoEquip;
                return(result);
            }

            //类型检测Categoriy=0-6、11-21的道具
            int  catetoriy      = Global.GetGoodsCatetoriy(equipData.GoodsID);
            bool isCanCatetoriy = (catetoriy >= 0 && catetoriy <= 6) || (catetoriy >= 11 && catetoriy <= 21);
            if (!isCanCatetoriy)
            {
                result.State = (int)ArtifactResultType.EcantUp;
                return(result);
            }

            //Suit=10
            SystemXmlItem systemGoods = null;
            if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(equipData.GoodsID, out systemGoods))
            {
                result.State = (int)ArtifactResultType.EnoEquip;
                return(result);
            }

            int nSuitID = systemGoods.GetIntValue("SuitID");
            if (nSuitID < ARTIFACT_SUIT)
            {
                result.State = (int)ArtifactResultType.EcantUp;
                return(result);
            }

            //神器基本数据
            ArtifactData artifactDataBasic = GetArtifactDataByNeedId(equipData.GoodsID);
            if (artifactDataBasic == null)
            {
                result.State = (int)ArtifactResultType.EcantUp;
                return(result);
            }

            //再造点
            bool enoughZaiZao = Global.IsRoleHasEnoughMoney(client, artifactDataBasic.NeedZaiZao, (int)MoneyTypes.ZaiZao) > 0;
            if (!enoughZaiZao)
            {
                result.State = (int)ArtifactResultType.EnoZaiZao;
                return(result);
            }

            //绑定金币
            int goldBind = Global.GetTotalBindTongQianAndTongQianVal(client);;
            if (artifactDataBasic.NeedGoldBind > goldBind)
            {
                result.State = (int)ArtifactResultType.EnoGold;
                return(result);
            }

            //材料——成功扣除
            foreach (var d in artifactDataBasic.NeedMaterial)
            {
                int materialId = d.Key;
                int count      = d.Value;

                int totalCount = Global.GetTotalGoodsCountByID(client, materialId);
                if (totalCount < count)
                {
                    result.State = (int)ArtifactResultType.EnoMaterial;
                    return(result);
                }
            }

            //材料——失败扣除
            foreach (var d in artifactDataBasic.FailMaterial)
            {
                int materialId = d.Key;
                int count      = d.Value;

                int totalCount = Global.GetTotalGoodsCountByID(client, materialId);
                if (totalCount < count)
                {
                    result.State = (int)ArtifactResultType.EnoMaterial;
                    return(result);
                }
            }

            //背包已满
            int freeBagIndex = Global.GetIdleSlotOfBagGoods(client);
            if (freeBagIndex < 0)
            {
                result.State = (int)ArtifactResultType.EnoBag;
                return(result);
            }
            #endregion

            #region 扣除

            //扣除绑定金币
            if (!Global.SubBindTongQianAndTongQian(client, artifactDataBasic.NeedGoldBind, "神器再造"))
            {
                result.State = (int)ArtifactResultType.EnoGold;
                return(result);
            }

            //几率
            //bool isSuccess = true;
            bool isSuccess = false;
            int  failCount = Global.GetRoleParamsInt32FromDB(client, RoleParamName.ArtifactFailCount); //失败次数
            int  failMax   = (int)GameManager.systemParamsList.GetParamValueIntByName("ZaiZaoBaoDi");
            if (failCount >= failMax)
            {
                isSuccess = true;
                failCount = 0;
                SetArtifactFailCount(client, failCount);
            }
            else
            {
                int rate = Global.GetRandomNumber(0, 100);
                if (rate < artifactDataBasic.SuccessRate)
                {
                    isSuccess = true;
                    failCount = 0;
                    SetArtifactFailCount(client, failCount);
                }
            }

            bool useBind      = false;
            bool useTimeLimit = false;
            //失败------------------------------------------------------------------------
            if (!isSuccess)
            {
                //扣除材料
                foreach (var d in artifactDataBasic.FailMaterial)
                {
                    int materialId = d.Key;
                    int count      = d.Value;

                    bool isOk = Global.UseGoodsBindOrNot(client, materialId, count, isUseBind, out useBind, out useTimeLimit) >= 1;
                    if (!isOk)
                    {
                        result.State = (int)ArtifactResultType.EnoMaterial;
                        return(result);
                    }
                }

                failCount++;
                Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.ArtifactFailCount, failCount, true);

                GameManager.logDBCmdMgr.AddDBLogInfo(artifactDataBasic.NewEquitID, artifactDataBasic.ArtifactName, "神器再造失败", client.ClientData.RoleName, client.ClientData.RoleName, "再造", 1, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, equipData);

                EventLogManager.AddRoleEvent(client, OpTypes.Trace, OpTags.ShenQiZaiZao, LogRecordType.ShenQiZaiZao, artifactDataBasic.NewEquitID, 0, failCount);

                result.State = (int)ArtifactResultType.Fail;
                return(result);
            }

            //成功------------------------------------------------------------------------
            //扣除材料
            foreach (var d in artifactDataBasic.NeedMaterial)
            {
                int materialId = d.Key;
                int count      = d.Value;

                bool oneUseBind      = false;
                bool oneUseTimeLimit = false;
                bool isOk            = Global.UseGoodsBindOrNot(client, materialId, count, isUseBind, out oneUseBind, out oneUseTimeLimit) >= 1;
                if (!isOk)
                {
                    result.State = (int)ArtifactResultType.EnoMaterial;
                    return(result);
                }

                useBind      = useBind || oneUseBind;
                useTimeLimit = useTimeLimit || oneUseTimeLimit;
            }

            //扣除再造点
            GameManager.ClientMgr.ModifyZaiZaoValue(client, -artifactDataBasic.NeedZaiZao, "神器再造", true, true);

            EventLogManager.AddRoleEvent(client, OpTypes.Trace, OpTags.ShenQiZaiZao, LogRecordType.ShenQiZaiZao, artifactDataBasic.NewEquitID, 1, 0);

            #endregion

            #region 再造

            int        _Forge_level    = equipData.Forge_level;    //强化等级
            int        _AppendPropLev  = equipData.AppendPropLev;  //追加等级
            int        _Lucky          = equipData.Lucky;          //幸运属性
            int        _ExcellenceInfo = equipData.ExcellenceInfo; //卓越属性
            List <int> _WashProps      = equipData.WashProps;      //培养属性
            int        _Binding        = equipData.Binding;        //绑定状态
            if (useBind)
            {
                _Binding = 1;
            }

            //扣除原有的装备
            if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool,
                                                      Global._TCPManager.TcpOutPacketPool, client, equipID, false))
            {
                result.State = (int)ArtifactResultType.EdelEquip;
                return(result);
            }

            //给予新的装备
            int nItemDBID = Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client,
                                                     artifactDataBasic.NewEquitID, 1,
                                                     equipData.Quality, //
                                                     "",
                                                     _Forge_level,
                                                     _Binding,
                                                     0,
                                                     equipData.Jewellist, //""
                                                     false,
                                                     1,
                                                     /**/ "神器再造",
                                                     Global.ConstGoodsEndTime,
                                                     equipData.AddPropIndex, //0, //
                                                     equipData.BornIndex,    //
                                                     _Lucky,
                                                     0,
                                                     _ExcellenceInfo,
                                                     _AppendPropLev,
                                                     equipData.ChangeLifeLevForEquip,//0, //
                                                     _WashProps);

            if (nItemDBID < 0)
            {
                result.State = (int)ArtifactResultType.EaddEquip;
                return(result);
            }

            #endregion

            // 玩家【用户名字】勇往直前,勇不可挡,通过了万魔塔第XX层!
            string broadcastMsg = StringUtil.substitute(Global.GetLang("玩家【{0}】成功进行了神器再造,获得了{2}阶装备【{1}】!"),
                                                        Global.FormatRoleName(client, client.ClientData.RoleName), artifactDataBasic.ArtifactName, nSuitID + 1);
            //播放用户行为消息
            Global.BroadcastRoleActionMsg(client, RoleActionsMsgTypes.HintMsg, broadcastMsg, true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.OnlySysHint);

            result.State     = (int)ArtifactResultType.Success;
            result.EquipDbID = nItemDBID;
            result.Bind      = _Binding;
            return(result);
        }
示例#19
0
        public ShenQiData LevelUpShenQiData(GameClient client, int useBaoJi)
        {
            ShenQiData result;

            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.ShenQi, false))
            {
                result = new ShenQiData
                {
                    UpResultType = -1
                };
            }
            else
            {
                ShenQiData data = client.ClientData.shenQiData;
                try
                {
                    if (null == data)
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("ShenQi :: 注入失败,获取角色神器数据错误,角色id:{0}", client.ClientData.RoleID), null, true);
                        return(new ShenQiData
                        {
                            UpResultType = 0
                        });
                    }
                    ArtifactItem artifactItem = null;
                    lock (this.ShenQiRunTimeData.Mutex)
                    {
                        this.ShenQiRunTimeData.ArtifactXmlDict.TryGetValue(data.ShenQiID, out artifactItem);
                    }
                    if (null == artifactItem)
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("ShenQi :: 注入失败,获取角色神器数据配置项错误,角色id:{0}, ShenQiID:{1}", client.ClientData.RoleID, data.ShenQiID), null, true);
                        return(new ShenQiData
                        {
                            UpResultType = 0
                        });
                    }
                    if (client.ClientData.ShenLiJingHuaPoints < artifactItem.CostShenLiJingHua)
                    {
                        return(new ShenQiData
                        {
                            UpResultType = -2
                        });
                    }
                    int GoldGoodsNum = 0;
                    if (artifactItem.CostGoldGoodsID > 0)
                    {
                        GoldGoodsNum = Global.GetTotalGoodsCountByID(client, artifactItem.CostGoldGoodsID);
                    }
                    if (client.ClientData.YinLiang < artifactItem.CostGoldCoin && (artifactItem.CostGoldGoodsNum <= 0 || GoldGoodsNum < artifactItem.CostGoldGoodsNum))
                    {
                        return(new ShenQiData
                        {
                            UpResultType = -4
                        });
                    }
                    if (useBaoJi > 0 && client.ClientData.UserMoney < artifactItem.CostDiamond && !HuanLeDaiBiManager.GetInstance().HuanledaibiEnough(client, artifactItem.CostDiamond))
                    {
                        return(new ShenQiData
                        {
                            UpResultType = -3
                        });
                    }
                    GameManager.ClientMgr.ModifyShenLiJingHuaPointsValue(client, -artifactItem.CostShenLiJingHua, "神器注入_精华", true, true);
                    if (artifactItem.CostGoldGoodsNum > 0 && GoldGoodsNum >= artifactItem.CostGoldGoodsNum)
                    {
                        bool oneUseBind      = false;
                        bool oneUseTimeLimit = false;
                        if (Global.UseGoodsBindOrNot(client, artifactItem.CostGoldGoodsID, artifactItem.CostGoldGoodsNum, true, out oneUseBind, out oneUseTimeLimit) < 1)
                        {
                            return(new ShenQiData
                            {
                                UpResultType = -4
                            });
                        }
                    }
                    else if (!GameManager.ClientMgr.SubUserYinLiang(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, artifactItem.CostGoldCoin, "神器注入_金币", false))
                    {
                        return(new ShenQiData
                        {
                            UpResultType = -4
                        });
                    }
                    if (useBaoJi > 0)
                    {
                        if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, artifactItem.CostDiamond, "神器注入_钻石", true, true, false, DaiBiSySType.ShenQiXiTong))
                        {
                            return(new ShenQiData
                            {
                                UpResultType = -4
                            });
                        }
                    }
                    int   rate     = 0;
                    int   r        = Global.GetRandomNumber(0, 101);
                    int[] addProps = null;
                    for (int i = 0; i < artifactItem.QiangHuaRate.Length; i++)
                    {
                        rate += artifactItem.QiangHuaRate[i];
                        if (r <= rate)
                        {
                            addProps       = artifactItem.QiangHuaArray[i];
                            data.BurstType = i;
                            if (useBaoJi > 0 && 0 == i)
                            {
                                addProps       = artifactItem.QiangHuaArray[1];
                                data.BurstType = 1;
                            }
                            break;
                        }
                    }
                    data.LifeAdd      += addProps[0];
                    data.LifeAdd       = ((data.LifeAdd > artifactItem.PropArray[0]) ? artifactItem.PropArray[0] : data.LifeAdd);
                    data.AttackAdd    += addProps[1];
                    data.AttackAdd     = ((data.AttackAdd > artifactItem.PropArray[1]) ? artifactItem.PropArray[1] : data.AttackAdd);
                    data.DefenseAdd   += addProps[2];
                    data.DefenseAdd    = ((data.DefenseAdd > artifactItem.PropArray[2]) ? artifactItem.PropArray[2] : data.DefenseAdd);
                    data.ToughnessAdd += addProps[3];
                    data.ToughnessAdd  = ((data.ToughnessAdd > artifactItem.PropArray[3]) ? artifactItem.PropArray[3] : data.ToughnessAdd);
                    if (data.LifeAdd < artifactItem.PropArray[0] || data.DefenseAdd < artifactItem.PropArray[2] || data.AttackAdd < artifactItem.PropArray[1] || data.ToughnessAdd < artifactItem.PropArray[3])
                    {
                        data.UpResultType = 1;
                    }
                    else if (this.ShenQiRunTimeData.ArtifactXmlDict.ContainsKey(data.ShenQiID + 1))
                    {
                        data.UpResultType = 2;
                        data.ShenQiID++;
                        data.LifeAdd      = 0;
                        data.AttackAdd    = 0;
                        data.DefenseAdd   = 0;
                        data.ToughnessAdd = 0;
                    }
                    else
                    {
                        data.UpResultType = 3;
                    }
                    data.ShenLiJingHuaLeft = client.ClientData.ShenLiJingHuaPoints;
                    List <int> props = new List <int>();
                    props.AddRange(new int[]
                    {
                        data.ShenQiID,
                        data.LifeAdd,
                        data.AttackAdd,
                        data.DefenseAdd,
                        data.ToughnessAdd
                    });
                    Global.SaveRoleParamsIntListToDB(client, props, "36", true);
                    client.ClientData.shenQiData = data;
                    this.UpdateRoleShenQiProps(client);
                    this.UpdateRoleTouhgnessProps(client);
                    if (data.UpResultType == 2 || data.UpResultType == 3)
                    {
                        this.UpdateRoleGodProps(client);
                        GameManager.logDBCmdMgr.AddDBLogInfo(-1, "神像", "神器升阶", client.ClientData.RoleName, "系统", "增加", 1, client.ClientData.ZoneID, client.strUserID, data.ShenQiID, client.ServerId, null);
                    }
                    GameManager.logDBCmdMgr.AddDBLogInfo(-1, "韧性", "神器注入_韧性", client.ClientData.RoleName, "系统", "增加", addProps[3], client.ClientData.ZoneID, client.strUserID, Convert.ToInt32(RoleAlgorithm.GetExtProp(client, 101)), client.ServerId, null);
                    GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                    GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7);
                }
                catch (Exception ex)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("ShenQi :: 升级角色神器数据错误 roleid={0} ex:{1}", client.ClientData.RoleID, ex.Message), null, true);
                    return(data);
                }
                result = data;
            }
            return(result);
        }
示例#20
0
        private EHolyResult HolyItem_Suit_Up(GameClient client, sbyte sShengWu_slot, sbyte sBuJian_slot)
        {
            EHolyResult result;

            if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot7))
            {
                result = EHolyResult.NotOpen;
            }
            else if (!GameManager.VersionSystemOpenMgr.IsVersionSystemOpen("HolyItem"))
            {
                result = EHolyResult.NotOpen;
            }
            else if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.HolyItem, true))
            {
                result = EHolyResult.NotOpen;
            }
            else if (null == client.ClientData.MyHolyItemDataDic)
            {
                result = EHolyResult.Error;
            }
            else
            {
                Dictionary <sbyte, HolyItemData> holyitemdata = client.ClientData.MyHolyItemDataDic;
                HolyItemData     tmpdata     = null;
                HolyItemPartData tmppartdata = null;
                HolyPartInfo     xmlData     = null;
                if (!holyitemdata.TryGetValue(sShengWu_slot, out tmpdata))
                {
                    result = EHolyResult.Error;
                }
                else if (!tmpdata.m_PartArray.TryGetValue(sBuJian_slot, out tmppartdata))
                {
                    result = EHolyResult.Error;
                }
                else if (tmppartdata.m_sSuit >= HolyItemManager.MAX_HOLY_PART_LEVEL)
                {
                    result = EHolyResult.PartSuitIsMax;
                }
                else
                {
                    int nDataID = HolyPartInfo.GetBujianID(sShengWu_slot, sBuJian_slot, tmppartdata.m_sSuit);
                    if (!this._partDataDic.TryGetValue(nDataID, out xmlData))
                    {
                        result = EHolyResult.Error;
                    }
                    else if (-1 != xmlData.m_nCostBandJinBi && xmlData.m_nCostBandJinBi > Global.GetTotalBindTongQianAndTongQianVal(client))
                    {
                        result = EHolyResult.NeedGold;
                    }
                    else if (-1 != xmlData.m_nNeedGoodsCount && xmlData.m_nNeedGoodsCount > tmppartdata.m_nSlice)
                    {
                        result = EHolyResult.NeedHolyItemPart;
                    }
                    else
                    {
                        bool bSuccess = false;
                        int  nRank    = Global.GetRandomNumber(0, 100);
                        if (-1 == xmlData.m_sSuccessProbability || tmppartdata.m_nFailCount >= xmlData.m_nMaxFailCount || nRank < (int)xmlData.m_sSuccessProbability)
                        {
                            bSuccess = true;
                            for (int i = 0; i < xmlData.NeedGoods.Count; i++)
                            {
                                int goodsId      = xmlData.NeedGoods[i][0];
                                int costCount    = xmlData.NeedGoods[i][1];
                                int haveGoodsCnt = Global.GetTotalGoodsCountByID(client, goodsId);
                                if (haveGoodsCnt < costCount)
                                {
                                    return(EHolyResult.NeedGoods);
                                }
                            }
                            if (-1 != xmlData.m_nCostBandJinBi)
                            {
                                if (!Global.SubBindTongQianAndTongQian(client, xmlData.m_nCostBandJinBi, "圣物部件升级消耗"))
                                {
                                    return(EHolyResult.Error);
                                }
                            }
                            if (-1 != xmlData.m_nNeedGoodsCount)
                            {
                                tmppartdata.m_nSlice -= xmlData.m_nNeedGoodsCount;
                            }
                            if (tmppartdata.m_nSlice < 0)
                            {
                                tmppartdata.m_nSlice = 0;
                                return(EHolyResult.Error);
                            }
                            bool bUsedBinding_just_placeholder     = false;
                            bool bUsedTimeLimited_just_placeholder = false;
                            for (int i = 0; i < xmlData.NeedGoods.Count; i++)
                            {
                                int goodsId   = xmlData.NeedGoods[i][0];
                                int costCount = xmlData.NeedGoods[i][1];
                                if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodsId, costCount, false, out bUsedBinding_just_placeholder, out bUsedTimeLimited_just_placeholder, false))
                                {
                                    LogManager.WriteLog(LogTypes.Error, string.Format("圣物部件升级时,消耗{1}个GoodsID={0}的物品失败,但是已设置为升阶成功", goodsId, costCount), null, true);
                                }
                                GoodsData goodsData = new GoodsData();
                                goodsData.GoodsID = goodsId;
                                goodsData.GCount  = costCount;
                            }
                            HolyItemPartData holyItemPartData = tmppartdata;
                            holyItemPartData.m_sSuit += 1;
                            tmppartdata.m_nFailCount  = 0;
                        }
                        else
                        {
                            for (int i = 0; i < xmlData.FaildNeedGoods.Count; i++)
                            {
                                int goodsId      = xmlData.FaildNeedGoods[i][0];
                                int costCount    = xmlData.FaildNeedGoods[i][1];
                                int haveGoodsCnt = Global.GetTotalGoodsCountByID(client, goodsId);
                                if (haveGoodsCnt < costCount)
                                {
                                    return(EHolyResult.NeedGoods);
                                }
                            }
                            if (-1 != xmlData.m_nCostBandJinBi)
                            {
                                if (!Global.SubBindTongQianAndTongQian(client, xmlData.m_nCostBandJinBi, "圣物部件升级消耗"))
                                {
                                    return(EHolyResult.Error);
                                }
                            }
                            bool bUsedBinding_just_placeholder     = false;
                            bool bUsedTimeLimited_just_placeholder = false;
                            for (int i = 0; i < xmlData.FaildNeedGoods.Count; i++)
                            {
                                int goodsId   = xmlData.FaildNeedGoods[i][0];
                                int costCount = xmlData.FaildNeedGoods[i][1];
                                if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodsId, costCount, false, out bUsedBinding_just_placeholder, out bUsedTimeLimited_just_placeholder, false))
                                {
                                    LogManager.WriteLog(LogTypes.Error, string.Format("圣物部件升级时,消耗{1}个GoodsID={0}的物品失败", goodsId, costCount), null, true);
                                }
                                GoodsData goodsData2 = new GoodsData();
                                goodsData2.GoodsID = goodsId;
                                goodsData2.GCount  = costCount;
                            }
                            if (-1 != xmlData.m_nFailCostGoodsCount)
                            {
                                tmppartdata.m_nSlice -= xmlData.m_nFailCostGoodsCount;
                            }
                            if (tmppartdata.m_nSlice < 0)
                            {
                                tmppartdata.m_nSlice = 0;
                                return(EHolyResult.Error);
                            }
                            tmppartdata.m_nFailCount++;
                        }
                        if (bSuccess)
                        {
                            this.UpdateHolyItemBuJianAttr(client, sShengWu_slot, sBuJian_slot);
                            this.UpdataHolyItemExAttr(client, sShengWu_slot);
                            GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                            GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7);
                        }
                        this.UpdateHolyItemData2DB(client, sShengWu_slot, sBuJian_slot, tmppartdata);
                        this.HolyItemSendToClient(client, sShengWu_slot, sBuJian_slot);
                        GameManager.logDBCmdMgr.AddDBLogInfo(-1, HolyItemManager.SliceNameSet[(int)sShengWu_slot, (int)sBuJian_slot], "圣物进阶", "系统", client.ClientData.RoleName, bSuccess ? "成功" : "失败", (xmlData.m_nCostBandJinBi != -1) ? xmlData.m_nCostBandJinBi : 0, client.ClientData.ZoneID, client.strUserID, tmppartdata.m_nSlice, client.ServerId, null);
                        if (client._IconStateMgr.CheckSpecialActivity(client) || client._IconStateMgr.CheckEverydayActivity(client))
                        {
                            client._IconStateMgr.SendIconStateToClient(client);
                        }
                        result = (bSuccess ? EHolyResult.Success : EHolyResult.Fail);
                    }
                }
            }
            return(result);
        }
示例#21
0
        //圣物进阶
        private EHolyResult HolyItem_Suit_Up(GameClient client, sbyte sShengWu_slot, sbyte sBuJian_slot)
        {
            // 如果1.7的功能没开放
            if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot7))
            {
                return(EHolyResult.NotOpen);
            }

            //增加系统开启判断
            if (false == GameManager.VersionSystemOpenMgr.IsVersionSystemOpen(VersionSystemOpenKey.HolyItem))
            {
                return(EHolyResult.NotOpen);
            }

            //不满足任务条件
            if (GlobalNew.IsGongNengOpened(client, GongNengIDs.HolyItem, true) == false)
            {
                return(EHolyResult.NotOpen);
            }

            if (null == client.ClientData.MyHolyItemDataDic)
            {
                return(EHolyResult.Error);
            }

            Dictionary <sbyte, HolyItemData> holyitemdata = client.ClientData.MyHolyItemDataDic;
            HolyItemData     tmpdata     = null;
            HolyItemPartData tmppartdata = null;
            HolyPartInfo     xmlData     = null;

            //先取得当前圣物部件等级
            if (false == holyitemdata.TryGetValue(sShengWu_slot, out tmpdata))
            {
                return(EHolyResult.Error);
            }

            if (false == tmpdata.m_PartArray.TryGetValue(sBuJian_slot, out tmppartdata))
            {
                return(EHolyResult.Error);
            }

            //0 看看要升级的部件阶级是不是已经满级了
            if (tmppartdata.m_sSuit >= MAX_HOLY_PART_LEVEL)
            {
                return(EHolyResult.PartSuitIsMax);
            }

            int nDataID = HolyPartInfo.GetBujianID(sShengWu_slot, sBuJian_slot, (sbyte)tmppartdata.m_sSuit);

            if (false == _partDataDic.TryGetValue(nDataID, out xmlData))
            {
                return(EHolyResult.Error);
            }

            //1 绑金+金币是否足够
            if (-1 != xmlData.m_nCostBandJinBi &&
                xmlData.m_nCostBandJinBi > Global.GetTotalBindTongQianAndTongQianVal(client))
            {
                return(EHolyResult.NeedGold);
            }

            //2 部件碎片是否足够
            if (-1 != xmlData.m_nNeedGoodsCount &&
                xmlData.m_nNeedGoodsCount > tmppartdata.m_nSlice)
            {
                return(EHolyResult.NeedHolyItemPart);
            }

            //3 以上均满足,判断成功率
            bool bSuccess = false;
            int  nRank    = Global.GetRandomNumber(0, 100);

            if (-1 == xmlData.m_sSuccessProbability ||
                tmppartdata.m_nFailCount >= xmlData.m_nMaxFailCount ||      //[bing] 2015,8,12 达到连续失败最大次数必成功
                nRank < (int)(xmlData.m_sSuccessProbability))
            {
                //4 合成成功:消耗金币、消耗部件碎片,阶数+1
                bSuccess = true;

                //扣除金币
                if (-1 != xmlData.m_nCostBandJinBi)
                {
                    if (!Global.SubBindTongQianAndTongQian(client, xmlData.m_nCostBandJinBi, "圣物部件升级消耗"))
                    {
                        return(EHolyResult.Error);
                    }
                }

                //扣除部件碎片
                if (-1 != xmlData.m_nNeedGoodsCount)
                {
                    tmppartdata.m_nSlice -= xmlData.m_nNeedGoodsCount;
                }
                if (tmppartdata.m_nSlice < 0)
                {
                    tmppartdata.m_nSlice = 0;
                    return(EHolyResult.Error);
                }

                //部件阶级提升
                tmppartdata.m_sSuit += 1;

                //重置失败次数
                tmppartdata.m_nFailCount = 0;
            }
            else
            {
                //5 合成失败:消耗金币、消耗部分部件碎片

                //扣除金币
                if (-1 != xmlData.m_nCostBandJinBi)
                {
                    if (!Global.SubBindTongQianAndTongQian(client, xmlData.m_nCostBandJinBi, "圣物部件升级消耗"))
                    {
                        return(EHolyResult.Error);
                    }
                }

                //扣除失败时的部件碎片
                if (-1 != xmlData.m_nFailCostGoodsCount)
                {
                    tmppartdata.m_nSlice -= xmlData.m_nFailCostGoodsCount;
                }
                if (tmppartdata.m_nSlice < 0)
                {
                    tmppartdata.m_nSlice = 0;
                    return(EHolyResult.Error);
                }

                //失败次数增加1
                tmppartdata.m_nFailCount += 1;
            }

            if (true == bSuccess)
            {
                //计算部件属性
                UpdateHolyItemBuJianAttr(client, sShengWu_slot, sBuJian_slot);

                //计算圣物额外属性
                UpdataHolyItemExAttr(client, sShengWu_slot);

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

            //更新db
            UpdateHolyItemData2DB(client, sShengWu_slot, sBuJian_slot, tmppartdata);

            //发送给客户端更新数据
            HolyItemSendToClient(client, sShengWu_slot, sBuJian_slot);

            //写log做进阶统计
            GameManager.logDBCmdMgr.AddDBLogInfo(
                -1
                , SliceNameSet[sShengWu_slot, sBuJian_slot]
                , /**/ "圣物进阶"
                , /**/ "系统"
                , client.ClientData.RoleName
                , bSuccess == true ? /**/ "成功" : /**/ "失败"
                , xmlData.m_nCostBandJinBi != -1 ? xmlData.m_nCostBandJinBi : 0     //消耗的金币数
                , client.ClientData.ZoneID
                , client.strUserID
                , tmppartdata.m_nSlice
                , client.ServerId);

            if (client._IconStateMgr.CheckSpecialActivity(client))
            {
                client._IconStateMgr.SendIconStateToClient(client);
            }

            return(bSuccess == true ? EHolyResult.Success : EHolyResult.Fail);
        }
示例#22
0
        public bool ProcessKuaFuMapEnterCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                int result     = 0;
                int toMapCode  = Global.SafeConvertToInt32(cmdParams[0]);
                int line       = Global.SafeConvertToInt32(cmdParams[1]);
                int toBoss     = 0;
                int teleportId = 0;
                if (cmdParams.Length >= 3)
                {
                    toBoss = Global.SafeConvertToInt32(cmdParams[2]);
                }
                if (cmdParams.Length >= 4)
                {
                    teleportId = Global.SafeConvertToInt32(cmdParams[3]);
                }
                KuaFuLineData kuaFuLineData;
                if (!KuaFuMapManager.getInstance().IsKuaFuMap(toMapCode))
                {
                    result = -12;
                }
                else if (!this.RuntimeData.LineMap2KuaFuLineDataDict.TryGetValue(new IntPairKey(line, toMapCode), out kuaFuLineData))
                {
                    result = -12;
                }
                else if (!Global.CanEnterMap(client, toMapCode) || (toMapCode == client.ClientData.MapCode && kuaFuLineData.MapType != 1))
                {
                    result = -12;
                }
                else
                {
                    if (toMapCode == client.ClientData.MapCode && kuaFuLineData.MapType == 1)
                    {
                        List <KuaFuLineData> list = KuaFuWorldClient.getInstance().GetKuaFuLineDataList(toMapCode) as List <KuaFuLineData>;
                        if (null == list)
                        {
                            result = -12;
                            goto IL_67F;
                        }
                        KuaFuLineData currentLineData = list.Find((KuaFuLineData x) => x.ServerId == GameManager.KuaFuServerId);
                        if (currentLineData != null && currentLineData.Line == kuaFuLineData.Line)
                        {
                            result = -4011;
                            goto IL_67F;
                        }
                    }
                    if (!KuaFuMapManager.getInstance().IsKuaFuMap(client.ClientData.MapCode) && !this.CheckMap(client))
                    {
                        result = -21;
                    }
                    else if (!this.IsGongNengOpened(client, false))
                    {
                        result = -12;
                    }
                    else if (kuaFuLineData.OnlineCount >= kuaFuLineData.MaxOnlineCount)
                    {
                        result = -100;
                    }
                    else
                    {
                        int fromMapCode = client.ClientData.MapCode;
                        if (teleportId > 0)
                        {
                            GameMap fromGameMap = null;
                            if (!GameManager.MapMgr.DictMaps.TryGetValue(fromMapCode, out fromGameMap))
                            {
                                result = -3;
                                goto IL_67F;
                            }
                            MapTeleport mapTeleport = null;
                            if (!fromGameMap.MapTeleportDict.TryGetValue(teleportId, out mapTeleport) || mapTeleport.ToMapID != toMapCode)
                            {
                                result = -12;
                                goto IL_67F;
                            }
                            if (Global.GetTwoPointDistance(client.CurrentPos, new Point((double)mapTeleport.X, (double)mapTeleport.Y)) > 800.0)
                            {
                                result = -301;
                                goto IL_67F;
                            }
                        }
                        KuaFuServerLoginData kuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client);
                        int kuaFuServerId;
                        if (kuaFuLineData.MapType == 1)
                        {
                            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.Reborn, true))
                            {
                                result = -400;
                                goto IL_67F;
                            }
                            string signToken;
                            string signKey;
                            int    rt = KuaFuWorldClient.getInstance().EnterPTKuaFuMap(client.ServerId, client.ClientData.LocalRoleID, client.ClientData.ServerPTID, kuaFuLineData.MapCode, kuaFuLineData.Line, kuaFuServerLoginData, out signToken, out signKey);
                            if (rt == -4010)
                            {
                                KuaFuWorldRoleData kuaFuWorldRoleData = new KuaFuWorldRoleData
                                {
                                    LocalRoleID = client.ClientData.LocalRoleID,
                                    UserID      = client.strUserID,
                                    WorldRoleID = client.ClientData.WorldRoleID,
                                    Channel     = client.ClientData.Channel,
                                    PTID        = client.ClientData.ServerPTID,
                                    ServerID    = client.ServerId,
                                    ZoneID      = client.ClientData.ZoneID
                                };
                                rt = KuaFuWorldClient.getInstance().RegPTKuaFuRoleData(ref kuaFuWorldRoleData);
                                rt = KuaFuWorldClient.getInstance().EnterPTKuaFuMap(client.ServerId, client.ClientData.LocalRoleID, client.ClientData.ServerPTID, kuaFuLineData.MapCode, kuaFuLineData.Line, kuaFuServerLoginData, out signToken, out signKey);
                            }
                            if (rt < 0)
                            {
                                result = rt;
                                goto IL_67F;
                            }
                            KFRebornRoleData rebornRoleData = KuaFuWorldClient.getInstance().Reborn_GetRebornRoleData(client.ClientData.ServerPTID, client.ClientData.LocalRoleID);
                            if (null == rebornRoleData)
                            {
                                result = KuaFuWorldClient.getInstance().Reborn_RoleReborn(client.ClientData.ServerPTID, client.ClientData.LocalRoleID, client.ClientData.RoleName, client.ClientData.RebornLevel);
                                if (result < 0)
                                {
                                    goto IL_67F;
                                }
                                LogManager.WriteLog(LogTypes.Analysis, string.Format("Reborn_RoleReborn ptId={0} roleId={1} roleName={2} rebornLevel={3}", new object[]
                                {
                                    client.ClientData.ServerPTID,
                                    client.ClientData.LocalRoleID,
                                    client.ClientData.RoleName,
                                    client.ClientData.RebornLevel
                                }), null, true);
                            }
                            kuaFuServerLoginData.PTID       = client.ClientData.ServerPTID;
                            kuaFuServerLoginData.RoleId     = client.ClientData.LocalRoleID;
                            kuaFuServerLoginData.SignToken  = signToken;
                            kuaFuServerLoginData.TempRoleID = rt;
                            kuaFuServerLoginData.SignCode   = MD5Helper.get_md5_string(kuaFuServerLoginData.SignDataString() + signKey).ToLower();
                            kuaFuServerId = kuaFuServerLoginData.TargetServerID;
                        }
                        else
                        {
                            kuaFuServerLoginData.SignCode = null;
                            kuaFuServerId = YongZheZhanChangClient.getInstance().EnterKuaFuMap(client.ClientData.LocalRoleID, kuaFuLineData.MapCode, kuaFuLineData.Line, client.ServerId, Global.GetClientKuaFuServerLoginData(client));
                        }
                        kuaFuServerLoginData.Line = line;
                        if (kuaFuServerId > 0)
                        {
                            bool flag      = 0 == 0;
                            int  needMoney = (teleportId > 0) ? 0 : Global.GetMapTransNeedMoney(toMapCode);
                            if (Global.GetTotalBindTongQianAndTongQianVal(client) < needMoney)
                            {
                                GameManager.ClientMgr.NotifyImportantMsg(client, StringUtil.substitute(GLang.GetLang(171, new object[0]), new object[]
                                {
                                    needMoney,
                                    Global.GetMapName(toMapCode)
                                }), GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox, 27);
                                result = -9;
                                Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
                            }
                            else
                            {
                                int[] enterFlags = new int[5];
                                enterFlags[0] = fromMapCode;
                                enterFlags[1] = teleportId;
                                enterFlags[2] = toBoss;
                                Global.SaveRoleParamsIntListToDB(client, new List <int>(enterFlags), "EnterKuaFuMapFlag", true);
                                GlobalNew.RecordSwitchKuaFuServerLog(client);
                                client.sendCmd <KuaFuServerLoginData>(14000, Global.GetClientKuaFuServerLoginData(client), false);
                            }
                        }
                        else
                        {
                            Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
                            result = kuaFuServerId;
                        }
                    }
                }
IL_67F:
                client.sendCmd <int>(nID, result, false);
                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
            }
            return(false);
        }
示例#23
0
 private bool IsGongNengOpened(GameClient client)
 {
     return(this.RuntimeData.IsGongNengOpend && GlobalNew.IsGongNengOpened(client, GongNengIDs.BianShen, false));
 }
示例#24
0
 private bool IsGongNengOpened(GameClient client)
 {
     return(!GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System2Dot3) && GlobalNew.IsGongNengOpened(client, GongNengIDs.ZhuanZhi, false));
 }
示例#25
0
 public static bool HasLeftnum(GameClient client)
 {
     return(GlobalNew.IsGongNengOpened(client, GongNengIDs.CrystalCollect, false) && client.ClientData.DailyCrystalCollectNum < CaiJiLogic.DailyNum);
 }
示例#26
0
        public static LingYuError AdvanceLingYuSuit(GameClient client, int roleID, int type, int useZuanshiIfNoMaterial)
        {
            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu))
            {
                return(LingYuError.NotOpen);
            }

            LingYuType lyType = null;

            if (!LingYuTypeDict.TryGetValue(type, out lyType))
            {
                //找不到该翎羽
                return(LingYuError.ErrorParams);
            }

            LingYuData lyData = null;

            lock (client.ClientData.LingYuDict)
            {
                if (!client.ClientData.LingYuDict.TryGetValue(type, out lyData))
                {
                    lyData       = new LingYuData();
                    lyData.Type  = type;
                    lyData.Level = DEFAULT_LINGYU_LEVEL;
                    lyData.Suit  = 0;
                }
            }

            //已满阶
            if (lyData.Suit == LingYuSuitLimit)
            {
                return(LingYuError.SuitFull);
            }

            //需要提升等级
            if (lyData.Level == 0 || lyData.Level / 10 == lyData.Suit)
            {
                return(LingYuError.NeedLevelUp);
            }

            LingYuSuit nextSuit = null;

            if (!lyType.SuitDict.TryGetValue(lyData.Suit + 1, out nextSuit)) //找不到下一阶配置
            {
                return(LingYuError.ErrorConfig);
            }

            if (Global.GetTotalBindTongQianAndTongQianVal(client) < nextSuit.JinBiCost)
            {
                return(LingYuError.SuitUpJinBiNotEnough);
            }

            int haveGoodsCnt = Global.GetTotalGoodsCountByID(client, nextSuit.GoodsCost);

            if (haveGoodsCnt < nextSuit.GoodsCostCnt && useZuanshiIfNoMaterial == 0)
            {
                return(LingYuError.SuitUpMaterialNotEnough);
            }

            //  本来的处理方式是,假设要消耗10个材料,现在玩家只有5个材料,并且勾选了使用钻石
            //  那么将会消耗玩家的这5个材料,不足的5个材料使用钻石替补

            /*
             * int goodsCostCnt = nextSuit.GoodsCostCnt;
             * int zuanshiCost = 0;
             * if (haveGoodsCnt < nextSuit.GoodsCostCnt)
             * {
             *  goodsCostCnt = haveGoodsCnt;
             *  int goodsPrice = 0;
             *  if (!Data.LingYuMaterialZuanshiDict.TryGetValue(nextSuit.GoodsCost, out goodsPrice))
             *      return LingYuError.ErrorConfig;
             *  zuanshiCost = (nextSuit.GoodsCostCnt - haveGoodsCnt) * goodsPrice;
             *  if (client.ClientData.UserMoney < zuanshiCost)
             *      return LingYuError.ZuanShiNotEnough;
             * }
             */

            //  现在的处理方式是,假设要消耗10个材料,现在玩家只有5个材料,并且勾选了使用钻石
            //  那么直接扣除10个材料的钻石价格,玩家的5个材料不消耗
            int goodsCostCnt = nextSuit.GoodsCostCnt;
            int zuanshiCost  = 0;

            if (haveGoodsCnt < nextSuit.GoodsCostCnt)
            {
                goodsCostCnt = 0;
                int goodsPrice = 0;
                if (!Data.LingYuMaterialZuanshiDict.TryGetValue(nextSuit.GoodsCost, out goodsPrice))
                {
                    return(LingYuError.ErrorConfig);
                }
                zuanshiCost = nextSuit.GoodsCostCnt * goodsPrice;
                if (client.ClientData.UserMoney < zuanshiCost)
                {
                    return(LingYuError.ZuanShiNotEnough);
                }
            }

            //先扣钱
            if (!Global.SubBindTongQianAndTongQian(client, nextSuit.JinBiCost, "翎羽升阶消耗"))
            {
                return(LingYuError.DBSERVERERROR);
            }

            //有可能出现消耗一部分材料,其余用钻石购买的情况
            if (goodsCostCnt > 0)
            {
                bool bUsedBinding     = false;
                bool bUsedTimeLimited = false;

                if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener,
                                                          Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nextSuit.GoodsCost, goodsCostCnt, false, out bUsedBinding, out bUsedTimeLimited))
                {
                    return(LingYuError.DBSERVERERROR);
                }
            }

            if (zuanshiCost > 0)
            {
                //先DBServer请求扣费  扣除用户点卷
                if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, zuanshiCost, "翎羽升级"))
                {
                    return(LingYuError.DBSERVERERROR);
                }
            }

            //生效,计算属性加成,写数据库
            int iRet = UpdateLingYu2DB(roleID, type, lyData.Level, lyData.Suit + 1, client.ServerId);

            if (iRet < 0)
            {
                return(LingYuError.DBSERVERERROR);
            }

            lyData.Suit++;
            lock (client.ClientData.LingYuDict)
            {
                client.ClientData.LingYuDict[type] = lyData;
            }

            if (LingYuManager.SuitOfNotifyList.Contains(lyData.Suit))
            {
                // 【{0}】将【{1}】提升到{2}阶,翅膀的力量得到了提升。
                string broadcastMsg = StringUtil.substitute(Global.GetLang("【{0}】将【{1}】提升到{2}阶,翅膀的力量得到了提升。"),
                                                            Global.FormatRoleName(client, client.ClientData.RoleName), lyType.Name, lyData.Suit);
                //播放用户行为消息
                Global.BroadcastRoleActionMsg(client, RoleActionsMsgTypes.HintMsg, broadcastMsg, true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.OnlySysHint);
            }

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

            return(LingYuError.Success);
        }
 public bool IsGongNengOpen(GameClient client, bool hint = false)
 {
     return(!GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System2Dot7) && GlobalNew.IsGongNengOpened(client, GongNengIDs.JingLingJueXing, hint));
 }
示例#28
0
        public MazingerStore ProcessMazingerStoreUpGrade(GameClient client, int ClientType, int ClientOpt)
        {
            MazingerStore res = new MazingerStore();

            res.IsBoom = 0;
            bool          up = false;
            MazingerStore result;

            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.MazingerStore, false))
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("玩家魔神秘宝功能未开启, 玩家id RoleID={0}", client.ClientData.RoleID), null, true);
                res.result = 12;
                result     = res;
            }
            else
            {
                if (ClientOpt < 0 || ClientOpt > 1)
                {
                    res.result = 2;
                }
                else if (ClientOpt == 0)
                {
                    if (this.MazingerStar == null || this.MazingerStarLevelMax == null || !this.MazingerStar.ContainsKey(ClientType) || !this.MazingerStarLevelMax.ContainsKey(ClientType))
                    {
                        res.result = 3;
                    }
                    else
                    {
                        if (client.ClientData.MazingerStoreDataInfo == null)
                        {
                            client.ClientData.MazingerStoreDataInfo = new Dictionary <int, MazingerStoreData>();
                        }
                        MazingerStoreData newData = null;
                        bool flag         = false;
                        int  StarLevelMax = 0;
                        if (client.ClientData.MazingerStoreDataInfo.ContainsKey(ClientType))
                        {
                            StarLevelMax = this.MazingerStarLevelMax[ClientType][client.ClientData.MazingerStoreDataInfo[ClientType].Stage];
                            if (client.ClientData.MazingerStoreDataInfo[ClientType].StarLevel >= StarLevelMax)
                            {
                                res.result = 5;
                                goto IL_B64;
                            }
                            newData = this.CopyMazingerStoreMemData(client, ClientType);
                            flag    = true;
                        }
                        else
                        {
                            newData           = new MazingerStoreData();
                            newData.RoleID    = client.ClientData.RoleID;
                            newData.Type      = ClientType;
                            newData.Exp       = 0;
                            newData.Stage     = 1;
                            newData.StarLevel = 0;
                            StarLevelMax      = this.MazingerStarLevelMax[ClientType][newData.Stage];
                        }
                        if (newData == null || !this.MazingerStar.ContainsKey(newData.Type) || !this.MazingerStar[newData.Type].ContainsKey(newData.Stage) || !this.MazingerStar[newData.Type][newData.Stage].ContainsKey(newData.StarLevel) || this.MazingerStar[newData.Type][newData.Stage][newData.StarLevel].UseGoods == null || this.MazingerStar[newData.Type][newData.Stage][newData.StarLevel].UseGoods.Count == 0)
                        {
                            res.result = 6;
                        }
                        else
                        {
                            List <double> rate = this.GetSystemParamMibao();
                            if (rate == null || rate.Count != 2)
                            {
                                res.result = 4;
                            }
                            else
                            {
                                int    AddExp = this.MazingerStar[newData.Type][newData.Stage][newData.StarLevel].Exp;
                                double rand   = Global.GetRandom();
                                if (rand <= rate[0])
                                {
                                    AddExp     = Convert.ToInt32((double)AddExp * rate[1]);
                                    res.IsBoom = 1;
                                }
                                foreach (KeyValuePair <int, int> iter in this.MazingerStar[newData.Type][newData.Stage][newData.StarLevel].UseGoods)
                                {
                                    bool EquipBindUse;
                                    if (!RebornStone.RebornUseGoodHasBinding(client, iter.Key, iter.Value, 1, out EquipBindUse))
                                    {
                                        res.result = 7;
                                        break;
                                    }
                                }
                                if (res.result != 7)
                                {
                                    int totleExp  = newData.Exp + AddExp;
                                    int currLevel = newData.StarLevel;
                                    int oldUpExp  = this.MazingerStar[newData.Type][newData.Stage][newData.StarLevel].UpExp;
                                    while (currLevel < StarLevelMax)
                                    {
                                        if (totleExp < oldUpExp)
                                        {
                                            break;
                                        }
                                        currLevel++;
                                        totleExp -= oldUpExp;
                                        if (totleExp < 0)
                                        {
                                            totleExp = 0;
                                            break;
                                        }
                                        if (this.MazingerStar[newData.Type][newData.Stage].ContainsKey(currLevel))
                                        {
                                            oldUpExp = this.MazingerStar[newData.Type][newData.Stage][currLevel].UpExp;
                                        }
                                        if (!up)
                                        {
                                            up = true;
                                        }
                                    }
                                    newData.StarLevel = currLevel;
                                    if (currLevel >= StarLevelMax)
                                    {
                                        newData.Exp = 0;
                                    }
                                    else
                                    {
                                        newData.Exp = totleExp;
                                    }
                                    if (flag)
                                    {
                                        int ret = Global.sendToDB <int, MazingerStoreData>(14126, newData, client.ServerId);
                                        if (ret < 0)
                                        {
                                            LogManager.WriteLog(LogTypes.Error, string.Format("魔神秘宝修改数据出错, 玩家id RoleID={0}", client.ClientData.RoleID), null, true);
                                            res.result = 10;
                                            goto IL_B64;
                                        }
                                        GameManager.logDBCmdMgr.AddDBLogInfo(-1, "魔神秘宝升星", DateTime.Now.ToString(), newData.Type.ToString(), client.ClientData.RoleName, "系统", ClientType, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, null);
                                        EventLogManager.AddMazingerStoreEvent(client, client.ClientData.MazingerStoreDataInfo[newData.Type].StarLevel, newData.StarLevel, client.ClientData.MazingerStoreDataInfo[newData.Type].Exp, newData.Exp, "魔神秘宝升星");
                                        client.ClientData.MazingerStoreDataInfo[newData.Type] = newData;
                                    }
                                    else
                                    {
                                        int ret = Global.sendToDB <int, MazingerStoreData>(14125, newData, client.ServerId);
                                        if (ret < 0)
                                        {
                                            LogManager.WriteLog(LogTypes.Error, string.Format("魔神秘宝插入数据出错, 玩家id RoleID={0}", client.ClientData.RoleID), null, true);
                                            res.result = 10;
                                            goto IL_B64;
                                        }
                                        GameManager.logDBCmdMgr.AddDBLogInfo(-1, "魔神秘宝升星", DateTime.Now.ToString(), newData.Type.ToString(), client.ClientData.RoleName, "系统", ClientType, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, null);
                                        EventLogManager.AddMazingerStoreEvent(client, 0, newData.StarLevel, 0, newData.Exp, "魔神秘宝升星");
                                        client.ClientData.MazingerStoreDataInfo.Add(newData.Type, newData);
                                    }
                                    res.result = 1;
                                    res.data   = client.ClientData.MazingerStoreDataInfo[newData.Type];
                                }
                            }
                        }
                    }
                }
                else if (this.MazingerGrade == null || this.MazingerGradeLevelMax == null || !this.MazingerGrade.ContainsKey(ClientType) || !this.MazingerGradeLevelMax.ContainsKey(ClientType))
                {
                    res.result = 3;
                }
                else if (client.ClientData.MazingerStoreDataInfo == null || !client.ClientData.MazingerStoreDataInfo.ContainsKey(ClientType))
                {
                    res.result = 11;
                }
                else if (client.ClientData.MazingerStoreDataInfo[ClientType].Stage >= this.MazingerGradeLevelMax[ClientType])
                {
                    res.result = 5;
                }
                else
                {
                    MazingerStoreData newData = this.CopyMazingerStoreMemData(client, ClientType);
                    if (newData == null || !this.MazingerGrade.ContainsKey(newData.Type) || !this.MazingerGrade[newData.Type].ContainsKey(newData.Stage) || this.MazingerGrade[newData.Type][newData.Stage].UseGoods == null || this.MazingerGrade[newData.Type][newData.Stage].UseGoods.Count == 0)
                    {
                        res.result = 6;
                    }
                    else
                    {
                        foreach (KeyValuePair <int, int> iter in this.MazingerGrade[newData.Type][newData.Stage].UseGoods)
                        {
                            bool EquipBindUse;
                            if (!RebornStone.RebornUseGoodHasBinding(client, iter.Key, iter.Value, 1, out EquipBindUse))
                            {
                                res.result = 7;
                                break;
                            }
                        }
                        if (res.result != 7)
                        {
                            newData.Exp++;
                            if (this.MazingerGrade[newData.Type][newData.Stage].LuckyOne + newData.Exp >= 110000)
                            {
                                newData.Stage++;
                                newData.StarLevel = 0;
                                newData.Exp       = 0;
                                up = true;
                            }
                            else if (this.MazingerGrade[newData.Type][newData.Stage].LuckyOne + newData.Exp > this.MazingerGrade[newData.Type][newData.Stage].LuckyTwo)
                            {
                                if (Global.GetRandom() < this.MazingerGrade[newData.Type][newData.Stage].Rate)
                                {
                                    newData.Stage++;
                                    newData.StarLevel = 0;
                                    newData.Exp       = 0;
                                    up         = true;
                                    res.IsBoom = 1;
                                }
                            }
                            int ret = Global.sendToDB <int, MazingerStoreData>(14126, newData, client.ServerId);
                            if (ret < 0)
                            {
                                LogManager.WriteLog(LogTypes.Error, string.Format("魔神秘宝修改数据出错, 玩家id RoleID={0}", client.ClientData.RoleID), null, true);
                                res.result = 10;
                            }
                            else
                            {
                                GameManager.logDBCmdMgr.AddDBLogInfo(-1, "魔神秘宝升阶", DateTime.Now.ToString(), newData.Type.ToString(), client.ClientData.RoleName, "系统", ClientType, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, null);
                                EventLogManager.AddMazingerStoreEvent(client, client.ClientData.MazingerStoreDataInfo[newData.Type].Stage, newData.Stage, client.ClientData.MazingerStoreDataInfo[newData.Type].Exp, newData.Exp, "魔神秘宝升阶");
                                client.ClientData.MazingerStoreDataInfo[newData.Type] = newData;
                                res.result = 1;
                                res.data   = client.ClientData.MazingerStoreDataInfo[newData.Type];
                            }
                        }
                    }
                }
IL_B64:
                if (up && res.result == 1)
                {
                    Global.RefreshEquipPropAndNotify(client);
                }
                result = res;
            }
            return(result);
        }
示例#29
0
 public bool IsGongNengOpened(GameClient client, bool hint = false)
 {
     return(!GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot8) && GameManager.VersionSystemOpenMgr.IsVersionSystemOpen("KuaFuBoss") && GlobalNew.IsGongNengOpened(client, GongNengIDs.KuaFuBoss, hint));
 }
示例#30
0
        public static LingYuError AdvanceLingYuLevel(GameClient client, int roleID, int type, int useZuanshiIfNoMaterial)
        {
            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu))
            {
                return(LingYuError.NotOpen);
            }

            LingYuType lyType = null;

            if (!LingYuTypeDict.TryGetValue(type, out lyType))
            {
                //找不到该翎羽
                return(LingYuError.ErrorParams);
            }

            LingYuData lyData = null;

            lock (client.ClientData.LingYuDict)
            {
                if (!client.ClientData.LingYuDict.TryGetValue(type, out lyData))
                {
                    lyData       = new LingYuData();
                    lyData.Type  = type;
                    lyData.Level = DEFAULT_LINGYU_LEVEL;
                    lyData.Suit  = 0;
                }
            }

            //已满级
            if (lyData.Level == LingYuLevelLimit)
            {
                return(LingYuError.LevelFull);
            }

            //需要提升品阶
            if (lyData.Level > 0 && lyData.Level % 10 == 0 && lyData.Level / 10 != lyData.Suit)
            {
                return(LingYuError.NeedSuitUp);
            }

            LingYuLevel nextLevel = null;

            if (!lyType.LevelDict.TryGetValue(lyData.Level + 1, out nextLevel)) //找不到下一级配置
            {
                return(LingYuError.ErrorConfig);
            }

            if (Global.GetTotalBindTongQianAndTongQianVal(client) < nextLevel.JinBiCost)
            {
                return(LingYuError.LevelUpJinBiNotEnough);
            }

            int haveGoodsCnt = Global.GetTotalGoodsCountByID(client, nextLevel.GoodsCost);

            if (haveGoodsCnt < nextLevel.GoodsCostCnt && useZuanshiIfNoMaterial == 0)
            {
                return(LingYuError.LevelUpMaterialNotEnough);
            }

            //  本来的处理方式是,假设要消耗10个材料,现在玩家只有5个材料,并且勾选了使用钻石
            //  那么将会消耗玩家的这5个材料,不足的5个材料使用钻石替补

            /*
             * int goodsCostCnt = nextLevel.GoodsCostCnt;
             * int zuanshiCost = 0;
             * if (haveGoodsCnt < nextLevel.GoodsCostCnt)
             * {
             *  goodsCostCnt = haveGoodsCnt;
             *  int goodsPrice = 0;
             *  if (!Data.LingYuMaterialZuanshiDict.TryGetValue(nextLevel.GoodsCost, out goodsPrice))
             *      return LingYuError.ErrorConfig;
             *  zuanshiCost = (nextLevel.GoodsCostCnt - haveGoodsCnt) * goodsPrice;
             *  if (client.ClientData.UserMoney < zuanshiCost)
             *      return LingYuError.ZuanShiNotEnough;
             * }
             */

            //  现在的处理方式是,假设要消耗10个材料,现在玩家只有5个材料,并且勾选了使用钻石
            //  那么直接扣除10个材料的钻石价格,玩家的5个材料不消耗
            int goodsCostCnt = nextLevel.GoodsCostCnt;
            int zuanshiCost  = 0;

            if (haveGoodsCnt < nextLevel.GoodsCostCnt)
            {
                goodsCostCnt = 0;
                int goodsPrice = 0;
                if (!Data.LingYuMaterialZuanshiDict.TryGetValue(nextLevel.GoodsCost, out goodsPrice))
                {
                    return(LingYuError.ErrorConfig);
                }
                zuanshiCost = nextLevel.GoodsCostCnt * goodsPrice;
                if (client.ClientData.UserMoney < zuanshiCost)
                {
                    return(LingYuError.ZuanShiNotEnough);
                }
            }

            // 先扣钱
            if (!Global.SubBindTongQianAndTongQian(client, nextLevel.JinBiCost, "翎羽升级消耗"))
            {
                return(LingYuError.DBSERVERERROR);
            }

            //有可能出现消耗一部分材料,其余用钻石购买的情况
            if (goodsCostCnt > 0)
            {
                bool bUsedBinding     = false;
                bool bUsedTimeLimited = false;

                if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener,
                                                          Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nextLevel.GoodsCost, goodsCostCnt, false, out bUsedBinding, out bUsedTimeLimited))
                {
                    return(LingYuError.DBSERVERERROR);
                }
            }

            if (zuanshiCost > 0)
            {
                //先DBServer请求扣费
                //扣除用户点卷
                if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, zuanshiCost, "翎羽升级"))
                {
                    return(LingYuError.DBSERVERERROR);
                }
            }

            //生效,计算属性加成,写数据库
            int iRet = UpdateLingYu2DB(roleID, type, lyData.Level + 1, lyData.Suit, client.ServerId);

            if (iRet < 0)
            {
                return(LingYuError.DBSERVERERROR);
            }

            lyData.Level++;
            lock (client.ClientData.LingYuDict)
            {
                client.ClientData.LingYuDict[type] = lyData;
            }

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

            return(LingYuError.Success);
        }