Example #1
0
        public static int ProcessAddHorseAwardLucky(GameClient client, int luckyValue, bool usedTimeLimited, string getType)
        {
            int result;

            if (0 == luckyValue)
            {
                result = 0;
            }
            else
            {
                int horseDbID = client.ClientData.HorseDbID;
                if (horseDbID <= 0)
                {
                    result = -300;
                }
                else
                {
                    HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);
                    if (null == horseData)
                    {
                        result = -1;
                    }
                    else
                    {
                        SystemXmlItem horseUpXmlNode = Global.GetHorseUpXmlNode(horseData.HorseID + 1);
                        if (null == horseUpXmlNode)
                        {
                            result = -35;
                        }
                        else
                        {
                            int horseBlessPoint = horseUpXmlNode.GetIntValue("BlessPoint", -1);
                            int jinJieFailedNum = Global.GetHorseFailedNum(horseData);
                            if (horseData.HorseID >= Global.MaxHorseID)
                            {
                                result = -10;
                            }
                            else
                            {
                                int addLuckValue = Global.GMin(luckyValue, horseBlessPoint - jinJieFailedNum);
                                addLuckValue = Global.GMax(0, addLuckValue);
                                if (!usedTimeLimited)
                                {
                                    Global.AddHorseFailedNum(horseData, addLuckValue);
                                }
                                else
                                {
                                    Global.AddHorseTempJiFen(horseData, addLuckValue);
                                }
                                Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID);
                                Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, getType);
                                result = addLuckValue;
                            }
                        }
                    }
                }
            }
            return(result);
        }
Example #2
0
        /// <summary>
        /// 为指定的坐骑增加养成点(临时)
        /// </summary>
        /// <param name="client"></param>
        /// <param name="horseDbID"></param>
        /// <param name="luckyGoodsID"></param>
        /// <returns></returns>
        public static int ProcessAddHorseLucky(GameClient client, int horseDbID, int luckyGoodsID)
        {
            //获取坐骑数据
            HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);

            if (null == horseData)
            {
                return(-1);
            }

            SystemXmlItem horseUpXmlNode = Global.GetHorseUpXmlNode(horseData.HorseID + 1);

            if (null == horseUpXmlNode)
            {
                return(-35);
            }

            int horseOne = 110000 - horseUpXmlNode.GetIntValue("HorseOne");
            int horseTwo = 110000 - horseUpXmlNode.GetIntValue("HorseTwo");
            //int horseBlessPoint = horseUpXmlNode.GetIntValue("BlessPoint");

            //获取坐骑的失败积分
            int jinJieFailedNum = Global.GetHorseFailedNum(horseData);

            //判断如果已经到了幸运点 - 1,则提示用户不需要使用祝福丹
            if (jinJieFailedNum >= (horseOne - 1))
            {
                return(-100);
            }

            //获取增加幸运点需要的物品ID
            int[] allHorseLuckyGoodsIDs        = GameManager.systemParamsList.GetParamValueIntArrayByName("AllHorseLuckyGoodsIDs");
            int[] allHorseLuckyGoodsIDsToLucky = GameManager.systemParamsList.GetParamValueIntArrayByName("AllHorseLuckyGoodsIDsToLucky");
            if (null == allHorseLuckyGoodsIDs || null == allHorseLuckyGoodsIDsToLucky || allHorseLuckyGoodsIDs.Length != allHorseLuckyGoodsIDsToLucky.Length)
            {
                return(-2);
            }

            //如果已经是最高阶,则不需要再增加幸运点
            if (horseData.HorseID >= Global.MaxHorseID)
            {
                return(-10);
            }

            //判断物品数量
            if (Global.GetTotalGoodsCountByID(client, luckyGoodsID) <= 0)
            {
                return(-20);
            }

            bool usedBinding     = false;
            bool usedTimeLimited = false;

            //扣除物品
            if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener,
                                                      Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, luckyGoodsID, 1, false, out usedBinding, out usedTimeLimited))
            {
                return(-30);
            }

            int addLuckValue = 0;

            for (int i = 0; i < allHorseLuckyGoodsIDs.Length; i++)
            {
                if (allHorseLuckyGoodsIDs[i] == luckyGoodsID)
                {
                    addLuckValue = allHorseLuckyGoodsIDsToLucky[i];
                    break;
                }
            }

            //addLuckValue = Global.GMin(addLuckValue, horseBlessPoint - jinJieFailedNum);
            addLuckValue = Global.GMax(0, addLuckValue);

            //if (!usedTimeLimited) //不是限时的道具
            {
                //记录失败次数
                //horseData.JinJieFailedNum += addLuckValue;
                Global.AddHorseFailedNum(horseData, addLuckValue);
            }
            //else
            //{
            //    Global.AddHorseTempJiFen(horseData, addLuckValue);
            //}

            //记录失败次数
            Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID);

            //写入角色进阶坐骑的行为日志
            Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, "祝福丹");

            return(addLuckValue);
        }
