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
        private static int ProcessHorseUpgradeNow(GameClient client, int horseDbID, HorseData horseData)
        {
            if (client.ClientData.HorseDbID > 0 && horseDbID == client.ClientData.HorseDbID)
            {
                Global.UpdateHorseDataProps(client, false);
            }
            int oldHorseID = horseData.HorseID;
            int newHorseID = horseData.HorseID + 1;

            Global.AddHorseTempJiFen(horseData, 0);
            horseData.JinJieFailedDayID = TimeUtil.NowDateTime().DayOfYear;
            horseData.JinJieFailedNum   = 0;
            int ret = 0;

            if (Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, newHorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID) < 0)
            {
                ret = -2000;
            }
            Global.AddRoleHorseUpgradeEvent(client, horseData.DbID, horseData.HorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID, "成功");
            if (client.ClientData.HorseDbID > 0 && horseDbID == client.ClientData.HorseDbID)
            {
                Global.UpdateHorseDataProps(client, true);
                if (0 == ret)
                {
                    GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                    GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7);
                }
                if (0 == ret)
                {
                    client.ClientData.RoleHorseJiFen = Global.CalcHorsePropsJiFen(horseData);
                    List <object> objsList = Global.GetAll9Clients(client);
                    GameManager.ClientMgr.NotifyHorseCmd(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, 0, 1, horseDbID, horseData.HorseID, horseData.BodyID, objsList);
                    Global.BroadcastHorseUpgradeOk(client, oldHorseID, newHorseID);
                }
            }
            return(0);
        }
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>
        private static int ProcessHorseUpgradeNow(GameClient client, int horseDbID, HorseData horseData)
        {
            //处理先前的坐骑
            if (client.ClientData.HorseDbID > 0 && horseDbID == client.ClientData.HorseDbID)
            {
                //减去buffer属性值
                //加载骑乘的属性
                /// 将坐骑的扩展属性加入Buffer中
                Global.UpdateHorseDataProps(client, false);
            }

            int oldHorseID = horseData.HorseID;
            int newHorseID = horseData.HorseID + 1;

            //强制清空临时的积分
            Global.AddHorseTempJiFen(horseData, 0);

            horseData.JinJieFailedDayID = TimeUtil.NowDateTime().DayOfYear;
            horseData.JinJieFailedNum   = 0; //清空失败的积分

            //进行坐骑属性的强化,并存入数据库中
            int ret = 0;

            if (Global.UpdateHorseIDDBCommand(Global._TCPManager.TcpOutPacketPool, client, horseData.DbID, newHorseID, horseData.JinJieFailedNum, Global.GetHorseStrTempTime(horseData), horseData.JinJieTempNum, horseData.JinJieFailedDayID) < 0)
            {
                ret = -2000;
            }

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

            //如果成功,并且坐骑处于骑乘状态
            if (client.ClientData.HorseDbID > 0 && horseDbID == client.ClientData.HorseDbID)
            {
                //减去buffer属性值
                //加载骑乘的属性
                /// 将坐骑的扩展属性加入Buffer中
                Global.UpdateHorseDataProps(client, true);

                if (0 == ret) //如果成功了, 否则没变化,不通知
                {
                    //通知客户端属性变化
                    GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);

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

                //通知用户更新坐骑的形象
                if (0 == ret) //如果成功了, 否则没变化,不通知
                {
                    //计算坐骑的积分值
                    client.ClientData.RoleHorseJiFen = Global.CalcHorsePropsJiFen(horseData);

                    List <Object> objsList = Global.GetAll9Clients(client);

                    //通知骑乘的的指令信息
                    GameManager.ClientMgr.NotifyHorseCmd(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client,
                                                         0, (int)HorseCmds.On, horseDbID, horseData.HorseID, horseData.BodyID, objsList);

                    //坐骑进阶成功
                    Global.BroadcastHorseUpgradeOk(client, oldHorseID, newHorseID);
                }
            }

            return(0);
        }