Example #3
0
        /// <summary>
        /// 为指定的坐骑增加养成点(临时或者永久)
        /// </summary>
        /// <param name="client"></param>
        /// <param name="horseDbID"></param>
        /// <param name="luckyGoodsID"></param>
        /// <returns></returns>
        public static int ProcessAddHorseAwardLucky(GameClient client, int luckyValue, bool usedTimeLimited, string getType)
        {
            if (0 == luckyValue)
            {
                return(0);
            }

            int horseDbID = client.ClientData.HorseDbID;

            if (horseDbID <= 0)
            {
                return(-300);
            }

            //获取坐骑数据
            HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);

            if (null == horseData)
            {
                return(-1);
            }

            SystemXmlItem horseUpXmlNode = Global.GetHorseUpXmlNode(horseData.HorseID + 1);

            if (null == horseUpXmlNode)
            {
                return(-35);
            }

            int horseBlessPoint = horseUpXmlNode.GetIntValue("BlessPoint");

            //获取坐骑的失败积分
            int jinJieFailedNum = Global.GetHorseFailedNum(horseData);

            //如果已经是最高阶,则不需要再增加幸运点
            if (horseData.HorseID >= Global.MaxHorseID)
            {
                return(-10);
            }

            int addLuckValue = luckyValue;

            addLuckValue = Global.GMin(addLuckValue, horseBlessPoint - jinJieFailedNum);
            addLuckValue = Global.GMax(0, addLuckValue);

            if (!usedTimeLimited)
            {
                //记录失败次数
                Global.AddHorseFailedNum(horseData, addLuckValue);
            }
            else
            {
                Global.AddHorseTempJiFen(horseData, addLuckValue);
            }

            //记录失败次数
            Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID);

            //写入角色进阶坐骑的行为日志
            Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, getType);

            return(addLuckValue);
        }
Example #4
0
        /// <summary>
        /// 坐骑进阶
        /// </summary>
        /// <param name="client"></param>
        /// <param name="horseDbID"></param>
        public static int ProcessHorseUpgrade(GameClient client, int horseDbID, bool allowAutoBuy)
        {
            //获取坐骑数据
            HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);

            if (null == horseData)
            {
                return(-1);
            }

            SystemXmlItem horseUpXmlNode = Global.GetHorseUpXmlNode(horseData.HorseID + 1);

            if (null == horseUpXmlNode)
            {
                return(-35);
            }

            //int needRoleLevel = horseUpXmlNode.GetIntValue("LevelLimit");
            //if (client.ClientData.Level < needRoleLevel)
            //{
            //    return -38;
            //}

            //获取强化需要的道具的物品ID
            int horseUpgradeGoodsID  = 0;
            int horseUpgradeGoodsNum = 0;

            //解析进阶需要的物品ID和数量
            Global.ParseHorseJinJieFu(horseData.HorseID, out horseUpgradeGoodsID, out horseUpgradeGoodsNum, horseUpXmlNode);
            if (horseUpgradeGoodsID <= 0)
            {
                return(-20);
            }

            if (horseData.HorseID >= Global.MaxHorseID)
            {
                return(-30);
            }

            //本次强化需要的银两
            int needYinLiang = Global.GMax(horseUpXmlNode.GetIntValue("UseYinLiang"), 0);

            needYinLiang = Global.RecalcNeedYinLiang(needYinLiang); //判断银两是否折半
            if (client.ClientData.YinLiang < needYinLiang)
            {
                return(-60);
            }

            int needBuyGoodsNum = 0; //需要购买的
            int needSubGoodsNum = 0; //需要扣除的

            //本次强化需要的辅助物品的个数
            int needGoodsNum = Global.GMax(horseUpgradeGoodsNum, 0);

            needSubGoodsNum = needGoodsNum;

            if (Global.GetTotalGoodsCountByID(client, horseUpgradeGoodsID) < needGoodsNum)
            {
                if (allowAutoBuy)
                {
                    needSubGoodsNum = Global.GetTotalGoodsCountByID(client, horseUpgradeGoodsID);
                    needBuyGoodsNum = needGoodsNum - needSubGoodsNum;
                }
                else
                {
                    return(-70);
                }
            }

            bool usedBinding     = false;
            bool usedTimeLimited = false;

            //自动扣除物品
            if (needSubGoodsNum > 0)
            {
                //扣除物品
                if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener,
                                                          Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, horseUpgradeGoodsID, needSubGoodsNum, false, out usedBinding, out usedTimeLimited))
                {
                    return(-70);
                }
            }

            //自动扣除money
            if (needBuyGoodsNum > 0)
            {
                //自动扣除元宝购买
                int ret = Global.SubUserMoneyForGoods(client, horseUpgradeGoodsID, needBuyGoodsNum, "坐骑进阶");

                if (ret <= 0)
                {
                    return(ret);
                }
            }

            //扣除银两
            if (!GameManager.ClientMgr.SubUserYinLiang(Global._TCPManager.MySocketListener,
                                                       Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, needYinLiang, "坐骑进阶"))
            {
                return(-60);
            }

            int    horseOne   = 110000 - horseUpXmlNode.GetIntValue("HorseOne");
            int    horseTwo   = 110000 - horseUpXmlNode.GetIntValue("HorseTwo");
            double horseThree = horseUpXmlNode.GetDoubleValue("HorseThree");
            //int horseBlessPoint = horseUpXmlNode.GetIntValue("BlessPoint");

            //获取坐骑的失败积分
            int jinJieFailedNum = Global.GetHorseFailedNum(horseData);

            //判断如果还没到真概率,则直接返回失败
            if (jinJieFailedNum < horseTwo)
            {
                //if (!usedTimeLimited) //不是限时的道具
                {
                    //记录失败次数
                    //horseData.JinJieFailedNum += 1;
                    Global.AddHorseFailedNum(horseData, 1);
                }
                //else
                //{
                //    Global.AddHorseTempJiFen(horseData, 1);
                //}

                //记录失败次数
                Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID);

                //写入角色进阶坐骑的行为日志
                Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, "失败");

                //改变坐骑的临时ID
                //Global.ChangeTempHorseID(client, horseData.HorseID + 1);

                return(-1000);
            }

            //判断如果还没到必定成功的幸运值,则判断随机数
            if (jinJieFailedNum < (horseOne - 1))
            {
                int successRate = (int)(horseThree * 10000);
                int randNum     = Global.GetRandomNumber(1, 10001);

                if (client.ClientData.TempHorseUpLevelRate != 1) //临时测试加成功率
                {
                    successRate *= client.ClientData.TempHorseUpLevelRate;
                    successRate  = Global.GMin(10000, successRate);
                }

                if (randNum > successRate)
                {
                    //if (!usedTimeLimited) //不是限时的道具
                    {
                        //记录失败次数
                        //horseData.JinJieFailedNum += 1;
                        Global.AddHorseFailedNum(horseData, 1);
                    }
                    //else
                    //{
                    //    Global.AddHorseTempJiFen(horseData, 1);
                    //}

                    //记录失败次数
                    Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID);

                    //写入角色进阶坐骑的行为日志
                    Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, "失败");

                    //改变坐骑的临时ID
                    //Global.ChangeTempHorseID(client, horseData.HorseID + 1);

                    return(-1000);
                }
            }

            //处理坐骑进阶
            return(ProcessHorseUpgradeNow(client, horseDbID, horseData));
        }
Example #5
0
        public static int ProcessAddHorseLucky(GameClient client, int horseDbID, int luckyGoodsID)
        {
            HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);
            int       result;

            if (null == horseData)
            {
                result = -1;
            }
            else
            {
                SystemXmlItem horseUpXmlNode = Global.GetHorseUpXmlNode(horseData.HorseID + 1);
                if (null == horseUpXmlNode)
                {
                    result = -35;
                }
                else
                {
                    int horseOne        = 110000 - horseUpXmlNode.GetIntValue("HorseOne", -1);
                    int horseTwo        = 110000 - horseUpXmlNode.GetIntValue("HorseTwo", -1);
                    int jinJieFailedNum = Global.GetHorseFailedNum(horseData);
                    if (jinJieFailedNum >= horseOne - 1)
                    {
                        result = -100;
                    }
                    else
                    {
                        int[] allHorseLuckyGoodsIDs        = GameManager.systemParamsList.GetParamValueIntArrayByName("AllHorseLuckyGoodsIDs", ',');
                        int[] allHorseLuckyGoodsIDsToLucky = GameManager.systemParamsList.GetParamValueIntArrayByName("AllHorseLuckyGoodsIDsToLucky", ',');
                        if (allHorseLuckyGoodsIDs == null || allHorseLuckyGoodsIDsToLucky == null || allHorseLuckyGoodsIDs.Length != allHorseLuckyGoodsIDsToLucky.Length)
                        {
                            result = -2;
                        }
                        else if (horseData.HorseID >= Global.MaxHorseID)
                        {
                            result = -10;
                        }
                        else if (Global.GetTotalGoodsCountByID(client, luckyGoodsID) <= 0)
                        {
                            result = -20;
                        }
                        else
                        {
                            bool usedBinding     = false;
                            bool usedTimeLimited = false;
                            if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, luckyGoodsID, 1, false, out usedBinding, out usedTimeLimited, false))
                            {
                                result = -30;
                            }
                            else
                            {
                                int addLuckValue = 0;
                                for (int i = 0; i < allHorseLuckyGoodsIDs.Length; i++)
                                {
                                    if (allHorseLuckyGoodsIDs[i] == luckyGoodsID)
                                    {
                                        addLuckValue = allHorseLuckyGoodsIDsToLucky[i];
                                        break;
                                    }
                                }
                                addLuckValue = Global.GMax(0, addLuckValue);
                                Global.AddHorseFailedNum(horseData, addLuckValue);
                                Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID);
                                Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, "祝福丹");
                                result = addLuckValue;
                            }
                        }
                    }
                }
            }
            return(result);
        }
Example #6
0
        public static int ProcessHorseUpgrade(GameClient client, int horseDbID, bool allowAutoBuy)
        {
            HorseData horseData = Global.GetHorseDataByDbID(client, horseDbID);
            int       result;

            if (null == horseData)
            {
                result = -1;
            }
            else
            {
                SystemXmlItem horseUpXmlNode = Global.GetHorseUpXmlNode(horseData.HorseID + 1);
                if (null == horseUpXmlNode)
                {
                    result = -35;
                }
                else
                {
                    int horseUpgradeGoodsID  = 0;
                    int horseUpgradeGoodsNum = 0;
                    Global.ParseHorseJinJieFu(horseData.HorseID, out horseUpgradeGoodsID, out horseUpgradeGoodsNum, horseUpXmlNode);
                    if (horseUpgradeGoodsID <= 0)
                    {
                        result = -20;
                    }
                    else if (horseData.HorseID >= Global.MaxHorseID)
                    {
                        result = -30;
                    }
                    else
                    {
                        int needYinLiang = Global.GMax(horseUpXmlNode.GetIntValue("UseYinLiang", -1), 0);
                        needYinLiang = Global.RecalcNeedYinLiang(needYinLiang);
                        if (client.ClientData.YinLiang < needYinLiang)
                        {
                            result = -60;
                        }
                        else
                        {
                            int needBuyGoodsNum = 0;
                            int needGoodsNum    = Global.GMax(horseUpgradeGoodsNum, 0);
                            int needSubGoodsNum = needGoodsNum;
                            if (Global.GetTotalGoodsCountByID(client, horseUpgradeGoodsID) < needGoodsNum)
                            {
                                if (!allowAutoBuy)
                                {
                                    return(-70);
                                }
                                needSubGoodsNum = Global.GetTotalGoodsCountByID(client, horseUpgradeGoodsID);
                                needBuyGoodsNum = needGoodsNum - needSubGoodsNum;
                            }
                            bool usedBinding     = false;
                            bool usedTimeLimited = false;
                            if (needSubGoodsNum > 0)
                            {
                                if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, horseUpgradeGoodsID, needSubGoodsNum, false, out usedBinding, out usedTimeLimited, false))
                                {
                                    return(-70);
                                }
                            }
                            if (needBuyGoodsNum > 0)
                            {
                                int ret = Global.SubUserMoneyForGoods(client, horseUpgradeGoodsID, needBuyGoodsNum, "坐骑进阶");
                                if (ret <= 0)
                                {
                                    return(ret);
                                }
                            }
                            if (!GameManager.ClientMgr.SubUserYinLiang(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, needYinLiang, "坐骑进阶", false))
                            {
                                result = -60;
                            }
                            else
                            {
                                int    horseOne        = 110000 - horseUpXmlNode.GetIntValue("HorseOne", -1);
                                int    horseTwo        = 110000 - horseUpXmlNode.GetIntValue("HorseTwo", -1);
                                double horseThree      = horseUpXmlNode.GetDoubleValue("HorseThree");
                                int    jinJieFailedNum = Global.GetHorseFailedNum(horseData);
                                if (jinJieFailedNum < horseTwo)
                                {
                                    Global.AddHorseFailedNum(horseData, 1);
                                    Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID);
                                    Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, "失败");
                                    result = -1000;
                                }
                                else
                                {
                                    if (jinJieFailedNum < horseOne - 1)
                                    {
                                        int successRate = (int)(horseThree * 10000.0);
                                        int randNum     = Global.GetRandomNumber(1, 10001);
                                        if (client.ClientData.TempHorseUpLevelRate != 1)
                                        {
                                            successRate *= client.ClientData.TempHorseUpLevelRate;
                                            successRate  = Global.GMin(10000, successRate);
                                        }
                                        if (randNum > successRate)
                                        {
                                            Global.AddHorseFailedNum(horseData, 1);
                                            Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID);
                                            Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, "失败");
                                            return(-1000);
                                        }
                                    }
                                    result = ProcessHorse.ProcessHorseUpgradeNow(client, horseDbID, horseData);
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }