Ejemplo n.º 1
0
        public bool processCmdEx(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            switch (nID)
            {
            case 2070:
                if (cmdParams == null || cmdParams.Length != 1)
                {
                    return(false);
                }
                try
                {
                    int    RoleID = Convert.ToInt32(cmdParams[0]);
                    string ToClientRegtime;
                    int    ToClientID;
                    int    ToClientLevel;
                    int    CurrDay;
                    int    ActiveMoney;
                    int    result = Convert.ToInt32(this.ProcessGetRegressAcitveFile(client, out ToClientRegtime, out ToClientID, out ToClientLevel, out CurrDay, out ActiveMoney));
                    client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}:{4}:{5}", new object[]
                    {
                        result,
                        ToClientRegtime,
                        ToClientID,
                        ToClientLevel,
                        CurrDay,
                        ActiveMoney
                    }), false);
                }
                catch (Exception ex)
                {
                    client.sendCmd(nID, "-1", false);
                    DataHelper.WriteFormatExceptionLog(ex, "CMD_SPR_REGRESSACTIVE_GETFILE", false, false);
                }
                break;

            case 2071:
                if (cmdParams == null || cmdParams.Length != 1)
                {
                    return(false);
                }
                try
                {
                    int RoleID = Convert.ToInt32(cmdParams[0]);
                    Dictionary <int, int> SignInfo;
                    int result = Convert.ToInt32(this.ProcessRegressSignInfo(client, out SignInfo));
                    client.sendCmd <Dictionary <int, int> >(nID, SignInfo, false);
                }
                catch (Exception ex)
                {
                    client.sendCmd(nID, "-1", false);
                    DataHelper.WriteFormatExceptionLog(ex, "CMD_SPR_REGRESSACTIVE_GETSIGNINFO", false, false);
                }
                break;

            case 2072:
                if (cmdParams == null || cmdParams.Length != 2)
                {
                    return(false);
                }
                try
                {
                    int Level  = Convert.ToInt32(cmdParams[0]);
                    int Day    = Convert.ToInt32(cmdParams[1]);
                    int result = Convert.ToInt32(this.ProcessRegressAcitveDaySignAward(client, Level, Day));
                    client.sendCmd(nID, string.Format("{0}", result), false);
                }
                catch (Exception ex)
                {
                    client.sendCmd(nID, "-1", false);
                    DataHelper.WriteFormatExceptionLog(ex, "CMD_SPR_REGRESSACTIVE_SING", false, false);
                }
                break;

            case 2073:
                if (cmdParams == null || cmdParams.Length != 1)
                {
                    return(false);
                }
                try
                {
                    int RoleID = Convert.ToInt32(cmdParams[0]);
                    Dictionary <int, int> GoodInfo;
                    int result = Convert.ToInt32(this.ProcessRegressAcitveGetStoreInfo(client, out GoodInfo));
                    client.sendCmd <Dictionary <int, int> >(nID, GoodInfo, false);
                }
                catch (Exception ex)
                {
                    client.sendCmd(nID, "-1", false);
                    DataHelper.WriteFormatExceptionLog(ex, "CMD_SPR_REGRESSACTIVE_GETSTOREINFO", false, false);
                }
                break;

            case 2074:
                if (cmdParams == null || cmdParams.Length != 4)
                {
                    return(false);
                }
                try
                {
                    int StoreConfID = Convert.ToInt32(cmdParams[0]);
                    int Level       = Convert.ToInt32(cmdParams[1]);
                    int GoodsID     = Convert.ToInt32(cmdParams[2]);
                    int Count       = Convert.ToInt32(cmdParams[3]);
                    int result      = Convert.ToInt32(this.ProcessRegressAcitveStore(client, StoreConfID, Level, GoodsID, Count));
                    client.sendCmd(nID, string.Format("{0}", result), false);
                }
                catch (Exception ex)
                {
                    client.sendCmd(nID, "-1", false);
                    DataHelper.WriteFormatExceptionLog(ex, "CMD_SPR_REGRESSACTIVE_STOREBUY", false, false);
                }
                break;

            case 2075:
                if (cmdParams == null || cmdParams.Length != 1)
                {
                    return(false);
                }
                try
                {
                    int    RoleID = Convert.ToInt32(cmdParams[0]);
                    int    Money;
                    string ConfIDList;
                    int    result = Convert.ToInt32(this.ProcessRegressAcitveRechargeInfo(client, RoleID, out Money, out ConfIDList));
                    client.sendCmd(nID, string.Format("{0}:{1}:{2}", result, Money, ConfIDList), false);
                }
                catch (Exception ex)
                {
                    client.sendCmd(nID, "-1", false);
                    DataHelper.WriteFormatExceptionLog(ex, "CMD_SPR_REGRESSACTIVE_INPUTINFO", false, false);
                }
                break;

            case 2076:
                if (cmdParams == null || cmdParams.Length != 2)
                {
                    return(false);
                }
                try
                {
                    int Level          = Convert.ToInt32(cmdParams[0]);
                    int RechargeConfID = Convert.ToInt32(cmdParams[1]);
                    int result         = Convert.ToInt32(this.ProcessRegressAcitveRecharge(client, Level, RechargeConfID));
                    client.sendCmd(nID, string.Format("{0}", result), false);
                }
                catch (Exception ex)
                {
                    client.sendCmd(nID, "-1", false);
                    DataHelper.WriteFormatExceptionLog(ex, "CMD_SPR_REGRESSACTIVE_INPUT", false, false);
                }
                break;

            case 2077:
                if (cmdParams == null || cmdParams.Length != 2)
                {
                    return(false);
                }
                try
                {
                    int RoleID = Convert.ToInt32(cmdParams[0]);
                    int Level  = Convert.ToInt32(cmdParams[1]);
                    Dictionary <int, int> ZhiGouDict;
                    int result = Convert.ToInt32(this.ProcessRegressAcitveDayBuy(client, RoleID, Level, out ZhiGouDict));
                    client.sendCmd <Dictionary <int, int> >(nID, ZhiGouDict, false);
                }
                catch (Exception ex)
                {
                    client.sendCmd(nID, "-1", false);
                    DataHelper.WriteFormatExceptionLog(ex, "CMD_SPR_REGRESSACTIVE_ZHIGOU_QUERY", false, false);
                }
                break;
            }
            return(true);
        }
Ejemplo n.º 2
0
 public bool ProcessAlchemyAddElementCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         int  result   = 0;
         int  roleID   = Convert.ToInt32(cmdParams[0]);
         int  costType = Convert.ToInt32(cmdParams[1]);
         int  useNum   = Convert.ToInt32(cmdParams[2]);
         bool bindOnly = true;
         if (cmdParams.Length >= 4)
         {
             bindOnly = (Convert.ToInt32(cmdParams[3]) > 0);
         }
         Dictionary <int, AlchemyConfigData> tempAlchemyConfig = null;
         lock (this.ConfigMutex)
         {
             tempAlchemyConfig = this.AlchemyConfig;
         }
         AlchemyConfigData alchemyConfig = null;
         if (!tempAlchemyConfig.TryGetValue(costType, out alchemyConfig))
         {
             result = -3;
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
             {
                 result,
                 roleID,
                 0,
                 costType,
                 0
             }), false);
             return(true);
         }
         if (!this.CheckCostEnough(client, costType, useNum, bindOnly) || useNum < alchemyConfig.Unit)
         {
             if (costType < this.MinGoodsID)
             {
                 result = -12;
             }
             else
             {
                 result = -6;
             }
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
             {
                 result,
                 roleID,
                 0,
                 costType,
                 0
             }), false);
             return(true);
         }
         int todayCost = this.GetTodayAddElementCost(client, costType);
         if (alchemyConfig.Limit != -1 && todayCost + useNum > alchemyConfig.Limit)
         {
             result = -36;
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
             {
                 result,
                 roleID,
                 0,
                 costType,
                 todayCost
             }), false);
             return(true);
         }
         useNum -= useNum % alchemyConfig.Unit;
         if (!this.ModifyAddElementCost(client, costType, -useNum, bindOnly))
         {
             result = -12;
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
             {
                 result,
                 roleID,
                 0,
                 costType,
                 todayCost
             }), false);
             return(true);
         }
         GameManager.ClientMgr.ModifyAlchemyElementValue(client, useNum / alchemyConfig.Unit * alchemyConfig.Element, "灌注", false, false);
         this.UpdateTodayAddElementCost(client, costType, useNum);
         this.UpdateHistAddElementCost(client, costType, useNum);
         this.UpdateAlchemyDataDB(client);
         todayCost = this.GetTodayAddElementCost(client, costType);
         client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
         {
             result,
             roleID,
             client.ClientData.AlchemyInfo.BaseData.Element,
             costType,
             todayCost
         }), false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Ejemplo n.º 3
0
 public bool ProcessShenJiAddEffectCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         int result   = 0;
         int roleID   = Convert.ToInt32(cmdParams[0]);
         int shenjiID = Convert.ToInt32(cmdParams[1]);
         Dictionary <int, ShenJiFuWenConfigData> tempShenJiConfig = null;
         lock (this.ConfigMutex)
         {
             tempShenJiConfig = this.ShenJiConfig;
         }
         ShenJiFuWenConfigData sConfigData = null;
         if (!tempShenJiConfig.TryGetValue(shenjiID, out sConfigData))
         {
             result = 1;
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
             {
                 result,
                 roleID,
                 shenjiID,
                 0
             }), false);
             return(true);
         }
         ShenJiFuWenData actData = this.GetShenJiFuWenData(client, shenjiID);
         if (actData != null && actData.Level >= sConfigData.MaxLevel)
         {
             result = 2;
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
             {
                 result,
                 roleID,
                 shenjiID,
                 0
             }), false);
             return(true);
         }
         if (sConfigData.UpNeed > GameManager.ClientMgr.GetShenJiPointValue(client))
         {
             result = 2;
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
             {
                 result,
                 roleID,
                 shenjiID,
                 0
             }), false);
             return(true);
         }
         ShenJiFuWenConfigData preConfigData = null;
         if (tempShenJiConfig.TryGetValue(sConfigData.PreShenJiID, out preConfigData))
         {
             ShenJiFuWenData preData = this.GetShenJiFuWenData(client, sConfigData.PreShenJiID);
             if (preData == null || sConfigData.PreShenJiLev > preData.Level)
             {
                 result = 2;
                 client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
                 {
                     result,
                     roleID,
                     shenjiID,
                     0
                 }), false);
                 return(true);
             }
         }
         if (null == actData)
         {
             actData = new ShenJiFuWenData
             {
                 ShenJiID = shenjiID
             };
             client.ClientData.ShenJiDataDict[shenjiID] = actData;
         }
         GameManager.ClientMgr.ModifyShenJiPointValue(client, -sConfigData.UpNeed, "精灵神迹升级|激活", true, true);
         actData.Level++;
         this.UpdateShenJiFuWenDataDB(client, shenjiID, actData.Level);
         this.RefreshShenJiFuWenProps(client);
         client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
         {
             result,
             roleID,
             shenjiID,
             actData.Level
         }), false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 给奖励
        /// </summary>
        public void GiveAwards(HuanYingSiYuanScene huanYingSiYuanScene)
        {
            try
            {
                List <GameClient> objsList = huanYingSiYuanScene.CopyMap.GetClientsList();
                if (objsList != null && objsList.Count > 0)
                {
                    int nowDayId = Global.GetOffsetDayNow();
                    for (int n = 0; n < objsList.Count; ++n)
                    {
                        GameClient client = objsList[n];
                        if (client != null && client == GameManager.ClientMgr.FindClient(client.ClientData.RoleID)) //确认角色仍然在线
                        {
                            bool   success    = false;
                            double nMultiple  = 0.5;
                            int    awardsRate = 1;
                            int    count      = 0;

                            HuanYingSiYuanLianShaContextData clientLianShaContextData = client.SceneContextData2 as HuanYingSiYuanLianShaContextData;
                            if (null != clientLianShaContextData && clientLianShaContextData.TotalScore >= RuntimeData.TempleMirageMinJiFen)
                            {
                                if (client.ClientData.BattleWhichSide == huanYingSiYuanScene.SuccessSide)
                                {
                                    success   = true;
                                    nMultiple = 1;

                                    //每日前3次享受10倍奖励
                                    int dayid = Global.GetRoleParamsInt32FromDB(client, RoleParamName.HysySuccessDayId);
                                    if (dayid == nowDayId)
                                    {
                                        count = Global.GetRoleParamsInt32FromDB(client, RoleParamName.HysySuccessCount);
                                        if (count < RuntimeData.TempleMirageWinExtraNum)
                                        {
                                            awardsRate = RuntimeData.TempleMirageWinExtraRate;
                                        }
                                    }
                                    else
                                    {
                                        awardsRate = RuntimeData.TempleMirageWinExtraRate;
                                    }
                                }
                            }
                            else
                            {
                                //达不到最低分数,无奖励,不计次
                                nMultiple  = 0;
                                awardsRate = 0;
                            }

                            // 公式
                            long nExp           = (long)(RuntimeData.TempleMirageEXPAward * nMultiple * client.ClientData.ChangeLifeCount);
                            int  chengJiuaward  = (int)(RuntimeData.TempleMirageAwardChengJiu * nMultiple);
                            int  shengWangaward = (int)(RuntimeData.TempleMirageAwardShengWang * nMultiple);

                            if (nExp > 0)
                            {
                                GameManager.ClientMgr.ProcessRoleExperience(client, nExp * awardsRate, false);
                                //GameManager.ClientMgr.NotifyAddExpMsg(client, nExp); //客户端自己提示,有显示"X10"的需求
                            }

                            if (chengJiuaward > 0)
                            {
                                ChengJiuManager.AddChengJiuPoints(client, "幻影寺院获得成就", chengJiuaward * awardsRate, true, true);
                            }

                            if (shengWangaward > 0)
                            {
                                GameManager.ClientMgr.ModifyShengWangValue(client, shengWangaward * awardsRate, "幻影寺院获得声望");
                            }

                            HuanYingSiYuanAwardsData awardsData = new HuanYingSiYuanAwardsData()
                            {
                                SuccessSide   = huanYingSiYuanScene.SuccessSide,
                                Exp           = nExp,
                                ShengWang     = shengWangaward,
                                ChengJiuAward = chengJiuaward,
                                AwardsRate    = awardsRate,
                            };

                            if (success)
                            {
                                if (nMultiple > 0)
                                {
                                    Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.HysySuccessDayId, nowDayId, true);
                                    Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.HysySuccessCount, count + 1, true);

                                    GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 1, 0, (int)GameTypes.HuanYingSiYuan);
                                    if (huanYingSiYuanScene.ScoreInfoData.Score1 >= 1000 || huanYingSiYuanScene.ScoreInfoData.Score2 >= 1000)
                                    {
                                        //FaildCount记录为获得够1000分而获胜的人次
                                        GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 0, 1, (int)GameTypes.HuanYingSiYuan);
                                    }
                                }
                            }
                            else
                            {
                                //FaildCount记录为失败人次
                                //GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 0, 1);
                            }

                            client.sendCmd((int)TCPGameServerCmds.CMD_SPR_HYSY_AWARD, awardsData);
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                DataHelper.WriteExceptionLogEx(ex, "幻影寺院清场调度异常");
            }
        }
Ejemplo n.º 5
0
        public bool ProcessMoHuaCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                if (!this.JueXingRunTimeData.MoHuaOpen)
                {
                    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);
                    return(true);
                }
                if (!CheckHelper.CheckCmdLengthAndRole(client, nID, cmdParams, 1))
                {
                    return(false);
                }
                int result     = 0;
                int nextLev    = Global.GetRoleParamsInt32FromDB(client, "10193");
                int jueXingJie = client.ClientData.JueXingData.JueXingJie;
                int jueXingJi  = client.ClientData.JueXingData.JueXingJi;
                nextLev++;
                AwakenLevelItem nextAwakenLevel;
                if (!this.JueXingRunTimeData.AwakenLevelDict.TryGetValue(nextLev, out nextAwakenLevel))
                {
                    result = -8;
                }
                else if (client.ClientData.JueXingZhiChen < (long)nextAwakenLevel.Awakenment)
                {
                    result = -9;
                }
                else
                {
                    string[] needGoods = nextAwakenLevel.AwakenAdvancedment.Split(new char[]
                    {
                        ','
                    });
                    if (needGoods.Length > 1)
                    {
                        int  needGoodID = Convert.ToInt32(needGoods[0]);
                        int  needNum    = Convert.ToInt32(needGoods[1]);
                        bool usedBinding;
                        bool usedTimeLimited;
                        if (Global.UseGoodsBindOrNot(client, needGoodID, needNum, true, out usedBinding, out usedTimeLimited) < 1)
                        {
                            result = -3;
                            goto IL_1BB;
                        }
                    }
                    GameManager.ClientMgr.ModifyJueXingZhiChenValue(client, -nextAwakenLevel.Awakenment, "觉醒魔化消耗", true, true, false);
                    Global.SaveRoleParamsInt32ValueToDB(client, "10193", nextLev, true);
                    client.ClientData.JueXingData.JueXingJie = nextAwakenLevel.Order;
                    client.ClientData.JueXingData.JueXingJi  = nextAwakenLevel.Star;
                    this.UpdataPalyerJueXingAttr(client, true);
                }
IL_1BB:
                client.sendCmd(nID, string.Format("{0}:{1}:{2}", result, client.ClientData.JueXingData.JueXingJie, client.ClientData.JueXingData.JueXingJi), false);
                return(true);
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("JueXing :: 觉醒魔化错误。rid:{0}, ex:{1}", client.ClientData.RoleID, ex.Message), null, true);
            }
            return(false);
        }
Ejemplo n.º 6
0
        private void TimerProc(object sender, EventArgs e)
        {
            bool     notifyPrepareGame = false;
            bool     notifyEnterGame   = false;
            DateTime now = TimeUtil.NowDateTime();

            lock (RuntimeData.Mutex)
            {
                bool bInActiveTime = false;

                YongZheZhanChangSceneInfo sceneItem = RuntimeData.SceneDataDict.Values.FirstOrDefault();
                for (int i = 0; i < sceneItem.TimePoints.Count - 1; i += 2)
                {
                    if ((int)now.DayOfWeek == sceneItem.TimePoints[i].Days &&
                        now.TimeOfDay.TotalSeconds >= sceneItem.SecondsOfDay[i] - sceneItem.SignUpStartSecs &&
                        now.TimeOfDay.TotalSeconds <= sceneItem.SecondsOfDay[i + 1])
                    {
                        double secs = sceneItem.SecondsOfDay[i] - now.TimeOfDay.TotalSeconds;
                        bInActiveTime = true;

                        if (!RuntimeData.PrepareGame)
                        {
                            if (secs > 0 && secs < sceneItem.SignUpEndSecs / 2)
                            {
                                LogManager.WriteLog(LogTypes.Error, "报名截止5分钟时间过半,通知跨服中心开始分配所有报名玩家的活动场次");

                                // 通知跨服中心开始准备副本
                                RuntimeData.PrepareGame = true;
                                notifyPrepareGame       = true;
                                break;
                            }
                        }
                        else
                        {
                            if (secs < 0)
                            {
                                LogManager.WriteLog(LogTypes.Error, "报名截止状态结束,可以通知已分配到场次的玩家进入游戏了");

                                // 首次到达进入时间,通知进入,并重置PrepareGame状态,然后以后的循环走上面的if
                                // 但是上面的if在本次活动期间就相当于空转
                                notifyEnterGame         = true;
                                RuntimeData.PrepareGame = false;
                                break;
                            }
                        }
                    }
                }

                if (!bInActiveTime)
                {
                    if (RuntimeData.RoleIdKuaFuLoginDataDict.Count > 0)
                    {
                        RuntimeData.RoleIdKuaFuLoginDataDict.Clear();
                    }

                    if (RuntimeData.RoleId2JoinGroup.Count > 0)
                    {
                        RuntimeData.RoleId2JoinGroup.Clear();
                    }
                }
            }

            if (notifyPrepareGame)
            {
                LogManager.WriteLog(LogTypes.Error, "通知跨服中心开始分配所有报名玩家的活动场次");

                // GameServer和KF-GameServer都会通知准备游戏,所以中心要防止状态回滚
                string cmd = string.Format("{0} {1} {2}", GameStates.CommandName, GameStates.PrepareGame, (int)GameTypes.YongZheZhanChang);
                YongZheZhanChangClient.getInstance().ExecuteCommand(cmd);
            }

            if (notifyEnterGame)
            {
                lock (RuntimeData.Mutex)
                {
                    foreach (var kuaFuServerLoginData in RuntimeData.RoleIdKuaFuLoginDataDict.Values)
                    {
                        RuntimeData.NotifyRoleEnterDict.Add(kuaFuServerLoginData.RoleId, kuaFuServerLoginData);
                    }
                }
            }

            //通知报名的玩家进入活动,每次只通知一部分(按RoleID除以15的余数),防止所有玩家一起进入给服务器造成压力.
            List <KuaFuServerLoginData> list = null;

            lock (RuntimeData.Mutex)
            {
                int count = RuntimeData.NotifyRoleEnterDict.Count;
                if (count > 0)
                {
                    list = new List <KuaFuServerLoginData>();
                    KuaFuServerLoginData kuaFuServerLoginData = RuntimeData.NotifyRoleEnterDict.First().Value;
                    foreach (var kv in RuntimeData.NotifyRoleEnterDict)
                    {
                        if ((kv.Key % 15) == (kuaFuServerLoginData.RoleId % 15))
                        {
                            list.Add(kv.Value);
                        }
                    }

                    foreach (var data in list)
                    {
                        RuntimeData.NotifyRoleEnterDict.Remove(data.RoleId);
                    }
                }
            }

            if (null != list)
            {
                foreach (var kuaFuServerLoginData in list)
                {
                    GameClient client = GameManager.ClientMgr.FindClient(kuaFuServerLoginData.RoleId);
                    if (null != client)
                    {
                        client.sendCmd((int)TCPGameServerCmds.CMD_SPR_YONGZHEZHANCHANG_ENTER, 1);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public bool ProcessGetYongZheZhanChangStateCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                // 根据策划需求,任何时候来查询状态,领奖状态具有最高优先级
                string awardsInfo = Global.GetRoleParamByName(client, RoleParamName.YongZheZhanChangAwards);
                if (!string.IsNullOrEmpty(awardsInfo))
                {
                    int lastGroupId = 0;
                    int score       = 0;
                    int success     = 0;
                    ConfigParser.ParseStrInt3(awardsInfo, ref lastGroupId, ref success, ref score);
                    if (lastGroupId > 0)
                    {
                        YongZheZhanChangSceneInfo lastSceneItem = null;
                        if (RuntimeData.SceneDataDict.TryGetValue(lastGroupId, out lastSceneItem))
                        {
                            // 通知有奖励可以领取
                            client.sendCmd(nID, (int)YongZheZhanChangGameStates.Awards);
                            return(true);
                        }
                    }
                }

                YongZheZhanChangSceneInfo  sceneItem = null;
                YongZheZhanChangGameStates timeState = YongZheZhanChangGameStates.None;
                int result  = (int)YongZheZhanChangGameStates.None;
                int groupId = 0;
                RuntimeData.RoleId2JoinGroup.TryGetValue(client.ClientData.RoleID, out groupId);

                CheckCondition(client, ref sceneItem, ref timeState);
                if (groupId > 0)
                {
                    if (timeState >= YongZheZhanChangGameStates.SignUp && timeState <= YongZheZhanChangGameStates.Wait)
                    {
                        int state = YongZheZhanChangClient.getInstance().GetKuaFuRoleState(client.ClientData.RoleID);
                        if (state >= (int)KuaFuRoleStates.SignUp)
                        {
                            result = (int)YongZheZhanChangGameStates.Wait;
                        }
                        else
                        {
                            result = (int)KuaFuBossGameStates.NotJoin;
                        }
                    }
                    else if (timeState == YongZheZhanChangGameStates.Start)
                    {
                        if (RuntimeData.RoleIdKuaFuLoginDataDict.ContainsKey(client.ClientData.RoleID))
                        {
                            result = (int)YongZheZhanChangGameStates.Start;
                        }
                    }
                }
                else
                {
                    if (timeState == YongZheZhanChangGameStates.SignUp)
                    {
                        result = (int)YongZheZhanChangGameStates.SignUp;
                    }
                    else if (timeState == YongZheZhanChangGameStates.Wait || timeState == YongZheZhanChangGameStates.Start)
                    {
                        // 未参加本次活动
                        result = (int)YongZheZhanChangGameStates.NotJoin;
                    }
                }

                client.sendCmd(nID, result);
                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
            }

            return(false);
        }
Ejemplo n.º 8
0
 public static void ProcessMonsterDead(GameClient client, Monster monster)
 {
     if (null != client)
     {
         if (null != monster)
         {
             int targetIdx = CopyTargetManager.GetMonsterIdx(monster.MonsterInfo.ExtensionID, client.ClientData.FuBenID);
             if (targetIdx > 0)
             {
                 List <object> findMonsters = GameManager.MonsterMgr.FindMonsterByExtensionID(monster.CurrentCopyMapID, monster.MonsterInfo.ExtensionID);
                 string        strCmd       = string.Format("{0}:{1}:{2}:{3}", new object[]
                 {
                     client.ClientData.FuBenID,
                     targetIdx,
                     monster.MonsterInfo.ExtensionID,
                     findMonsters.Count
                 });
                 TCPOutPacket tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(Global._TCPManager.TcpOutPacketPool, strCmd, 877);
                 if (MapTypes.MarriageCopy == Global.GetMapType(client.ClientData.MapCode))
                 {
                     if (client.ClientData.MyMarriageData.byMarrytype > 0 && client.ClientData.MyMarriageData.nSpouseID > 0)
                     {
                         GameClient spouseClient = GameManager.ClientMgr.FindClient(client.ClientData.MyMarriageData.nSpouseID);
                         if (spouseClient != null && MapTypes.MarriageCopy == Global.GetMapType(spouseClient.ClientData.MapCode))
                         {
                             spouseClient.sendCmd(877, strCmd, false);
                         }
                     }
                     client.sendCmd(877, strCmd, false);
                 }
                 else
                 {
                     TeamData td = null;
                     if (client.ClientData.TeamID > 0)
                     {
                         td = GameManager.TeamMgr.FindData(client.ClientData.TeamID);
                     }
                     if (null == td)
                     {
                         Global._TCPManager.MySocketListener.SendData(client.ClientSocket, tcpOutPacket, true);
                     }
                     else
                     {
                         lock (td)
                         {
                             for (int i = 0; i < td.TeamRoles.Count; i++)
                             {
                                 GameClient gc = GameManager.ClientMgr.FindClient(td.TeamRoles[i].RoleID);
                                 if (null != gc)
                                 {
                                     if (gc.ClientData.MapCode == client.ClientData.MapCode)
                                     {
                                         if (gc.ClientData.CopyMapID == client.ClientData.CopyMapID)
                                         {
                                             Global._TCPManager.MySocketListener.SendData(gc.ClientSocket, tcpOutPacket, true);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 9
0
        private bool ProcessArmorStarUpCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            int result = 0;
            ArmorUpdateResultData resultData = new ArmorUpdateResultData();
            RoleArmorData         ArmorData  = client.ClientData.ArmorData;
            int exp = 0;
            ArmorUpdateResultData requestData = DataHelper.BytesToObject <ArmorUpdateResultData>(bytes, 0, bytes.Length);
            int  type     = requestData.Type;
            int  zuanshi  = requestData.ZuanShi;
            int  auto     = requestData.Auto;
            long nowTicks = TimeUtil.NOW();

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

            if (!MarryLogic.IsVersionSystemOpenOfMarriage())
            {
                result = MarryResult.NotOpen;
            }
            else if (client.ClientData.MyMarriageData.byMarrytype > 0)
            {
                result = MarryResult.SelfMarried;
            }
            else
            {
                GameClient sourceClient = GameManager.ClientMgr.FindClient(sourceID);
                if (sourceClient == null)
                {
                    result = MarryResult.ApplyTimeout;
                }
                else if (sourceClient.ClientData.MyMarriageData.byMarrytype > 0)
                {
                    result = MarryResult.TargetMarried;
                }
                else if (!MarryLogic.RemoveMarryApply(sourceID, MarryApplyType.ApplyInit))
                {
                    result = MarryResult.ApplyTimeout;
                }
                else
                {
                    if (!client.ClientData.IsMainOccupation || !sourceClient.ClientData.IsMainOccupation)
                    {
                        accept = 0;
                    }
                    if (accept == 0 || client.ClientData.MyMarriageData.byAutoReject == 1)
                    {
                        string notifyData = string.Format("{0}:{1}:{2}", 1, client.ClientData.RoleID, client.ClientData.RoleName);
                        sourceClient.sendCmd(894, notifyData, false);
                        GameManager.ClientMgr.AddUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, sourceClient, MarryLogic.MarryCost, "求婚被拒绝返还钻石", ActivityTypes.None, "");
                    }
                    else
                    {
                        MarryLogic.RemoveMarryApply(sourceID, MarryApplyType.ApplyNull);
                        MarryLogic.ApplyLogoutClear(client);
                        MarryLogic.RemoveMarryApply(client.ClientData.RoleID, MarryApplyType.ApplyNull);
                        int initRingID = 0;
                        if (null != MarriageOtherLogic.getInstance().WeddingRingDic.SystemXmlItemDict)
                        {
                            initRingID = MarriageOtherLogic.getInstance().WeddingRingDic.SystemXmlItemDict.Keys.First <int>();
                        }
                        if (sourceClient.ClientData.MyMarriageData.nRingID <= 0)
                        {
                            sourceClient.ClientData.MyMarriageData.nRingID = initRingID;
                        }
                        if (client.ClientData.MyMarriageData.nRingID <= 0)
                        {
                            client.ClientData.MyMarriageData.nRingID = initRingID;
                        }
                        sbyte sourceType = (sbyte)(sourceClient.ClientData.RoleSex != 1 || client.ClientData.RoleSex == sourceClient.ClientData.RoleSex ? 1 : 2);
                        sourceClient.ClientData.MyMarriageData.byMarrytype = sourceType;
                        client.ClientData.MyMarriageData.byMarrytype       = (sbyte)(sourceType == 1 ? 2 : 1);
                        sourceClient.ClientData.MyMarriageData.nSpouseID   = client.ClientData.RoleID;
                        client.ClientData.MyMarriageData.nSpouseID         = sourceID;
                        if (sourceClient.ClientData.MyMarriageData.byGoodwilllevel == 0)
                        {
                            sourceClient.ClientData.MyMarriageData.ChangTime       = TimeUtil.NowDateTime().ToString("yyyy-MM-dd HH:mm:ss");
                            sourceClient.ClientData.MyMarriageData.byGoodwilllevel = 1;
                        }
                        if (client.ClientData.MyMarriageData.byGoodwilllevel == 0)
                        {
                            client.ClientData.MyMarriageData.ChangTime       = TimeUtil.NowDateTime().ToString("yyyy-MM-dd HH:mm:ss");
                            client.ClientData.MyMarriageData.byGoodwilllevel = 1;
                        }
                        EventLogManager.AddRingBuyEvent(sourceClient, 0, initRingID, 0, 0, 0, 1, "");
                        EventLogManager.AddRingBuyEvent(client, 0, initRingID, 0, 0, 0, 1, "");
                        MarryFuBenMgr.UpdateMarriageData2DB(sourceClient);
                        MarryFuBenMgr.UpdateMarriageData2DB(client);
                        MarriageOtherLogic.getInstance().SendMarriageDataToClient(sourceClient, true);
                        MarriageOtherLogic.getInstance().SendMarriageDataToClient(client, true);
                        MarriageOtherLogic.getInstance().UpdateRingAttr(sourceClient, true, false);
                        if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriMarriage))
                        {
                            client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived());
                            client._IconStateMgr.SendIconStateToClient(client);
                        }
                        if (sourceClient._IconStateMgr.CheckJieRiFanLi(sourceClient, ActivityTypes.JieriMarriage))
                        {
                            sourceClient._IconStateMgr.AddFlushIconState(14000, sourceClient._IconStateMgr.IsAnyJieRiTipActived());
                            sourceClient._IconStateMgr.SendIconStateToClient(sourceClient);
                        }
                        FriendData friendData = Global.FindFriendData(client, sourceID);
                        if (friendData != null && friendData.FriendType != 0)
                        {
                            GameManager.ClientMgr.RemoveFriend(Global._TCPManager, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, friendData.DbID);
                            friendData = null;
                        }
                        if (friendData == null)
                        {
                            GameManager.ClientMgr.AddFriend(Global._TCPManager, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, -1, sourceID, Global.FormatRoleName(sourceClient, sourceClient.ClientData.RoleName), 0);
                        }
                        friendData = Global.FindFriendData(sourceClient, client.ClientData.RoleID);
                        if (friendData != null && friendData.FriendType != 0)
                        {
                            GameManager.ClientMgr.RemoveFriend(Global._TCPManager, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, sourceClient, friendData.DbID);
                            friendData = null;
                        }
                        if (friendData == null)
                        {
                            GameManager.ClientMgr.AddFriend(Global._TCPManager, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, sourceClient, -1, client.ClientData.RoleID, Global.FormatRoleName(client, client.ClientData.RoleName), 0);
                        }
                        string broadCastMsg = string.Format(GLang.GetLang(485, new object[0]), sourceClient.ClientData.RoleName, client.ClientData.RoleName);
                        Global.BroadcastRoleActionMsg(client, RoleActionsMsgTypes.Bulletin, broadCastMsg, true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.OnlySysHint, 0, 0, 100, 100);
                        SingletonTemplate <CoupleArenaManager> .Instance().OnMarry(sourceClient, client);
                    }
                    result = MarryResult.Success;
                }
            }
            return(result);
        }
Ejemplo n.º 11
0
        public static MarryResult MarryDivorce(GameClient client, MarryDivorceType divorceType)
        {
            MarryResult result;

            if (!MarryLogic.IsVersionSystemOpenOfMarriage())
            {
                result = MarryResult.NotOpen;
            }
            else if (0 >= client.ClientData.MyMarriageData.byMarrytype)
            {
                result = MarryResult.NotMarried;
            }
            else if (!SingletonTemplate <CoupleArenaManager> .Instance().IsNowCanDivorce(TimeUtil.NowDateTime()))
            {
                result = MarryResult.DeniedByCoupleAreanTime;
            }
            else
            {
                int        spouseID     = client.ClientData.MyMarriageData.nSpouseID;
                GameClient spouseClient = GameManager.ClientMgr.FindClient(spouseID);
                if (divorceType == MarryDivorceType.DivorceForce || divorceType == MarryDivorceType.DivorceFree || divorceType == MarryDivorceType.DivorceFreeAccept)
                {
                    if (client.ClientData.ExchangeID > 0 || client.ClientSocket.IsKuaFuLogin || client.ClientData.CopyMapID > 0)
                    {
                        return(MarryResult.SelfBusy);
                    }
                    if (-1 != client.ClientData.FuBenID && MapTypes.MarriageCopy == Global.GetMapType(client.ClientData.MapCode))
                    {
                        return(MarryResult.SelfBusy);
                    }
                    if (null != spouseClient)
                    {
                        if (-1 != spouseClient.ClientData.FuBenID && MapTypes.MarriageCopy == Global.GetMapType(spouseClient.ClientData.MapCode))
                        {
                            return(MarryResult.TargetBusy);
                        }
                    }
                    if (divorceType == MarryDivorceType.DivorceForce || divorceType == MarryDivorceType.DivorceFree)
                    {
                        if (MarryLogic.ApplyExist(client.ClientData.RoleID))
                        {
                            return(MarryResult.SelfBusy);
                        }
                    }
                }
                int _man  = client.ClientData.RoleID;
                int _wife = spouseID;
                if (client.ClientData.MyMarriageData.byMarrytype == 2)
                {
                    DataHelper2.Swap <int>(ref _man, ref _wife);
                }
                if (divorceType == MarryDivorceType.DivorceForce)
                {
                    if (client.ClientData.UserMoney < MarryLogic.DivorceForceCost)
                    {
                        return(MarryResult.MoneyNotEnough);
                    }
                    if (!SingletonTemplate <CoupleWishManager> .Instance().PreClearDivorceData(_man, _wife))
                    {
                        return(MarryResult.NotOpen);
                    }
                    if (!SingletonTemplate <CoupleArenaManager> .Instance().PreClearDivorceData(_man, _wife))
                    {
                        return(MarryResult.NotOpen);
                    }
                    if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, MarryLogic.DivorceForceCost, "强制离婚", false, true, false, DaiBiSySType.None))
                    {
                    }
                    client.ClientData.MyMarriageData.byMarrytype = -1;
                    client.ClientData.MyMarriageData.nSpouseID   = -1;
                    MarryFuBenMgr.UpdateMarriageData2DB(client);
                    MarriageOtherLogic.getInstance().ResetRingAttr(client);
                    if (null != spouseClient)
                    {
                        spouseClient.ClientData.MyMarriageData.nSpouseID   = -1;
                        spouseClient.ClientData.MyMarriageData.byMarrytype = -1;
                        MarryFuBenMgr.UpdateMarriageData2DB(spouseClient);
                        MarriageOtherLogic.getInstance().ResetRingAttr(spouseClient);
                        MarriageOtherLogic.getInstance().SendMarriageDataToClient(spouseClient, true);
                        if (spouseClient._IconStateMgr.CheckJieRiFanLi(spouseClient, ActivityTypes.JieriMarriage))
                        {
                            spouseClient._IconStateMgr.AddFlushIconState(14000, spouseClient._IconStateMgr.IsAnyJieRiTipActived());
                            spouseClient._IconStateMgr.SendIconStateToClient(spouseClient);
                        }
                    }
                    else
                    {
                        string       tcpstring          = string.Format("{0}", spouseID);
                        MarriageData spouseMarriageData = Global.sendToDB <MarriageData, string>(10186, tcpstring, client.ServerId);
                        if (spouseMarriageData != null && 0 < spouseMarriageData.byMarrytype)
                        {
                            spouseMarriageData.byMarrytype = -1;
                            spouseMarriageData.nSpouseID   = -1;
                            MarryFuBenMgr.UpdateMarriageData2DB(spouseID, spouseMarriageData, client);
                        }
                    }
                    MarryPartyLogic.getInstance().MarryPartyRemove(client.ClientData.RoleID, true, client);
                    MarryPartyLogic.getInstance().MarryPartyRemove(spouseID, true, client);
                    MarriageOtherLogic.getInstance().SendMarriageDataToClient(client, true);
                    if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriMarriage))
                    {
                        client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived());
                        client._IconStateMgr.SendIconStateToClient(client);
                    }
                    string msg = string.Format(GLang.GetLang(486, new object[0]), client.ClientData.RoleName);
                    MarryLogic.SendDivorceMail(spouseID, GLang.GetLang(487, new object[0]), msg, spouseClient, client.ServerId);
                    SingletonTemplate <CoupleArenaManager> .Instance().OnDivorce(client.ClientData.RoleID, spouseID);
                }
                else if (divorceType == MarryDivorceType.DivorceFree)
                {
                    if (null == spouseClient)
                    {
                        return(MarryResult.TargetOffline);
                    }
                    if (spouseClient.ClientData.ExchangeID > 0 || spouseClient.ClientSocket.IsKuaFuLogin || spouseClient.ClientData.CopyMapID > 0)
                    {
                        return(MarryResult.TargetBusy);
                    }
                    if (Global.GetTotalBindTongQianAndTongQianVal(client) < MarryLogic.DivorceCost)
                    {
                        return(MarryResult.MoneyNotEnough);
                    }
                    if (!Global.SubBindTongQianAndTongQian(client, MarryLogic.DivorceCost, "申请离婚"))
                    {
                        return(MarryResult.MoneyNotEnough);
                    }
                    MarryLogic.AddMarryApply(client.ClientData.RoleID, MarryApplyType.ApplyDivorce, spouseID);
                    string notifyData = string.Format("{0}:{1}", client.ClientData.RoleID, 1);
                    spouseClient.sendCmd(892, notifyData, false);
                    SingletonTemplate <CoupleArenaManager> .Instance().OnSpouseRequestDivorce(spouseClient, client);
                }
                else
                {
                    if (null == spouseClient)
                    {
                        return(MarryResult.TargetOffline);
                    }
                    if (!MarryLogic.RemoveMarryApply(spouseID, MarryApplyType.ApplyDivorce))
                    {
                        return(MarryResult.ApplyTimeout);
                    }
                    MarryLogic.RemoveMarryApply(spouseID, MarryApplyType.ApplyNull);
                    if (divorceType == MarryDivorceType.DivorceFreeAccept)
                    {
                        if (SingletonTemplate <CoupleWishManager> .Instance().PreClearDivorceData(_man, _wife) && SingletonTemplate <CoupleArenaManager> .Instance().PreClearDivorceData(_man, _wife))
                        {
                            client.ClientData.MyMarriageData.byMarrytype       = -1;
                            client.ClientData.MyMarriageData.nSpouseID         = -1;
                            spouseClient.ClientData.MyMarriageData.byMarrytype = -1;
                            spouseClient.ClientData.MyMarriageData.nSpouseID   = -1;
                            MarryFuBenMgr.UpdateMarriageData2DB(client);
                            MarryFuBenMgr.UpdateMarriageData2DB(spouseClient);
                            MarriageOtherLogic.getInstance().SendMarriageDataToClient(client, true);
                            MarriageOtherLogic.getInstance().SendMarriageDataToClient(spouseClient, true);
                            MarriageOtherLogic.getInstance().ResetRingAttr(client);
                            MarriageOtherLogic.getInstance().ResetRingAttr(spouseClient);
                            MarryPartyLogic.getInstance().MarryPartyRemove(client.ClientData.RoleID, true, client);
                            MarryPartyLogic.getInstance().MarryPartyRemove(spouseID, true, client);
                            if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriMarriage))
                            {
                                client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived());
                                client._IconStateMgr.SendIconStateToClient(client);
                            }
                            if (spouseClient._IconStateMgr.CheckJieRiFanLi(spouseClient, ActivityTypes.JieriMarriage))
                            {
                                spouseClient._IconStateMgr.AddFlushIconState(14000, spouseClient._IconStateMgr.IsAnyJieRiTipActived());
                                spouseClient._IconStateMgr.SendIconStateToClient(spouseClient);
                            }
                            SingletonTemplate <CoupleArenaManager> .Instance().OnDivorce(client.ClientData.RoleID, spouseID);
                        }
                        else
                        {
                            GameManager.ClientMgr.AddMoney1(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, spouseClient, MarryLogic.DivorceCost, "自由离婚拒绝返还绑金", false);
                            GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(488, new object[0]), new object[0]), GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox, 0);
                            GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, spouseClient, StringUtil.substitute(GLang.GetLang(488, new object[0]), new object[0]), GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox, 0);
                        }
                    }
                    else if (divorceType == MarryDivorceType.DivorceFreeReject)
                    {
                        GameManager.ClientMgr.AddMoney1(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, spouseClient, MarryLogic.DivorceCost, "自由离婚拒绝返还绑金", false);
                        string notifyData = string.Format("{0}:{1}", client.ClientData.RoleID, 3);
                        spouseClient.sendCmd(892, notifyData, false);
                    }
                }
                result = MarryResult.Success;
            }
            return(result);
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
 public bool ProcessGetKarenBattleStateCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         int result    = 0;
         int westcount = 0;
         int eastcount = 0;
         if (!this.IsGongNengOpened(client, true))
         {
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
             {
                 result,
                 westcount,
                 eastcount,
                 "",
                 ""
             }), false);
             return(true);
         }
         KarenGameStates timeState = KarenGameStates.None;
         this.CheckTimeCondition(ref timeState);
         if (this.CheckCanEnterKarenBattle(client))
         {
             if (timeState == KarenGameStates.Wait)
             {
                 result = 1;
             }
             else if (timeState == KarenGameStates.Start)
             {
                 lock (this.Mutex)
                 {
                     foreach (KeyValuePair <int, KarenBattleSceneInfo> item in this.SceneDataDict)
                     {
                         KarenFuBenData fubenData = JunTuanClient.getInstance().GetKarenKuaFuFuBenData(item.Key);
                         if (null != fubenData)
                         {
                             JunTuanRankData rankData = this.GetJunTuanRankDataByClient(client);
                             if (null != rankData)
                             {
                                 SceneUIClasses sceneType = Global.GetMapSceneType(item.Value.MapCode);
                                 if (sceneType == SceneUIClasses.KarenWest)
                                 {
                                     westcount = fubenData.GetRoleCountWithEnter(rankData.Rank);
                                 }
                                 else
                                 {
                                     eastcount = fubenData.GetRoleCountWithEnter(rankData.Rank);
                                 }
                             }
                         }
                     }
                 }
                 result = 2;
             }
         }
         else if (timeState == KarenGameStates.Wait || timeState == KarenGameStates.Start)
         {
             JunTuanRankData RankData = this.GetJunTuanRankDataByClient(client);
             if (null != RankData)
             {
                 result = 3;
             }
             else
             {
                 result = 4;
             }
         }
         string            eastjtname = "";
         string            westjtname = "";
         List <LingDiData> LingDiList = JunTuanClient.getInstance().GetLingDiData();
         if (null != LingDiList)
         {
             foreach (LingDiData item2 in LingDiList)
             {
                 SceneUIClasses mapType = this.ConvertCaiJiLingDiTypeToMapSceneType(item2.LingDiType);
                 if (mapType == SceneUIClasses.KarenWest)
                 {
                     westjtname = item2.JunTuanName;
                 }
                 else if (mapType == SceneUIClasses.KarenEast)
                 {
                     eastjtname = item2.JunTuanName;
                 }
             }
         }
         client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
         {
             result,
             westcount,
             eastcount,
             westjtname,
             eastjtname
         }), false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Ejemplo n.º 14
0
 public bool ProcessKarenBattleEnterCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         int result = 0;
         if (!this.IsGongNengOpened(client, true))
         {
             client.sendCmd <int>(nID, result, false);
             return(true);
         }
         int roleID  = Global.SafeConvertToInt32(cmdParams[0]);
         int mapCode = Global.SafeConvertToInt32(cmdParams[1]);
         KarenBattleSceneInfo sceneItem = null;
         KarenGameStates      state     = KarenGameStates.None;
         int             eastcount      = 0;
         int             westcount      = 0;
         JunTuanRankData rankData       = this.GetJunTuanRankDataByClient(client);
         if (rankData == null || !this.CheckCanEnterKarenBattle(client))
         {
             result = -5;
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
             {
                 result,
                 0,
                 westcount,
                 eastcount
             }), false);
             return(true);
         }
         if (!this.CheckMap(client))
         {
             result = -21;
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
             {
                 result,
                 0,
                 westcount,
                 eastcount
             }), false);
             return(true);
         }
         result = this.CheckTimeCondition(ref state);
         if (state != KarenGameStates.Start)
         {
             result = -2001;
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
             {
                 result,
                 0,
                 westcount,
                 eastcount
             }), false);
             return(true);
         }
         lock (this.Mutex)
         {
             if (!this.SceneDataDict.TryGetValue(mapCode, out sceneItem))
             {
                 result = -5;
                 client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
                 {
                     result,
                     0,
                     westcount,
                     eastcount
                 }), false);
                 return(true);
             }
             foreach (KeyValuePair <int, KarenBattleSceneInfo> item in this.SceneDataDict)
             {
                 KarenFuBenData fbData = JunTuanClient.getInstance().GetKarenKuaFuFuBenData(item.Key);
                 if (null != fbData)
                 {
                     SceneUIClasses sType = Global.GetMapSceneType(item.Value.MapCode);
                     if (sType == SceneUIClasses.KarenWest)
                     {
                         westcount = fbData.GetRoleCountWithEnter(rankData.Rank);
                     }
                     else
                     {
                         eastcount = fbData.GetRoleCountWithEnter(rankData.Rank);
                     }
                 }
             }
             DateTime lastEnterTime = Global.GetRoleParamsDateTimeFromDB(client, "20019");
             if (!this.GMTest && TimeUtil.NowDateTime().Ticks - lastEnterTime.Ticks < 10000000L * (long)sceneItem.EnterCD)
             {
                 GameManager.ClientMgr.NotifyImportantMsg(client, string.Format(GLang.GetLang(2615, new object[0]), sceneItem.EnterCD), GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox, 0);
                 result = -2007;
                 client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
                 {
                     result,
                     0,
                     westcount,
                     eastcount
                 }), false);
                 return(true);
             }
             KuaFuServerInfo kfserverInfo = null;
             KarenFuBenData  fubenData    = JunTuanClient.getInstance().GetKarenKuaFuFuBenData(mapCode);
             if (fubenData == null || !KuaFuManager.getInstance().TryGetValue(fubenData.ServerId, out kfserverInfo))
             {
                 result = -11000;
                 client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
                 {
                     result,
                     0,
                     westcount,
                     eastcount
                 }), false);
                 return(true);
             }
             if (fubenData.GetRoleCountWithEnter(rankData.Rank) >= sceneItem.MaxEnterNum)
             {
                 result = -22;
                 client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
                 {
                     result,
                     0,
                     westcount,
                     eastcount
                 }), false);
                 return(true);
             }
             SceneUIClasses       sceneType = Global.GetMapSceneType(sceneItem.MapCode);
             KuaFuServerLoginData clientKuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client);
             if (null != clientKuaFuServerLoginData)
             {
                 clientKuaFuServerLoginData.RoleId     = client.ClientData.RoleID;
                 clientKuaFuServerLoginData.GameId     = (long)fubenData.GameId;
                 clientKuaFuServerLoginData.GameType   = fubenData.GameType;
                 clientKuaFuServerLoginData.EndTicks   = fubenData.EndTime.Ticks;
                 clientKuaFuServerLoginData.ServerId   = client.ServerId;
                 clientKuaFuServerLoginData.ServerIp   = kfserverInfo.Ip;
                 clientKuaFuServerLoginData.ServerPort = kfserverInfo.Port;
                 clientKuaFuServerLoginData.FuBenSeqId = 0;
             }
             if (result >= 0)
             {
                 result = JunTuanClient.getInstance().GameFuBenRoleChangeState(client.ServerId, client.ClientData.RoleID, (int)clientKuaFuServerLoginData.GameId, rankData.Rank, 4);
                 if (result >= 0)
                 {
                     GlobalNew.RecordSwitchKuaFuServerLog(client);
                     client.sendCmd <KuaFuServerLoginData>(14000, Global.GetClientKuaFuServerLoginData(client), false);
                 }
                 else
                 {
                     Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
                 }
             }
         }
         client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
         {
             result,
             0,
             westcount,
             eastcount
         }), false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Ejemplo n.º 15
0
        private bool ProcessHuiJiStarUpCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            int result = 0;
            HuiJiUpdateResultData resultData = new HuiJiUpdateResultData();
            RoleHuiJiData         huiJiData  = client.ClientData.HuiJiData;
            int exp = 0;
            HuiJiUpdateResultData requestData = DataHelper.BytesToObject <HuiJiUpdateResultData>(bytes, 0, bytes.Length);
            int  type     = requestData.Type;
            int  zuanshi  = requestData.ZuanShi;
            int  auto     = requestData.Auto;
            long nowTicks = TimeUtil.NOW();

            if (!this.IsGongNengOpened(client))
            {
                result = -12;
            }
            else
            {
                lock (this.RuntimeData.Mutex)
                {
                    EmblemStarInfo starInfo;
                    EmblemStarInfo starInfo2;
                    if (huiJiData.huiji != requestData.HuiJi)
                    {
                        result = -3;
                    }
                    else if (!this.RuntimeData.EmblemStarDict.Value.TryGetValue(huiJiData.huiji, out starInfo))
                    {
                        result = -3;
                    }
                    else if (!this.RuntimeData.EmblemStarDict.Value.TryGetValue(huiJiData.huiji + 1, out starInfo2))
                    {
                        result = -4004;
                    }
                    else
                    {
                        bool   useBind      = false;
                        bool   useTimeLimit = false;
                        string strCostList;
                        if (type == 0)
                        {
                            if (starInfo.EmblemUpInfo.MaxStarLevel == starInfo.EmblemStar)
                            {
                                result = -4;
                                goto IL_646;
                            }
                            if (Global.UseGoodsBindOrNot(client, starInfo.NeedGoods[0], starInfo.NeedGoods[1], true, out useBind, out useTimeLimit) < 0)
                            {
                                if (zuanshi <= 0 || zuanshi != starInfo.NeedDiamond)
                                {
                                    result = -6;
                                    goto IL_646;
                                }
                                if (!GameManager.ClientMgr.SubUserMoney(client, zuanshi, "徽记升星", true, true, true, true, DaiBiSySType.HuiJiShengXing))
                                {
                                    result = -10;
                                    goto IL_646;
                                }
                                exp         = starInfo.ZuanShiExp;
                                strCostList = EventLogManager.NewResPropString(ResLogType.ZuanShi, new object[]
                                {
                                    -zuanshi,
                                    client.ClientData.UserMoney + zuanshi,
                                    client.ClientData.UserMoney
                                });
                                if (Global.GetRandom() < this.RuntimeData.EmblemShengXing[1])
                                {
                                    exp = (int)((double)exp * this.RuntimeData.EmblemShengXing[2]);
                                }
                            }
                            else
                            {
                                exp         = starInfo.GoodsExp;
                                strCostList = EventLogManager.NewGoodsDataPropString(new GoodsData
                                {
                                    GoodsID = starInfo.NeedGoods[0],
                                    GCount  = starInfo.NeedGoods[1]
                                });
                                if (Global.GetRandom() < this.RuntimeData.EmblemShengXing[0])
                                {
                                    exp = (int)((double)exp * this.RuntimeData.EmblemShengXing[2]);
                                }
                            }
                            huiJiData.Exp += exp;
                            if (huiJiData.Exp >= starInfo.StarExp)
                            {
                                huiJiData.huiji++;
                                if (starInfo.EmblemStar < starInfo.EmblemUpInfo.MaxStarLevel - 1)
                                {
                                    huiJiData.Exp -= starInfo.StarExp;
                                }
                                else
                                {
                                    huiJiData.Exp = 0;
                                }
                            }
                        }
                        else
                        {
                            if (starInfo.EmblemUpInfo.MaxStarLevel != starInfo.EmblemStar)
                            {
                                result = -4;
                                goto IL_646;
                            }
                            if (Global.UseGoodsBindOrNot(client, starInfo.EmblemUpInfo.NeedGoods[0], starInfo.EmblemUpInfo.NeedGoods[1], true, out useBind, out useTimeLimit) < 0)
                            {
                                if (zuanshi <= 0 || zuanshi != starInfo.EmblemUpInfo.NeedDiamond)
                                {
                                    result = -6;
                                    goto IL_646;
                                }
                                if (!GameManager.ClientMgr.SubUserMoney(client, zuanshi, "徽记升阶", true, true, true, true, DaiBiSySType.HuiJiShengJie))
                                {
                                    result = -10;
                                    goto IL_646;
                                }
                                strCostList = EventLogManager.NewResPropString(ResLogType.ZuanShi, new object[]
                                {
                                    -zuanshi,
                                    client.ClientData.UserMoney + zuanshi,
                                    client.ClientData.UserMoney
                                });
                            }
                            else
                            {
                                strCostList = EventLogManager.NewGoodsDataPropString(new GoodsData
                                {
                                    GoodsID = starInfo.EmblemUpInfo.NeedGoods[0],
                                    GCount  = starInfo.EmblemUpInfo.NeedGoods[1]
                                });
                                exp = starInfo.GoodsExp;
                            }
                            huiJiData.Exp++;
                            if (starInfo.EmblemUpInfo.LuckyOne + huiJiData.Exp >= 110000)
                            {
                                huiJiData.huiji++;
                                huiJiData.Exp = 0;
                            }
                            else if (starInfo.EmblemUpInfo.LuckyOne + huiJiData.Exp > starInfo.EmblemUpInfo.LuckyTwo)
                            {
                                if (Global.GetRandom() < starInfo.EmblemUpInfo.LuckyTwoRate)
                                {
                                    huiJiData.huiji++;
                                    huiJiData.Exp = 0;
                                }
                            }
                        }
                        Global.SendToDB <RoleDataCmdT <RoleHuiJiData> >(1446, new RoleDataCmdT <RoleHuiJiData>(client.ClientData.RoleID, huiJiData), client.ServerId);
                        if (huiJiData.huiji > requestData.HuiJi)
                        {
                            client.ClientData.PropsCacheManager.SetExtProps(new object[]
                            {
                                PropsSystemTypes.HuiJiHuTi,
                                starInfo2.ExtPropValues
                            });
                            client.delayExecModule.SetDelayExecProc(new DelayExecProcIds[]
                            {
                                DelayExecProcIds.RecalcProps,
                                DelayExecProcIds.NotifyRefreshProps
                            });
                            EventLogManager.AddHuiJiEvent(client, type, (zuanshi > 0) ? 1 : 0, exp, starInfo.EmblemLevel, starInfo.EmblemStar, starInfo2.EmblemLevel, starInfo2.EmblemStar, huiJiData.Exp, strCostList);
                        }
                        else
                        {
                            EventLogManager.AddHuiJiEvent(client, type, (zuanshi > 0) ? 1 : 0, exp, starInfo.EmblemLevel, starInfo.EmblemStar, starInfo.EmblemLevel, starInfo.EmblemStar, huiJiData.Exp, strCostList);
                        }
                    }
                }
            }
IL_646:
            if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieRiHuiJi))
            {
                client._IconStateMgr.SendIconStateToClient(client);
            }
            resultData.Result = result;
            resultData.HuiJi  = huiJiData.huiji;
            resultData.Exp    = huiJiData.Exp;
            resultData.Auto   = auto;
            resultData.Type   = type;
            client.sendCmd <HuiJiUpdateResultData>(nID, resultData, false);
            return(true);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 执行炼制
        /// </summary>
        /// <param name="type">炼制类型: 0 金币,1 绑钻,2钻石</param>
        /// <param name="count">炼制次数: 非正数表示全部剩余次数</param>
        /// <returns></returns>
        public bool ExecLianZhi(GameClient client, int type, int count)
        {
            int        roleID   = client.ClientData.RoleID;
            int        vipLevel = client.ClientData.VipLevel;
            int        nID      = (int)TCPGameServerCmds.CMD_SPR_EXEC_LIANZHI;
            string     useMsg   = "炼制系统";
            List <int> result   = new List <int>();

            result.Add(StdErrorCode.Error_Success);
            result.Add(type);
            result.Add(count);

            //验证配置和参数
            if (!ConfigLoadSuccess)
            {
                result[0] = StdErrorCode.Error_Config_Fault;
                client.sendCmd(nID, result);
            }
            else if (type < 0 || type > 2)
            {
                result[0] = StdErrorCode.Error_Invalid_Operation;
                client.sendCmd(nID, result);
            }
            else
            {
                int  needJinBi    = 0;
                int  needBangZuan = 0;
                int  needZuanShi  = 0;
                long addExp       = 0;
                int  addXingHun   = 0;
                int  addJinBi     = 0;

                int lianZhiCount    = 0;  //当日已用此数
                int lianZhiDayID    = -1; //使用的日期
                int lianZhiMaxCount = 0;  //最大次数限制
                int dayID           = TimeUtil.NowDateTime().DayOfYear;

                //整理次数、消耗和奖励信息
                if (type == 0)
                {
                    useMsg          = "金币炼制";
                    lianZhiCount    = Global.GetRoleParamsInt32FromDB(client, RoleParamName.LianZhiJinBiCount);
                    lianZhiDayID    = Global.GetRoleParamsInt32FromDB(client, RoleParamName.LianZhiJinBiDayID);
                    lianZhiMaxCount = JinBiLianZhi[2] + VIPJinBiLianZhi[Math.Min(VIPJinBiLianZhi.Length - 1, vipLevel)];
                    needJinBi       = JinBiLianZhi[0];
                    addExp          = JinBiLianZhi[1];

                    JieRiMultAwardActivity activity = HuodongCachingMgr.GetJieRiMultAwardActivity();
                    if (null != activity)
                    {
                        JieRiMultConfig config = activity.GetConfig((int)MultActivityType.ZhuanHuanCount);
                        if (null != config)
                        {
                            lianZhiMaxCount = lianZhiMaxCount * ((int)config.GetMult() + 1);
                        }
                        config = activity.GetConfig((int)MultActivityType.ZhuanHuanAward);
                        if (null != config)
                        {
                            addExp += (int)(addExp * config.GetMult());
                        }
                    }
                }
                else if (type == 1)
                {
                    useMsg          = "绑钻炼制";
                    lianZhiCount    = Global.GetRoleParamsInt32FromDB(client, RoleParamName.LianZhiBangZuanCount);
                    lianZhiDayID    = Global.GetRoleParamsInt32FromDB(client, RoleParamName.LianZhiBangZuanDayID);
                    lianZhiMaxCount = BangZuanLianZhi[2] + VIPBangZuanLianZhi[Math.Min(VIPBangZuanLianZhi.Length - 1, vipLevel)];
                    needBangZuan    = BangZuanLianZhi[0];
                    addXingHun      = BangZuanLianZhi[1];

                    JieRiMultAwardActivity activity = HuodongCachingMgr.GetJieRiMultAwardActivity();
                    if (null != activity)
                    {
                        JieRiMultConfig config = activity.GetConfig((int)MultActivityType.ZhuanHuanCount);
                        if (null != config)
                        {
                            lianZhiMaxCount = lianZhiMaxCount * ((int)config.GetMult() + 1);
                        }
                        config = activity.GetConfig((int)MultActivityType.ZhuanHuanAward);
                        if (null != config)
                        {
                            addXingHun += (int)(addXingHun * config.GetMult());
                        }
                    }
                }
                else if (type == 2)
                {
                    useMsg          = "钻石炼制";
                    lianZhiCount    = Global.GetRoleParamsInt32FromDB(client, RoleParamName.LianZhiZuanShiCount);
                    lianZhiDayID    = Global.GetRoleParamsInt32FromDB(client, RoleParamName.LianZhiZuanShiDayID);
                    lianZhiMaxCount = ZuanShiLianZhi[4] + VIPZuanShiLianZhi[Math.Min(VIPZuanShiLianZhi.Length - 1, vipLevel)];
                    needZuanShi     = ZuanShiLianZhi[0];
                    addExp          = ZuanShiLianZhi[1];
                    addXingHun      = ZuanShiLianZhi[2];
                    addJinBi        = ZuanShiLianZhi[3];

                    JieRiMultAwardActivity activity = HuodongCachingMgr.GetJieRiMultAwardActivity();
                    if (null != activity)
                    {
                        JieRiMultConfig config = activity.GetConfig((int)MultActivityType.ZhuanHuanCount);
                        if (null != config)
                        {
                            lianZhiMaxCount = lianZhiMaxCount * ((int)config.GetMult() + 1);
                        }
                        config = activity.GetConfig((int)MultActivityType.ZhuanHuanAward);
                        if (null != config)
                        {
                            addExp     += (int)(addExp * config.GetMult());
                            addXingHun += (int)(addXingHun * config.GetMult());
                            addJinBi   += (int)(addJinBi * config.GetMult());
                        }
                    }
                }

                //炼制日期已经不是今天,则次数归零
                if (lianZhiDayID != dayID)
                {
                    lianZhiCount = 0;
                }

                //如果传入0及以下的次数,则默认为最大次数
                if (count <= 0)
                {
                    count = lianZhiMaxCount - lianZhiCount;
                }

                //验证剩余次数
                if (count <= 0 || lianZhiCount + count > lianZhiMaxCount)
                {
                    result[0] = StdErrorCode.Error_No_Residue_Degree;
                    client.sendCmd(nID, result);
                }
                else
                {
                    needJinBi    *= count;
                    needBangZuan *= count;
                    needZuanShi  *= count;
                    addExp       *= count;
                    addXingHun   *= count;
                    addJinBi     *= count;

                    addExp = Global.GetExpMultiByZhuanShengExpXiShu(client, addExp);

                    //扣除消耗所需
                    if (needJinBi > 0 && !Global.SubBindTongQianAndTongQian(client, needJinBi, useMsg))
                    {
                        result[0] = StdErrorCode.Error_JinBi_Not_Enough;
                        client.sendCmd(nID, result);
                    }
                    else if (needBangZuan > 0 && !GameManager.ClientMgr.SubUserGold(client, needBangZuan, useMsg))
                    {
                        result[0] = StdErrorCode.Error_BangZuan_Not_Enough;
                        client.sendCmd(nID, result);
                    }
                    else if (needZuanShi > 0 && !GameManager.ClientMgr.SubUserMoney(client, needZuanShi, useMsg))
                    {
                        result[0] = StdErrorCode.Error_ZuanShi_Not_Enough;
                        client.sendCmd(nID, result);
                    }
                    else
                    {
                        //既然该扣的都扣除了,下面可以给奖励了
                        if (addExp > 0)
                        {
                            GameManager.ClientMgr.ProcessRoleExperience(client, addExp);
                        }
                        if (addJinBi > 0)
                        {
                            GameManager.ClientMgr.AddMoney1(client, addJinBi, useMsg);
                        }
                        if (addXingHun > 0)
                        {
                            GameManager.ClientMgr.ModifyStarSoulValue(client, addXingHun, useMsg, true);
                        }

                        //计次存盘
                        lianZhiCount += count;
                        lianZhiDayID  = dayID;
                        if (type == 0)
                        {
                            // 七日活动
                            GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.JinBiZhuanHuanTimes));

                            Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.LianZhiJinBiCount, lianZhiCount, true);
                            Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.LianZhiJinBiDayID, lianZhiDayID, true);
                        }
                        else if (type == 1)
                        {
                            // 七日活动
                            GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.BangZuanZhuanHuanTimes));

                            Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.LianZhiBangZuanCount, lianZhiCount, true);
                            Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.LianZhiBangZuanDayID, lianZhiDayID, true);
                        }
                        else if (type == 2)
                        {
                            // 七日活动
                            GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.ZuanShiZhuanHuanTimes));

                            Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.LianZhiZuanShiCount, lianZhiCount, true);
                            Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.LianZhiZuanShiDayID, lianZhiDayID, true);
                        }

                        //返回结果
                        client.sendCmd(nID, result);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 给奖励
        /// </summary>
        public void GiveAwards(TianTiScene tianTiScene)
        {
            try
            {
                DateTime          now       = TimeUtil.NowDateTime();
                DateTime          startTime = now.Subtract(RuntimeData.RefreshTime); //后退刷新时间,这样来保证不跨天计次
                List <GameClient> objsList  = tianTiScene.CopyMap.GetClientsList();
                if (objsList != null && objsList.Count > 0)
                {
                    int nowDayId = Global.GetOffsetDayNow();
                    for (int n = 0; n < objsList.Count; ++n)
                    {
                        GameClient client = objsList[n];
                        if (client != null && client == GameManager.ClientMgr.FindClient(client.ClientData.RoleID)) //确认角色仍然在线
                        {
                            RoleTianTiData     roleTianTiData    = client.ClientData.TianTiData;
                            bool               success           = client.ClientData.BattleWhichSide == tianTiScene.SuccessSide;
                            int                selfDuanWeiId     = roleTianTiData.DuanWeiId;
                            TianTiRoleMiniData enemyMiniData     = GetEnemyBattleSide(tianTiScene, client);
                            int                addDuanWeiJiFen   = 0;
                            int                addLianShengJiFen = 0;
                            int                addRongYao        = 0;

                            int dayId = Global.GetOffsetDay(startTime);
                            if (dayId != roleTianTiData.LastFightDayId)
                            {
                                roleTianTiData.LastFightDayId  = dayId;
                                roleTianTiData.TodayFightCount = 1;
                            }
                            else
                            {
                                roleTianTiData.TodayFightCount++;
                            }

                            //设置每日天梯积分获得上限为60万
                            if (roleTianTiData.DayDuanWeiJiFen < RuntimeData.MaxTianTiJiFen)
                            {
                                TianTiDuanWei tianTiDuanWei;
                                if (success)
                                {
                                    roleTianTiData.LianSheng++;
                                    roleTianTiData.SuccessCount++;
                                    if (RuntimeData.TianTiDuanWeiDict.TryGetValue(enemyMiniData.DuanWeiId, out tianTiDuanWei))
                                    {
                                        //连胜后积分=基础积分*(1+Min(2,((连续胜利次数-1)* 0.2)))
                                        addDuanWeiJiFen   = tianTiDuanWei.WinJiFen;
                                        addLianShengJiFen = (int)(tianTiDuanWei.WinJiFen * Math.Min(2, (roleTianTiData.LianSheng - 1) * 0.2));
                                        if (roleTianTiData.TodayFightCount <= tianTiDuanWei.RongYaoNum)
                                        {
                                            addRongYao = tianTiDuanWei.WinRongYu;
                                        }
                                    }
                                }
                                else
                                {
                                    roleTianTiData.LianSheng = 0;
                                    if (RuntimeData.TianTiDuanWeiDict.TryGetValue(roleTianTiData.DuanWeiId, out tianTiDuanWei))
                                    {
                                        addDuanWeiJiFen = tianTiDuanWei.LoseJiFen;
                                        if (roleTianTiData.TodayFightCount <= tianTiDuanWei.RongYaoNum)
                                        {
                                            addRongYao = tianTiDuanWei.LoseRongYu;
                                        }
                                    }
                                }

                                if (addDuanWeiJiFen != 0)
                                {
                                    roleTianTiData.DuanWeiJiFen += addDuanWeiJiFen + addLianShengJiFen;
                                    roleTianTiData.DuanWeiJiFen  = Math.Max(0, roleTianTiData.DuanWeiJiFen);

                                    roleTianTiData.DayDuanWeiJiFen += addDuanWeiJiFen + addLianShengJiFen;
                                    roleTianTiData.DayDuanWeiJiFen  = Math.Max(0, roleTianTiData.DayDuanWeiJiFen);
                                    Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.TianTiDayScore, roleTianTiData.DayDuanWeiJiFen, true);
                                }
                            }
                            else
                            {
                                GameManager.ClientMgr.NotifyHintMsg(client, Global.GetLang("今日获得段位积分已达上限!"));
                            }

                            if (addRongYao != 0)
                            {
                                GameManager.ClientMgr.ModifyTianTiRongYaoValue(client, addRongYao, "天梯系统获得荣耀", true);
                            }

                            roleTianTiData.FightCount++;
                            if (RuntimeData.DuanWeiJiFenRangeDuanWeiIdDict.TryGetValue(roleTianTiData.DuanWeiJiFen, out selfDuanWeiId))
                            {
                                roleTianTiData.DuanWeiId = selfDuanWeiId;
                            }

                            TianTiAwardsData awardsData = new TianTiAwardsData();
                            awardsData.DuanWeiJiFen   = addDuanWeiJiFen;
                            awardsData.LianShengJiFen = addLianShengJiFen;
                            awardsData.RongYao        = addRongYao;
                            awardsData.DuanWeiId      = roleTianTiData.DuanWeiId;
                            if (success)
                            {
                                awardsData.Success = 1;
                                GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 1, 0, (int)GameTypes.TianTi);
                            }
                            else
                            {
                                GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 0, 1, (int)GameTypes.TianTi);
                            }

                            client.sendCmd((int)TCPGameServerCmds.CMD_SPR_TIANTI_AWARD, awardsData);
                            Global.sendToDB <int, RoleTianTiData>((int)TCPGameServerCmds.CMD_DB_TIANTI_UPDATE_ROLE_DATA, roleTianTiData, client.ServerId);

                            TianTiLogItemData tianTiLogItemData = new TianTiLogItemData()
                            {
                                Success           = awardsData.Success,
                                ZoneId1           = client.ClientData.ZoneID,
                                RoleName1         = client.ClientData.RoleName,
                                ZoneId2           = enemyMiniData.ZoneId,
                                RoleName2         = enemyMiniData.RoleName,
                                DuanWeiJiFenAward = addDuanWeiJiFen + addLianShengJiFen,
                                RongYaoAward      = addRongYao,
                                RoleId            = client.ClientData.RoleID,
                                EndTime           = now,
                            };
                            Global.sendToDB <int, TianTiLogItemData>((int)TCPGameServerCmds.CMD_DB_TIANTI_ADD_ZHANBAO_LOG, tianTiLogItemData, client.ServerId);

                            TianTiPaiHangRoleData tianTiPaiHangRoleData = new TianTiPaiHangRoleData();
                            tianTiPaiHangRoleData.DuanWeiId    = roleTianTiData.DuanWeiId;
                            tianTiPaiHangRoleData.RoleId       = roleTianTiData.RoleId;
                            tianTiPaiHangRoleData.RoleName     = client.ClientData.RoleName;
                            tianTiPaiHangRoleData.Occupation   = client.ClientData.Occupation;
                            tianTiPaiHangRoleData.ZhanLi       = client.ClientData.CombatForce;
                            tianTiPaiHangRoleData.ZoneId       = client.ClientData.ZoneID;
                            tianTiPaiHangRoleData.DuanWeiJiFen = roleTianTiData.DuanWeiJiFen;
                            RoleData4Selector roleInfo = Global.sendToDB <RoleData4Selector, string>((int)TCPGameServerCmds.CMD_SPR_GETROLEUSINGGOODSDATALIST, string.Format("{0}", client.ClientData.RoleID), client.ServerId);
                            if (null != roleInfo || roleInfo.RoleID < 0)
                            {
                                tianTiPaiHangRoleData.RoleData4Selector = roleInfo;
                            }
                            PlayerJingJiData jingJiData = JingJiChangManager.getInstance().createJingJiData(client);

                            TianTiRoleInfoData tianTiRoleInfoData = new TianTiRoleInfoData();
                            tianTiRoleInfoData.RoleId                 = tianTiPaiHangRoleData.RoleId;
                            tianTiRoleInfoData.ZoneId                 = tianTiPaiHangRoleData.ZoneId;
                            tianTiRoleInfoData.ZhanLi                 = tianTiPaiHangRoleData.ZhanLi;
                            tianTiRoleInfoData.RoleName               = tianTiPaiHangRoleData.RoleName;
                            tianTiRoleInfoData.DuanWeiId              = tianTiPaiHangRoleData.DuanWeiId;
                            tianTiRoleInfoData.DuanWeiJiFen           = tianTiPaiHangRoleData.DuanWeiJiFen;
                            tianTiRoleInfoData.DuanWeiRank            = tianTiPaiHangRoleData.DuanWeiRank;
                            tianTiRoleInfoData.TianTiPaiHangRoleData  = DataHelper.ObjectToBytes(tianTiPaiHangRoleData);
                            tianTiRoleInfoData.PlayerJingJiMirrorData = DataHelper.ObjectToBytes(jingJiData);
                            TianTiClient.getInstance().UpdateRoleInfoData(tianTiRoleInfoData);
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                DataHelper.WriteExceptionLogEx(ex, "天梯系统清场调度异常");
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 洗炼操作
        /// 返回值列表: (操作索引:错误码:DBID:绑定状态:属性列表键值对...)
        /// </summary>
        /// <param name="client"></param>
        /// <param name="dbid"></param>
        /// <param name="washIndex"></param>
        /// <param name="firstUseBinding"></param>
        /// <returns></returns>
        public static bool WashProps(GameClient client, int dbid, int washIndex, bool firstUseBinding, int moneyType)
        {
            int        nID    = (int)TCPGameServerCmds.CMD_SPR_EXEC_WASHPROPS;
            List <int> result = new List <int>();

            result.Add(washIndex);
            result.Add(StdErrorCode.Error_Success);
            result.Add(dbid);
            result.Add(0);

            if (washIndex > WashOperations.WashPropsQuantity || washIndex < WashOperations.WashPropsQuery)
            {
                result[1] = (StdErrorCode.Error_Invalid_Operation);
                client.sendCmd(nID, result);
                return(true);
            }
            if (moneyType < 0 || moneyType > 1)
            {
                result[1] = (StdErrorCode.Error_MoneyType_Not_Select);
                client.sendCmd(nID, result);
                return(true);
            }

            //查找物品
            GoodsData goodsData = Global.GetGoodsByDbID(client, dbid);

            if (null == goodsData)
            {
                result[1] = (StdErrorCode.Error_Invalid_DBID);
                client.sendCmd(nID, result);
                return(true);
            }

            //if (goodsData.Using > 0)
            //{
            //    result.Add(StdErrorCode.Error_Goods_Is_Using);
            //    client.sendCmd(nID, result);
            //    return true;
            //}

            SystemXmlItem xml;

            if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(goodsData.GoodsID, out xml))
            {
                //错误的参数
                result[1] = (StdErrorCode.Error_Config_Fault);
                client.sendCmd(nID, result);
                return(true);
            }

            int           id = xml.GetIntValue("XiLian");
            XiLianShuXing xiLianShuXing;

            if (!XiLianShuXingDict.TryGetValue(id, out xiLianShuXing))
            {
                //错误的参数
                result[1] = (StdErrorCode.Error_Config_Fault);
                client.sendCmd(nID, result);
                return(true);
            }

            if (washIndex == WashOperations.WashPropsQuantity || washIndex == WashOperations.WashPropsActive)
            {
                if (moneyType == 0)
                {
                    if (client.ClientData.Money1 + client.ClientData.YinLiang < xiLianShuXing.NeedJinBi)
                    {
                        result[1] = (StdErrorCode.Error_JinBi_Not_Enough);
                        client.sendCmd(nID, result);
                        return(true);
                    }
                }
                else if (moneyType == 1)
                {
                    if (client.ClientData.UserMoney < xiLianShuXing.NeedZuanShi)
                    {
                        result[1] = (StdErrorCode.Error_ZuanShi_Not_Enough);
                        client.sendCmd(nID, result);
                        return(true);
                    }
                }
            }

            // 根据客户端的请求分别处理洗炼数值和洗练属性两种操作
            if (washIndex == WashOperations.WashPropsActive)
            {
                //洗炼激活
                if (null != goodsData.WashProps && goodsData.WashProps.Count > 0)
                {
                    result[1] = (StdErrorCode.Error_Invalid_Operation);
                    client.sendCmd(nID, result);
                    return(true);
                }

                int        color = Global.GetEquipColor(goodsData);
                XiLianType xiLianType;
                if (color <= 0 || !XiLianTypeDict.TryGetValue(color, out xiLianType) || xiLianType.ShuXingNum <= 0)
                {
                    result[1] = (StdErrorCode.Error_Invalid_Operation);
                    client.sendCmd(nID, result);
                    return(true);
                }

                UpdateGoodsArgs updateGoodsArgs = new UpdateGoodsArgs()
                {
                    RoleID = client.ClientData.RoleID, DbID = dbid
                };
                updateGoodsArgs.WashProps = new List <int>();

                //扣除所需物品
                // 新增材料替换功能,chenjingui
                if (xiLianShuXing.NeedGoodsIDs[0] > 0 && xiLianShuXing.NeedGoodsCounts[0] > 0)
                {
                    client.ClientData._ReplaceExtArg.Reset();
                    if (GoodsReplaceManager.Instance().NeedCheckSuit(Global.GetGoodsCatetoriy(goodsData.GoodsID)))
                    {
                        client.ClientData._ReplaceExtArg.CurrEquipSuit = Global.GetEquipGoodsSuitID(goodsData.GoodsID);
                    }

                    GoodsReplaceResult replaceRet = GoodsReplaceManager.Instance().GetReplaceResult(client, xiLianShuXing.NeedGoodsIDs[0]);
                    if (replaceRet == null || replaceRet.TotalGoodsCnt() < xiLianShuXing.NeedGoodsCounts[0])
                    {
                        result[1] = (StdErrorCode.Error_Goods_Not_Enough);
                        client.sendCmd(nID, result);
                        return(true);
                    }
                    List <GoodsReplaceResult.ReplaceItem> realCostList = new List <GoodsReplaceResult.ReplaceItem>();
                    if (firstUseBinding)
                    {
                        // 1:使用替换后的绑定材料
                        // 2:使用原始的绑定材料
                        // 3:使用替换后的非绑定材料
                        // 4:使用原始的非绑定材料
                        realCostList.AddRange(replaceRet.BindList);
                        realCostList.Add(replaceRet.OriginBindGoods);
                        realCostList.AddRange(replaceRet.UnBindList);
                        realCostList.Add(replaceRet.OriginUnBindGoods);
                    }
                    else
                    {
                        // 1:使用替换后的非绑定材料
                        // 2:使用原始的非绑定材料
                        // 3:使用替换后的绑定材料
                        // 4:使用原始的绑定材料
                        realCostList.AddRange(replaceRet.UnBindList);
                        realCostList.Add(replaceRet.OriginUnBindGoods);
                        realCostList.AddRange(replaceRet.BindList);
                        realCostList.Add(replaceRet.OriginBindGoods);
                    }

                    int stillNeedGoodsCnt = xiLianShuXing.NeedGoodsCounts[0];
                    foreach (var item in realCostList)
                    {
                        if (item.GoodsCnt <= 0)
                        {
                            continue;
                        }

                        int realCostCnt = Math.Min(stillNeedGoodsCnt, item.GoodsCnt);
                        if (realCostCnt <= 0)
                        {
                            break;
                        }

                        bool usedBinding_just_placeholder     = false;
                        bool usedTimeLimited_just_placeholder = false;

                        bool bFailed = false;
                        if (item.IsBind)
                        {
                            if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client,
                                                                          item.GoodsID, realCostCnt, false, out usedBinding_just_placeholder, out usedTimeLimited_just_placeholder))
                            {
                                bFailed = true;
                            }
                            updateGoodsArgs.Binding = 1;
                        }
                        else
                        {
                            if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client,
                                                                             item.GoodsID, realCostCnt, false, out usedBinding_just_placeholder, out usedTimeLimited_just_placeholder))
                            {
                                bFailed = true;
                            }
                        }

                        if (bFailed)
                        {
                            result[1] = (StdErrorCode.Error_Goods_Not_Enough);
                            client.sendCmd(nID, result);
                            return(true);
                        }

                        stillNeedGoodsCnt -= realCostCnt;
                    }
                }

                //随机激活属性
                for (int i = 0; i < xiLianType.ShuXingNum; i++)
                {
                    int rand      = Global.GetRandomNumber(0, PropsIds.Count);
                    int propID    = PropsIds[rand];
                    int propLimit = xiLianShuXing.PromotePropLimit[propID];
                    int propValue = (int)Math.Ceiling(propLimit * xiLianType.FirstShuXing * xiLianType.ShuXingLimitMultiplying);
                    updateGoodsArgs.WashProps.Add(propID);
                    updateGoodsArgs.WashProps.Add(propValue);
                }

                //存盘并通知用户结果
                Global.UpdateGoodsProp(client, goodsData, updateGoodsArgs);
                //写入角色物品的得失行为日志(扩展)
                Global.ModRoleGoodsEvent(client, goodsData, 0, "装备洗炼激活");
                EventLogManager.AddGoodsEvent(client, OpTypes.Forge, OpTags.None, goodsData.GoodsID, goodsData.Id, 0, goodsData.GCount, "装备洗炼激活");

                result[3] = (goodsData.Binding > 0 | updateGoodsArgs.Binding > 0) ? 1 : 0;
                result.AddRange(goodsData.WashProps);
                client.sendCmd(nID, result);
                return(true);
            }
            else if (washIndex == WashOperations.WashPropsQuantity)
            {
                UpdateGoodsArgs updateGoodsArgs = new UpdateGoodsArgs()
                {
                    RoleID = client.ClientData.RoleID, DbID = dbid
                };

                //扣除所需物品
                if (xiLianShuXing.NeedGoodsIDs[0] > 0 && xiLianShuXing.NeedGoodsCounts[0] > 0)
                {
                    client.ClientData._ReplaceExtArg.Reset();
                    if (GoodsReplaceManager.Instance().NeedCheckSuit(Global.GetGoodsCatetoriy(goodsData.GoodsID)))
                    {
                        client.ClientData._ReplaceExtArg.CurrEquipSuit = Global.GetEquipGoodsSuitID(goodsData.GoodsID);
                    }

                    GoodsReplaceResult replaceRet = GoodsReplaceManager.Instance().GetReplaceResult(client, xiLianShuXing.NeedGoodsIDs[0]);
                    if (replaceRet == null || replaceRet.TotalGoodsCnt() < xiLianShuXing.NeedGoodsCounts[0])
                    {
                        result[1] = (StdErrorCode.Error_Goods_Not_Enough);
                        client.sendCmd(nID, result);
                        return(true);
                    }
                    List <GoodsReplaceResult.ReplaceItem> realCostList = new List <GoodsReplaceResult.ReplaceItem>();
                    if (firstUseBinding)
                    {
                        // 1:使用替换后的绑定材料
                        // 2:使用原始的绑定材料
                        // 3:使用替换后的非绑定材料
                        // 4:使用原始的非绑定材料
                        realCostList.AddRange(replaceRet.BindList);
                        realCostList.Add(replaceRet.OriginBindGoods);
                        realCostList.AddRange(replaceRet.UnBindList);
                        realCostList.Add(replaceRet.OriginUnBindGoods);
                    }
                    else
                    {
                        // 1:使用替换后的非绑定材料
                        // 2:使用原始的非绑定材料
                        // 3:使用替换后的绑定材料
                        // 4:使用原始的绑定材料
                        realCostList.AddRange(replaceRet.UnBindList);
                        realCostList.Add(replaceRet.OriginUnBindGoods);
                        realCostList.AddRange(replaceRet.BindList);
                        realCostList.Add(replaceRet.OriginBindGoods);
                    }

                    int stillNeedGoodsCnt = xiLianShuXing.NeedGoodsCounts[0];
                    foreach (var item in realCostList)
                    {
                        if (item.GoodsCnt <= 0)
                        {
                            continue;
                        }

                        int realCostCnt = Math.Min(stillNeedGoodsCnt, item.GoodsCnt);
                        if (realCostCnt <= 0)
                        {
                            break;
                        }

                        bool usedBinding_just_placeholder     = false;
                        bool usedTimeLimited_just_placeholder = false;

                        bool bFailed = false;
                        if (item.IsBind)
                        {
                            if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client,
                                                                          item.GoodsID, realCostCnt, false, out usedBinding_just_placeholder, out usedTimeLimited_just_placeholder))
                            {
                                bFailed = true;
                            }
                            updateGoodsArgs.Binding = 1;
                        }
                        else
                        {
                            if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client,
                                                                             item.GoodsID, realCostCnt, false, out usedBinding_just_placeholder, out usedTimeLimited_just_placeholder))
                            {
                                bFailed = true;
                            }
                        }

                        if (bFailed)
                        {
                            result[1] = (StdErrorCode.Error_Goods_Not_Enough);
                            client.sendCmd(nID, result);
                            return(true);
                        }

                        stillNeedGoodsCnt -= realCostCnt;
                    }
                }

                if (moneyType == 0)
                {
                    Global.SubBindTongQianAndTongQian(client, xiLianShuXing.NeedJinBi, "洗炼");
                }
                else if (moneyType == 1)
                {
                    GameManager.ClientMgr.SubUserMoney(client, xiLianShuXing.NeedZuanShi, "洗炼");
                }

                //从装备颜色获取洗炼类型配置,获取洗炼条目最大值
                int        color = Global.GetEquipColor(goodsData);
                XiLianType xiLianType;
                if (color <= 0 || !XiLianTypeDict.TryGetValue(color, out xiLianType) || xiLianType.ShuXingNum <= 0)
                {
                    result[1] = (StdErrorCode.Error_Invalid_Operation);
                    client.sendCmd(nID, result);
                    return(true);
                }

                //如果没有洗练属性,先生成一份
                if (null == goodsData.WashProps || goodsData.WashProps.Count == 0)
                {
                    List <int> washProps = new List <int>(xiLianType.ShuXingNum * 2);
                    int        maxCount  = xiLianType.ShuXingNum;
                    foreach (var kv in xiLianShuXing.PromotePropLimit)
                    {
                        if (kv.Value > 0)
                        {
                            washProps.Add(kv.Key);
                            washProps.Add(0);
                            if (--maxCount <= 0)
                            {
                                break;
                            }
                        }
                    }

                    ////索引值无效
                    //result[1] = (StdErrorCode.Error_Invalid_Operation);
                    //client.sendCmd(nID, result);
                    //return true;
                    updateGoodsArgs.WashProps = washProps;
                }
                else
                {
                    updateGoodsArgs.WashProps = new List <int>(goodsData.WashProps);
                }

                //洗炼数值
                for (int i = 0; i < updateGoodsArgs.WashProps.Count; i += 2)
                {
                    int propID = updateGoodsArgs.WashProps[i];
                    if (!xiLianShuXing.PromotePropLimit.ContainsKey(propID))
                    {
                        //错误的参数
                        result[1] = (StdErrorCode.Error_Config_Fault);
                        client.sendCmd(nID, result);
                        return(true);
                    }
                    int propValue = updateGoodsArgs.WashProps[i + 1];
                    int propLimit = (int)(xiLianShuXing.PromotePropLimit[propID] * xiLianType.ShuXingLimitMultiplying);
                    if (moneyType == UseMoneyTypes.JinBiOrBindJinBi)
                    {
                        int nRandNum = Global.GetRandomNumber(0, xiLianShuXing.PromoteJinBiRange[propID].Count);
                        propValue += (int)xiLianShuXing.PromoteJinBiRange[propID][nRandNum];
                    }
                    else if (moneyType == UseMoneyTypes.ZuanShi)
                    {
                        int nRandNum = Global.GetRandomNumber(0, xiLianShuXing.PromoteZuanShiRange[propID].Count);
                        propValue += (int)xiLianShuXing.PromoteZuanShiRange[propID][nRandNum];
                    }

                    propValue = Global.Clamp(propValue, 0, propLimit);
                    updateGoodsArgs.WashProps[i + 1] = propValue;
                }

                client.ClientData.TempWashPropsDict[updateGoodsArgs.DbID] = updateGoodsArgs;
                client.ClientData.TempWashPropOperationIndex = washIndex;

                result[3] = (goodsData.Binding > 0 | updateGoodsArgs.Binding > 0) ? 1 : 0;
                result.AddRange(updateGoodsArgs.WashProps);
                client.sendCmd(nID, result);
                return(true);
            }
            else if (washIndex == WashOperations.WashPropsCommit)
            {
                //提交洗练结果
                UpdateGoodsArgs tempWashProps;
                if (!client.ClientData.TempWashPropsDict.TryGetValue(goodsData.Id, out tempWashProps))
                {
                    //索引值无效
                    result[1] = (StdErrorCode.Error_Invalid_Index);
                    client.sendCmd(nID, result);
                    return(true);
                }

                Global.UpdateGoodsProp(client, goodsData, tempWashProps);
                //写入角色物品的得失行为日志(扩展)
                Global.ModRoleGoodsEvent(client, goodsData, 0, "装备洗炼");
                EventLogManager.AddGoodsEvent(client, OpTypes.Forge, OpTags.None, goodsData.GoodsID, goodsData.Id, 0, goodsData.GCount, "装备洗炼");

                client.ClientData.TempWashPropsDict.Remove(goodsData.Id);
                result[3] = (goodsData.Binding > 0) ? 1 : 0;
                result.AddRange(goodsData.WashProps);
                client.sendCmd(nID, result);
                return(true);
            }
            else if (washIndex == WashOperations.WashPropsCancle)
            {
                //取消本次洗炼,与提交(替换)相对
                client.ClientData.TempWashPropsDict.Remove(dbid);
                client.sendCmd(nID, result);
                return(true);
            }
            else if (washIndex == WashOperations.WashPropsQuery)
            {
                //查询未提交的洗炼结果
                UpdateGoodsArgs tempWashProps;
                if (!client.ClientData.TempWashPropsDict.TryGetValue(goodsData.Id, out tempWashProps))
                {
                    result[1] = StdErrorCode.Error_Data_Overdue;
                    client.sendCmd(nID, result);
                    return(true);
                }
                result[0] = client.ClientData.TempWashPropOperationIndex;
                result[2] = tempWashProps.DbID;
                result[3] = tempWashProps.Binding | goodsData.Binding;
                result.AddRange(tempWashProps.WashProps);
                client.sendCmd(nID, result);
                return(true);
            }
            else if (washIndex >= WashOperations.WashProps)
            {
                //洗练属性
                if (washIndex < 0 || null == goodsData.WashProps || goodsData.WashProps.Count / 2 <= washIndex)
                {
                    //索引值无效
                    result[1] = (StdErrorCode.Error_Invalid_Index);
                    client.sendCmd(nID, result);
                    return(true);
                }

                int        color = Global.GetEquipColor(goodsData);
                XiLianType xiLianType;
                if (color <= 0 || !XiLianTypeDict.TryGetValue(color, out xiLianType) || xiLianType.ShuXingNum <= washIndex)
                {
                    result[1] = (StdErrorCode.Error_Invalid_Operation);
                    client.sendCmd(nID, result);
                    return(true);
                }

                UpdateGoodsArgs updateGoodsArgs = new UpdateGoodsArgs()
                {
                    RoleID = client.ClientData.RoleID, DbID = dbid
                };
                updateGoodsArgs.WashProps = new List <int>(goodsData.WashProps);

                //扣除所需物品
                if (xiLianShuXing.NeedGoodsIDs[0] > 0 && xiLianShuXing.NeedGoodsCounts[0] > 0)
                {
                    bool bUsedBinding     = firstUseBinding;
                    bool bUsedTimeLimited = false;

                    //扣除物品
                    if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener,
                                                              Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, xiLianShuXing.NeedGoodsIDs[0], xiLianShuXing.NeedGoodsCounts[0], false, out bUsedBinding, out bUsedTimeLimited))
                    {
                        //索引值无效
                        result[1] = StdErrorCode.Error_Goods_Not_Enough;
                        client.sendCmd(nID, result);
                        return(true);
                    }
                    if (goodsData.Binding == 0 && bUsedBinding)
                    {
                        updateGoodsArgs.Binding = 1;
                    }
                }

                int rand      = Global.GetRandomNumber(0, PropsIds.Count);
                int propID    = PropsIds[rand];
                int propLimit = xiLianShuXing.PromotePropLimit[propID];
                int propValue = (int)Math.Ceiling(propLimit * xiLianType.FirstShuXing * xiLianType.ShuXingLimitMultiplying);

                updateGoodsArgs.WashProps[washIndex * 2]     = propID;
                updateGoodsArgs.WashProps[washIndex * 2 + 1] = propValue;

                client.ClientData.TempWashPropsDict[updateGoodsArgs.DbID] = updateGoodsArgs;
                client.ClientData.TempWashPropOperationIndex = washIndex;

                //通知结果
                result[3] = (goodsData.Binding > 0 | updateGoodsArgs.Binding > 0) ? 1 : 0;
                result.Add(propID);
                result.Add(propValue);
                client.sendCmd(nID, result);
                return(true);
            }
            else
            {
                //错误的参数
                result[1] = (StdErrorCode.Error_Invalid_Index);
                client.sendCmd(nID, result);
                return(true);
            }
        }
Ejemplo n.º 19
0
        public bool ProcessGetYongZheZhanChangAwardCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                int err = StdErrorCode.Error_Success;

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

                string awardsInfo = Global.GetRoleParamByName(client, RoleParamName.YongZheZhanChangAwards);
                if (!string.IsNullOrEmpty(awardsInfo))
                {
                    int lastGroupId = 0;
                    int score       = 0;
                    int success     = 0;
                    int sideScore1  = 0;
                    int sideScore2  = 0;
                    ConfigParser.ParseStrInt3(awardsInfo, ref lastGroupId, ref success, ref score);
                    List <int> awardsParamList = Global.StringToIntList(awardsInfo, ',');
                    lastGroupId = awardsParamList[0];
                    bool clear = true;
                    if (awardsParamList.Count >= 5 && lastGroupId > 0)
                    {
                        success    = awardsParamList[1];
                        score      = awardsParamList[2];
                        sideScore1 = awardsParamList[3];
                        sideScore2 = awardsParamList[4];

                        YongZheZhanChangSceneInfo lastSceneItem = null;
                        if (RuntimeData.SceneDataDict.TryGetValue(lastGroupId, out lastSceneItem))
                        {
                            err = GiveRoleAwards(client, success, score, lastSceneItem);
                            if (err < StdErrorCode.Error_Success_No_Info)
                            {
                                clear = false;
                            }
                        }
                    }

                    if (clear)
                    {
                        Global.SaveRoleParamsStringToDB(client, RoleParamName.YongZheZhanChangAwards, RuntimeData.RoleParamsAwardsDefaultString, true);
                    }

                    client.sendCmd(nID, err);
                }

                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
            }

            client.sendCmd(nID, StdErrorCode.Error_Success_No_Info);

            return(false);
        }
Ejemplo n.º 20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="client"></param>
        /// <param name="leftGoodsDbID">左边物品ID,提供传承属性的物品,传承提供者</param>
        /// <param name="rightGoodsDbID">右边物品ID,获得传承属性的物品,传承接受者</param>
        /// <param name="nSubMoneyType">消耗钱类型 -- 1银两 2元宝</param>
        /// <returns></returns>
        public static bool WashPropsInherit(GameClient client, int leftGoodsDbID, int rightGoodsDbID, int nSubMoneyType)
        {
            int        roleID = client.ClientData.RoleID;
            int        nID    = (int)TCPGameServerCmds.CMD_SPR_EXEC_WASHPROPSINHERIT;
            List <int> result = new List <int>();

            result.Add(StdErrorCode.Error_Success);
            result.Add(leftGoodsDbID);
            result.Add(rightGoodsDbID);
            result.Add(0);

            //从物品包中获取传承提供者装备
            GoodsData leftGoodsData = Global.GetGoodsByDbID(client, leftGoodsDbID);

            if (null == leftGoodsData) //没有找到物品
            {
                result[0] = StdErrorCode.Error_Invalid_DBID;
                client.sendCmd(nID, result);
                return(true);
            }

            //从物品包中获取传承接受者装备
            GoodsData rightGoodsData = Global.GetGoodsByDbID(client, rightGoodsDbID);

            if (null == rightGoodsData) //没有找到物品
            {
                result[0] = StdErrorCode.Error_Invalid_DBID;
                client.sendCmd(nID, result);
                return(true);
            }

            SystemXmlItem xml;

            if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(rightGoodsData.GoodsID, out xml))
            {
                //错误的参数
                result.Add(StdErrorCode.Error_Config_Fault);
                client.sendCmd(nID, result);
                return(true);
            }

            int           id = xml.GetIntValue("XiLian");
            XiLianShuXing xiLianShuXing;

            if (!XiLianShuXingDict.TryGetValue(id, out xiLianShuXing))
            {
                //配置错误
                result.Add(StdErrorCode.Error_Config_Fault);
                client.sendCmd(nID, result);
                return(true);
            }

            /* 规则:
             * 1.剥离追加的装备颜色不能低于继承追加的装备颜色
             * 2.剥离追加的装备追加级别不能低于继承追加的装备追加级别
             *
             */

            int nLeftColor  = Global.GetEquipColor(leftGoodsData);
            int nRigthColor = Global.GetEquipColor(rightGoodsData);

            if (nLeftColor < 2 || nRigthColor < 2 || null == leftGoodsData.WashProps /* || null == rightGoodsData.WashProps*/)
            {
                result[0] = StdErrorCode.Error_Operation_Denied;
                client.sendCmd(nID, result);
                return(true);
            }

            XiLianType xiLianType = null;

            if (!XiLianTypeDict.TryGetValue(nRigthColor, out xiLianType))
            {
                //配置错误
                result.Add(StdErrorCode.Error_Config_Fault);
                client.sendCmd(nID, result);
                return(true);
            }

            int OccupationLeft  = Global.GetMainOccupationByGoodsID(leftGoodsData.GoodsID);
            int OccupationRight = Global.GetMainOccupationByGoodsID(rightGoodsData.GoodsID);

            // 装备职业
            if (OccupationLeft != OccupationRight)
            {
                result[0] = StdErrorCode.Error_Operation_Denied;
                client.sendCmd(nID, result);
                return(true);
            }

            int categoryLeft  = Global.GetGoodsCatetoriy(leftGoodsData.GoodsID);
            int categoryRight = Global.GetGoodsCatetoriy(rightGoodsData.GoodsID);

            if (categoryLeft >= 0 && categoryLeft <= 6 && categoryLeft == categoryRight)
            {
                //装备类型相同
            }
            else if (categoryLeft == 10 && categoryLeft == categoryRight)
            {
                //装备类型相同
            }
            else if (categoryLeft >= (int)ItemCategories.WuQi_Jian && categoryLeft <= (int)ItemCategories.WuQi_NuJianTong &&
                     categoryRight >= (int)ItemCategories.WuQi_Jian && categoryRight <= (int)ItemCategories.WuQi_NuJianTong)
            {
                //11到21都算相同(武器类)
            }
            else
            {
                result[0] = StdErrorCode.Error_Type_Not_Match;
                client.sendCmd(nID, result);
                return(true);
            }

            //如果物品不在背包中,拒绝操作
            if (leftGoodsData.Site != 0 || rightGoodsData.Site != 0)
            {
                result[0] = StdErrorCode.Error_Goods_Not_Find;
                client.sendCmd(nID, result);
                return(true);
            }

            // 检测 银两或元宝
            if (nSubMoneyType < 1 || nSubMoneyType > 2)
            {
                result[0] = StdErrorCode.Error_MoneyType_Not_Select;
                client.sendCmd(nID, result);
                return(true);
            }

            if (nSubMoneyType == 1)
            {
                if (XiLianChuanChengXiaoHaoJinBi[0] > 0 && !Global.SubBindTongQianAndTongQian(client, XiLianChuanChengXiaoHaoJinBi[0], "洗练属性传承"))
                {
                    result[0] = StdErrorCode.Error_JinBi_Not_Enough;
                    client.sendCmd(nID, result);
                    return(true);
                }
            }
            else if (nSubMoneyType == 2)
            {
                if (XiLianChuanChengXiaoHaoZhuanShi[0] > 0 && !GameManager.ClientMgr.SubUserMoney(client, XiLianChuanChengXiaoHaoZhuanShi[0], "洗练属性传承"))
                {
                    result[0] = StdErrorCode.Error_ZuanShi_Not_Enough;
                    client.sendCmd(nID, result);
                    return(true);
                }
            }

            //判断是否有需要传承的属性,没有就不传承了 当前只传承 强化
            int nBinding = 0;

            if (rightGoodsData.Binding == 1 || leftGoodsData.Binding == 1)
            {
                nBinding = 1;
            }

            int rnd = Global.GetRandomNumber(0, 101);

            if (null != XiLianChuanChengGoodsRates && rnd > XiLianChuanChengGoodsRates[nLeftColor])
            {
                result[0] = StdErrorCode.Error_Operation_Faild;
                client.sendCmd(nID, result);
                return(true);
            }

            UpdateGoodsArgs argsLeft = new UpdateGoodsArgs()
            {
                RoleID = roleID, DbID = leftGoodsDbID
            };

            argsLeft.WashProps = new List <int>(leftGoodsData.WashProps);
            UpdateGoodsArgs argsRight = new UpdateGoodsArgs()
            {
                RoleID = roleID, DbID = rightGoodsDbID
            };

            //如果没有洗练属性,先生成一份
            if (null == rightGoodsData.WashProps || rightGoodsData.WashProps.Count == 0)
            {
                argsRight.WashProps = new List <int>(xiLianType.ShuXingNum * 2);

                int maxCount = 0;
                foreach (var kv in xiLianShuXing.PromotePropLimit)
                {
                    if (kv.Value > 0)
                    {
                        argsRight.WashProps.Add(kv.Key);
                        argsRight.WashProps.Add(0);

                        if (++maxCount >= xiLianType.ShuXingNum)
                        {
                            break;
                        }
                    }
                }
            }
            else
            {
                argsRight.WashProps = new List <int>(rightGoodsData.WashProps);
            }

            //尝试纠正错误的属性
            List <int> correctPropsList = new List <int>();

            for (int i = 0; i < argsRight.WashProps.Count - 1; i += 2)
            {
                int propID    = argsRight.WashProps[i];
                int propLimit = 0;

                //如果属性列表已经包含了一次(不应该重复),或这个装备的培养属性不应该有这个属性(上限为0),则重新随机个属性给他
                if (correctPropsList.Contains(propID) || !xiLianShuXing.PromotePropLimit.TryGetValue(propID, out propLimit) || propLimit <= 0)
                {
                    foreach (var kv in xiLianShuXing.PromotePropLimit)
                    {
                        if (kv.Value > 0)
                        {
                            argsRight.WashProps[i]     = kv.Key;
                            argsRight.WashProps[i + 1] = 0;
                            correctPropsList.Add(kv.Key);
                        }
                    }
                }
                else
                {
                    correctPropsList.Add(propID);
                }
            }

            //两层循环,找到两件装备对应的属性,并传承(之所以写这么复杂,是因为dictionary的foreach枚举顺序是没有保证的,虽然绝大多数情况下是不变的)
            List <int> inhertPropsList = new List <int>();

            for (int i = 0; i < argsLeft.WashProps.Count - 1; i += 2)
            {
                for (int j = 0; j < argsRight.WashProps.Count - 1; j += 2)
                {
                    if (argsLeft.WashProps[i] == argsRight.WashProps[j])
                    {
                        int propID    = argsLeft.WashProps[i];
                        int propLimit = 0;

                        inhertPropsList.Add(propID);
                        argsRight.WashProps[j] = propID;
                        if (xiLianShuXing.PromotePropLimit.TryGetValue(propID, out propLimit))
                        {
                            argsRight.WashProps[j + 1] = (int)Math.Round(Global.Clamp(argsLeft.WashProps[i + 1], 0, propLimit * xiLianType.ShuXingLimitMultiplying));
                        }
                        else
                        {
                            argsRight.WashProps[j + 1] = 0;
                        }
                    }
                }
            }

            //两层循环,找到两件装备不对应的装备(之所以写这么复杂,是因为dictionary的foreach枚举顺序是没有保证的,虽然绝大多数情况下是不变的)
            for (int i = 0; i < argsLeft.WashProps.Count - 1; i += 2)
            {
                if (!inhertPropsList.Contains(argsLeft.WashProps[i]))
                {
                    inhertPropsList.Add(argsLeft.WashProps[i]);
                    for (int j = 0; j < argsRight.WashProps.Count - 1; j += 2)
                    {
                        if (!inhertPropsList.Contains(argsRight.WashProps[j]))
                        {
                            inhertPropsList.Add(argsRight.WashProps[j]);

                            int propID    = argsRight.WashProps[j];
                            int propLimit = 0;

                            argsRight.WashProps[i] = propID;
                            if (xiLianShuXing.PromotePropLimit.TryGetValue(propID, out propLimit))
                            {
                                //击中恢复和附加攻击之间按比例1:10转换,其他的类型的值不能传承。
                                if (argsLeft.WashProps[i] == (int)ExtPropIndexes.LifeSteal && argsRight.WashProps[j] == (int)ExtPropIndexes.AddAttack)
                                {
                                    argsRight.WashProps[j + 1] = (int)Math.Floor(Global.Clamp(argsLeft.WashProps[i + 1] * 10, 0, propLimit * xiLianType.ShuXingLimitMultiplying));
                                }
                                else if (argsLeft.WashProps[i] == (int)ExtPropIndexes.AddAttack && argsRight.WashProps[j] == (int)ExtPropIndexes.LifeSteal)
                                {
                                    argsRight.WashProps[j + 1] = (int)Math.Floor(Global.Clamp(argsLeft.WashProps[i + 1] / 10, 0, propLimit * xiLianType.ShuXingLimitMultiplying));
                                }
                                else
                                {
                                    argsRight.WashProps[j + 1] = 0;
                                }
                            }
                            else
                            {
                                argsRight.WashProps[j + 1] = 0;
                            }
                        }
                    }
                }
            }

            argsLeft.WashProps = null;
            argsRight.Binding  = nBinding;

            //清除已传承装备的上次培养记录属性
            client.ClientData.TempWashPropsDict.Remove(argsLeft.DbID);
            client.ClientData.TempWashPropsDict.Remove(argsRight.DbID);

            if (Global.UpdateGoodsProp(client, leftGoodsData, argsLeft) < 0)
            {
                result[0] = StdErrorCode.Error_DB_Faild;
                client.sendCmd(nID, result);
                return(true);
            }
            if (Global.UpdateGoodsProp(client, rightGoodsData, argsRight) < 0)
            {
                result[0] = StdErrorCode.Error_DB_Faild;
                client.sendCmd(nID, result);
                return(true);
            }

            //写入角色物品的得失行为日志(扩展)
            Global.ModRoleGoodsEvent(client, leftGoodsData, 0, "装备洗炼传承_提供方");
            Global.ModRoleGoodsEvent(client, rightGoodsData, 0, "装备洗炼传承_接受方");
            EventLogManager.AddGoodsEvent(client, OpTypes.Forge, OpTags.None, leftGoodsData.GoodsID, leftGoodsData.Id, 0, leftGoodsData.GCount, "装备洗炼传承_提供方");
            EventLogManager.AddGoodsEvent(client, OpTypes.Forge, OpTags.None, rightGoodsData.GoodsID, rightGoodsData.Id, 0, rightGoodsData.GCount, "装备洗炼传承_接受方");

            //Global.BroadcastAppendChuanChengOk(client, leftGoodsData, rightGoodsData);

            //如果有物品是穿戴的,更新角色属性
            if (leftGoodsData.Using > 0 || rightGoodsData.Using > 0)
            {
                Global.RefreshEquipPropAndNotify(client);
            }

            // 更新成就
            //ChengJiuManager.OnFirstJiCheng(client);
            // 七日活动
            GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.EquipChuanChengTimes));

            result[3] = nBinding;
            result.AddRange(rightGoodsData.WashProps);
            client.sendCmd(nID, result);
            return(true);
        }
Ejemplo n.º 21
0
        public bool ProcessYongZheZhanChangEnterCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                int result = StdErrorCode.Error_Success_No_Info;

                // 如果1.7的功能没开放
                if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot7))
                {
                    client.sendCmd(nID, result);
                    return(true);
                }

                YongZheZhanChangSceneInfo  sceneItem = null;
                YongZheZhanChangGameStates state     = YongZheZhanChangGameStates.None;

                if (!CheckMap(client))
                {
                    result = StdErrorCode.Error_Denied_In_Current_Map;
                }
                else
                {
                    result = CheckCondition(client, ref sceneItem, ref state);
                }

                if (state == YongZheZhanChangGameStates.Start)
                {
                    KuaFuServerLoginData kuaFuServerLoginData = null;
                    lock (RuntimeData.Mutex)
                    {
                        if (RuntimeData.RoleIdKuaFuLoginDataDict.TryGetValue(client.ClientData.RoleID, out kuaFuServerLoginData))
                        {
                            KuaFuServerLoginData clientKuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client);
                            if (null != clientKuaFuServerLoginData)
                            {
                                clientKuaFuServerLoginData.RoleId     = kuaFuServerLoginData.RoleId;
                                clientKuaFuServerLoginData.GameId     = kuaFuServerLoginData.GameId;
                                clientKuaFuServerLoginData.GameType   = kuaFuServerLoginData.GameType;
                                clientKuaFuServerLoginData.EndTicks   = kuaFuServerLoginData.EndTicks;
                                clientKuaFuServerLoginData.ServerId   = kuaFuServerLoginData.ServerId;
                                clientKuaFuServerLoginData.ServerIp   = kuaFuServerLoginData.ServerIp;
                                clientKuaFuServerLoginData.ServerPort = kuaFuServerLoginData.ServerPort;
                                clientKuaFuServerLoginData.FuBenSeqId = kuaFuServerLoginData.FuBenSeqId;
                            }
                        }
                        else
                        {
                            result = StdErrorCode.Error_Server_Busy;
                        }
                    }

                    if (result >= 0)
                    {
                        result = YongZheZhanChangClient.getInstance().ChangeRoleState(client.ClientData.RoleID, KuaFuRoleStates.EnterGame);
                        if (result >= 0)
                        {
                            GlobalNew.RecordSwitchKuaFuServerLog(client);
                            client.sendCmd((int)TCPGameServerCmds.CMD_SPR_KF_SWITCH_SERVER, Global.GetClientKuaFuServerLoginData(client));
                        }
                        else
                        {
                            Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
                        }
                    }
                }
                else
                {
                    result = StdErrorCode.Error_Not_In_valid_Time;
                }

                client.sendCmd(nID, result);
                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
            }

            return(false);
        }
Ejemplo n.º 22
0
 public void GiveAwards(CopyWolfSceneInfo scene, int leftSecond)
 {
     try
     {
         FuBenMapItem fuBenMapItem = FuBenManager.FindMapCodeByFuBenID(scene.CopyMapInfo.FubenMapID, scene.MapID);
         if (fuBenMapItem != null)
         {
             int zhanLi = 0;
             List <GameClient> objsList = scene.CopyMapInfo.GetClientsList();
             if (objsList != null && objsList.Count > 0)
             {
                 for (int i = 0; i < objsList.Count; i++)
                 {
                     GameClient client = objsList[i];
                     if (client != null && client == GameManager.ClientMgr.FindClient(client.ClientData.RoleID))
                     {
                         int wave = scene.MonsterWaveOld;
                         if (wave > scene.MonsterWaveTotal)
                         {
                             wave = scene.MonsterWaveTotal;
                         }
                         int  scoreMonster = scene.GetMonsterScore(client.ClientData.RoleID);
                         int  life         = scene.ScoreData.FortLifeNow;
                         int  scoreAll     = this.GetScore(scoreMonster, leftSecond, life);
                         long nExp         = (long)this.AwardExp(fuBenMapItem.Experience, scoreAll);
                         int  money        = this.AwardGoldBind(fuBenMapItem.Money1, scoreAll);
                         int  wolfMoney    = this.AwardWolfMoney(fuBenMapItem.WolfMoney, scoreAll);
                         if (nExp > 0L)
                         {
                             GameManager.ClientMgr.ProcessRoleExperience(client, nExp, false, true, false, "none");
                         }
                         if (money > 0)
                         {
                             GameManager.ClientMgr.AddMoney1(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, money, string.Format("副本{0}通关奖励", scene.CopyID), false);
                         }
                         if (wolfMoney > 0)
                         {
                             GameManager.ClientMgr.ModifyLangHunFenMoValue(client, wolfMoney, "狼魂要塞", true, true);
                         }
                         CopyWolfAwardsData awardsData = new CopyWolfAwardsData
                         {
                             Wave      = scene.MonsterWaveOld,
                             Exp       = nExp,
                             Money     = money,
                             WolfMoney = wolfMoney,
                             RoleScore = scene.GetMonsterScore(client.ClientData.RoleID)
                         };
                         GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 1, 0, 11);
                         client.sendCmd <CopyWolfAwardsData>(1026, awardsData, false);
                         zhanLi += client.ClientData.CombatForce;
                         Global.UpdateFuBenDataForQuickPassTimer(client, scene.CopyMapInfo.FubenMapID, 0, 1);
                     }
                 }
             }
             if (objsList != null && objsList.Count > 0)
             {
                 int roleCount = objsList.Count;
                 zhanLi /= roleCount;
             }
         }
     }
     catch (Exception ex)
     {
         DataHelper.WriteExceptionLogEx(ex, "【狼魂要塞】清场调度异常");
     }
 }
Ejemplo n.º 23
0
 public bool ProcessJueXingJiHuoCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         if (!CheckHelper.CheckCmdLengthAndRole(client, nID, cmdParams, 3))
         {
             return(false);
         }
         int            suitID  = Convert.ToInt32(cmdParams[1]);
         int            stoneID = Convert.ToInt32(cmdParams[2]);
         TaoZhuang      taoZhuang;
         int            result;
         JueXingShiItem jueXingItem;
         if (!this.JueXingRunTimeData.TaoZhuangDict.TryGetValue(suitID, out taoZhuang))
         {
             result = -2;
         }
         else if (!this.JueXingRunTimeData.JueXingShiDict.TryGetValue(stoneID, out jueXingItem))
         {
             result = -2;
         }
         else if (jueXingItem.SuitParent != suitID)
         {
             result = -5;
         }
         else
         {
             JueXingShiData       jueXingData = client.ClientData.JueXingData;
             List <TaoZhuangData> jueXingList = jueXingData.TaoZhuangList;
             TaoZhuangData        suitData    = jueXingList.Find((TaoZhuangData _g) => _g.ID == suitID);
             if (null == suitData)
             {
                 suitData = new TaoZhuangData
                 {
                     ID           = suitID,
                     ActiviteList = new List <int>()
                 };
                 jueXingList.Add(suitData);
             }
             if (suitData.ActiviteList.Contains(stoneID))
             {
                 result = -1;
             }
             else
             {
                 int  needGoods = jueXingItem.NeedGoodsID;
                 int  needNum   = jueXingItem.NeedGoodsNum;
                 bool usedBinding;
                 bool usedTimeLimited;
                 if (Global.UseGoodsBindOrNot(client, needGoods, needNum, true, out usedBinding, out usedTimeLimited) < 1)
                 {
                     result = -3;
                 }
                 else
                 {
                     suitData.ActiviteList.Add(stoneID);
                     string strcmd = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, suitID, string.Join <int>(",", suitData.ActiviteList));
                     result = Global.sendToDB <int, string>(20318, strcmd, client.ServerId);
                     Global.RefreshEquipProp(client);
                     GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
                     GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7);
                 }
             }
         }
         client.sendCmd(nID, string.Format("{0}:{1}:{2}", result, suitID, stoneID), false);
         return(true);
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Error, string.Format("JueXing :: 激活觉醒石错误。rid:{0}, ex:{1}", client.ClientData.RoleID, ex.Message), null, true);
     }
     return(false);
 }
Ejemplo n.º 24
0
        /// <summary>
        /// 给奖励
        /// </summary>
        public void GiveAwards(CopyWolfSceneInfo scene, int leftSecond)
        {
            try
            {
                FuBenMapItem fuBenMapItem = FuBenManager.FindMapCodeByFuBenID(scene.CopyMapInfo.FubenMapID, scene.MapID);
                if (fuBenMapItem == null)
                {
                    return;
                }

                int zhanLi = 0;
                List <GameClient> objsList = scene.CopyMapInfo.GetClientsList();
                if (objsList != null && objsList.Count > 0)
                {
                    for (int n = 0; n < objsList.Count; ++n)
                    {
                        GameClient client = objsList[n];
                        if (client != null && client == GameManager.ClientMgr.FindClient(client.ClientData.RoleID)) //确认角色仍然在线
                        {
                            int wave = scene.MonsterWaveOld;
                            if (wave > scene.MonsterWaveTotal)
                            {
                                wave = scene.MonsterWaveTotal;
                            }

                            int scoreMonster = scene.GetMonsterScore(client.ClientData.RoleID);
                            int life         = scene.ScoreData.FortLifeNow;
                            int scoreAll     = GetScore(scoreMonster, leftSecond, life);

                            // 公式
                            long nExp      = AwardExp(fuBenMapItem.Experience, scoreAll);
                            int  money     = AwardGoldBind(fuBenMapItem.Money1, scoreAll);
                            int  wolfMoney = AwardWolfMoney(fuBenMapItem.WolfMoney, scoreAll);

                            if (nExp > 0)
                            {
                                GameManager.ClientMgr.ProcessRoleExperience(client, nExp, false);
                            }

                            if (money > 0)
                            {
                                GameManager.ClientMgr.AddMoney1(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, money, string.Format("副本{0}通关奖励", scene.CopyID), false);
                            }

                            if (wolfMoney > 0)
                            {
                                GameManager.ClientMgr.ModifyLangHunFenMoValue(client, wolfMoney, "狼魂要塞", true);
                            }

                            CopyWolfAwardsData awardsData = new CopyWolfAwardsData()
                            {
                                Wave      = scene.MonsterWaveOld,
                                Exp       = nExp,
                                Money     = money,
                                WolfMoney = wolfMoney,
                                RoleScore = scene.GetMonsterScore(client.ClientData.RoleID)
                            };

                            //AddElementWarCount(client);
                            GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 1, 0, (int)_gameType);

                            client.sendCmd((int)TCPGameServerCmds.CMD_SPR_COPY_WOLF_AWARD, awardsData);

                            zhanLi += client.ClientData.CombatForce;
                            Global.UpdateFuBenDataForQuickPassTimer(client, scene.CopyMapInfo.FubenMapID, 0, 1);
                        }
                    }
                }

                int roleCount = 0;
                if (objsList != null && objsList.Count > 0)
                {
                    roleCount = objsList.Count;
                    zhanLi    = zhanLi / roleCount;
                }

                // ElementWarClient.getInstance().UpdateCopyPassEvent(scene.FuBenSeqId, roleCount, scene.MonsterWaveOld, zhanLi);
            }
            catch (System.Exception ex)
            {
                DataHelper.WriteExceptionLogEx(ex, "【狼魂要塞】清场调度异常");
            }
        }
Ejemplo n.º 25
0
 public bool ProcessHuiShouCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         if (!this.JueXingRunTimeData.MoHuaOpen)
         {
             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);
             return(true);
         }
         if (!CheckHelper.CheckCmdLengthAndRole(client, nID, cmdParams, 2))
         {
             return(false);
         }
         int result = 0;
         foreach (string one in cmdParams[1].Split(new char[]
         {
             '|'
         }))
         {
             string[] oneStr = one.Split(new char[]
             {
                 ','
             });
             if (oneStr.Length < 3)
             {
                 break;
             }
             int goodsID  = Convert.ToInt32(oneStr[0]);
             int goodsNum = Convert.ToInt32(oneStr[1]);
             int binding  = Convert.ToInt32(oneStr[2]);
             int addVal   = 0;
             if (!this.JueXingRunTimeData.AwakenRecoveryDict.TryGetValue(goodsID, out addVal))
             {
                 result = -2;
                 break;
             }
             addVal *= goodsNum;
             if (binding > 0)
             {
                 if (Global.GetTotalBindGoodsCountByID(client, goodsID) < goodsNum)
                 {
                     result = -10;
                     break;
                 }
                 bool useBinding;
                 bool useTimeLimit;
                 if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodsID, goodsNum, false, out useBinding, out useTimeLimit, false))
                 {
                     result = -10;
                     break;
                 }
             }
             else if (binding < 1)
             {
                 if (Global.GetTotalNotBindGoodsCountByID(client, goodsID) < goodsNum)
                 {
                     result = -10;
                     break;
                 }
                 bool useBinding;
                 bool useTimeLimit;
                 if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodsID, goodsNum, false, out useBinding, out useTimeLimit, false))
                 {
                     result = -10;
                     break;
                 }
             }
             GameManager.ClientMgr.ModifyJueXingZhiChenValue(client, addVal, "碎片分解增加觉醒之尘", true, true, false);
         }
         client.sendCmd(nID, string.Format("{0}", result), false);
         return(true);
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Error, string.Format("JueXing :: 觉醒魔化错误。rid:{0}, ex:{1}", client.ClientData.RoleID, ex.Message), null, true);
     }
     return(false);
 }
Ejemplo n.º 26
0
 public void GiveAwards(ElementWarScene scene)
 {
     try
     {
         FuBenMapItem fuBenMapItem = FuBenManager.FindMapCodeByFuBenID(scene.CopyMapInfo.FubenMapID, scene.MapID);
         if (fuBenMapItem != null)
         {
             int zhanLi = 0;
             List <GameClient> objsList = scene.CopyMapInfo.GetClientsList();
             if (objsList != null && objsList.Count > 0)
             {
                 for (int i = 0; i < objsList.Count; i++)
                 {
                     GameClient client = objsList[i];
                     if (client != null && client == GameManager.ClientMgr.FindClient(client.ClientData.RoleID))
                     {
                         long nExp  = (long)fuBenMapItem.Experience;
                         int  money = fuBenMapItem.Money1;
                         int  wave  = scene.MonsterWaveOld;
                         int  light = fuBenMapItem.LightAward + this._runtimeData.AwardLight[wave];
                         int  ysfm  = fuBenMapItem.YuanSuFenMoaward + this._runtimeData.YuanSuShiLianAward2[wave];
                         if (nExp > 0L)
                         {
                             GameManager.ClientMgr.ProcessRoleExperience(client, nExp, false, true, false, "none");
                         }
                         if (money > 0)
                         {
                             GameManager.ClientMgr.AddMoney1(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, money, string.Format("副本{0}通关奖励", scene.CopyID), false);
                         }
                         if (light > 0)
                         {
                             GameManager.FluorescentGemMgr.AddFluorescentPoint(client, light, "元素试炼", true);
                         }
                         if (ysfm > 0)
                         {
                             GameManager.ClientMgr.ModifyYuanSuFenMoValue(client, ysfm, "元素试炼", true, false);
                         }
                         ElementWarAwardsData awardsData = new ElementWarAwardsData
                         {
                             Wave  = scene.MonsterWaveOld,
                             Exp   = nExp,
                             Money = money,
                             Light = light,
                             ysfm  = ysfm
                         };
                         this.AddElementWarCount(client);
                         GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 1, 0, 4);
                         client.sendCmd <ElementWarAwardsData>(1015, awardsData, false);
                         zhanLi += client.ClientData.CombatForce;
                         Global.UpdateFuBenDataForQuickPassTimer(client, scene.CopyMapInfo.FubenMapID, 0, 1);
                     }
                 }
             }
             if (objsList != null && objsList.Count > 0)
             {
                 int roleCount = objsList.Count;
                 zhanLi /= roleCount;
             }
         }
     }
     catch (Exception ex)
     {
         DataHelper.WriteExceptionLogEx(ex, "【元素试炼】清场调度异常");
     }
 }
Ejemplo n.º 27
0
 public bool ProcessAlchemyExcuteCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         int result      = 0;
         int roleID      = Convert.ToInt32(cmdParams[0]);
         int alchemyType = Convert.ToInt32(cmdParams[1]);
         if (alchemyType != 0 && alchemyType != 1)
         {
             return(true);
         }
         string alchemyProp = "";
         if (alchemyType == 0)
         {
             if (client.ClientData.AlchemyInfo.BaseData.Element < this.LevelUpElement)
             {
                 result = -12;
                 client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
                 {
                     result,
                     roleID,
                     client.ClientData.AlchemyInfo.BaseData.Element,
                     alchemyProp
                 }), false);
                 return(true);
             }
             int prop = this.RandomAlchemyProp(client);
             alchemyProp = string.Format("{0}", prop);
             int propNum = 0;
             client.ClientData.AlchemyInfo.BaseData.AlchemyValue.TryGetValue(prop, out propNum);
             propNum = (client.ClientData.AlchemyInfo.BaseData.AlchemyValue[prop] = propNum + 1);
             GameManager.ClientMgr.ModifyAlchemyElementValue(client, -this.LevelUpElement, "炼金", false, false);
         }
         else
         {
             if (client.ClientData.AlchemyInfo.BaseData.Element < this.LevelUpElement * 10)
             {
                 result = -12;
                 client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
                 {
                     result,
                     roleID,
                     client.ClientData.AlchemyInfo.BaseData.Element,
                     alchemyProp
                 }), false);
                 return(true);
             }
             for (int loop = 0; loop < 10; loop++)
             {
                 int prop = this.RandomAlchemyProp(client);
                 alchemyProp += string.Format("{0}|", prop);
                 int propNum = 0;
                 client.ClientData.AlchemyInfo.BaseData.AlchemyValue.TryGetValue(prop, out propNum);
                 propNum = (client.ClientData.AlchemyInfo.BaseData.AlchemyValue[prop] = propNum + 1);
             }
             GameManager.ClientMgr.ModifyAlchemyElementValue(client, -this.LevelUpElement * 10, "炼金", false, false);
         }
         this.RefreshAlchemyProps(client);
         this.UpdateAlchemyDataDB(client);
         if (!string.IsNullOrEmpty(alchemyProp) && alchemyProp.Substring(alchemyProp.Length - 1) == "|")
         {
             alchemyProp = alchemyProp.Substring(0, alchemyProp.Length - 1);
         }
         client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
         {
             result,
             roleID,
             client.ClientData.AlchemyInfo.BaseData.Element,
             alchemyProp
         }), false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Ejemplo n.º 28
0
        public void processEvent(EventObjectEx eventObject)
        {
            switch (eventObject.EventType)
            {
            case 10000:
            {
                KuaFuFuBenRoleCountEvent e = eventObject as KuaFuFuBenRoleCountEvent;
                if (null != e)
                {
                    GameClient client = GameManager.ClientMgr.FindClient(e.RoleId);
                    if (null != client)
                    {
                        client.sendCmd <int>(1013, e.RoleCount, false);
                    }
                    eventObject.Handled = true;
                }
                break;
            }

            case 10001:
            {
                KuaFuNotifyEnterGameEvent e2 = eventObject as KuaFuNotifyEnterGameEvent;
                if (null != e2)
                {
                    KuaFuServerLoginData kuaFuServerLoginData = e2.Arg as KuaFuServerLoginData;
                    if (null != kuaFuServerLoginData)
                    {
                        GameClient client = GameManager.ClientMgr.FindClient(kuaFuServerLoginData.RoleId);
                        if (null != client)
                        {
                            KuaFuServerLoginData clientKuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client);
                            if (null != clientKuaFuServerLoginData)
                            {
                                clientKuaFuServerLoginData.RoleId     = kuaFuServerLoginData.RoleId;
                                clientKuaFuServerLoginData.GameId     = kuaFuServerLoginData.GameId;
                                clientKuaFuServerLoginData.GameType   = kuaFuServerLoginData.GameType;
                                clientKuaFuServerLoginData.EndTicks   = kuaFuServerLoginData.EndTicks;
                                clientKuaFuServerLoginData.ServerId   = kuaFuServerLoginData.ServerId;
                                clientKuaFuServerLoginData.ServerIp   = kuaFuServerLoginData.ServerIp;
                                clientKuaFuServerLoginData.ServerPort = kuaFuServerLoginData.ServerPort;
                                clientKuaFuServerLoginData.FuBenSeqId = kuaFuServerLoginData.FuBenSeqId;
                                client.sendCmd(1012, string.Format("{0}:{1}", kuaFuServerLoginData.GameId, e2.TeamCombatAvg), false);
                            }
                        }
                    }
                    eventObject.Handled = true;
                }
                break;
            }

            case 10004:
            {
                KuaFuNotifyCopyCancelEvent e3 = eventObject as KuaFuNotifyCopyCancelEvent;
                GameClient client             = GameManager.ClientMgr.FindClient(e3.RoleId);
                if (client != null)
                {
                    client.ClientData.SignUpGameType = 0;
                    client.sendCmd(1016, string.Format("{0}:{1}", e3.GameId, e3.Reason), false);
                }
                eventObject.Handled = true;
                break;
            }

            case 10005:
            {
                KuaFuNotifyRealEnterGameEvent e4 = eventObject as KuaFuNotifyRealEnterGameEvent;
                if (e4 != null)
                {
                    GameClient client = GameManager.ClientMgr.FindClient(e4.RoleId);
                    if (client != null)
                    {
                        client.ClientData.SignUpGameType = 0;
                        GlobalNew.RecordSwitchKuaFuServerLog(client);
                        client.sendCmd <KuaFuServerLoginData>(14000, Global.GetClientKuaFuServerLoginData(client), false);
                    }
                }
                eventObject.Handled = true;
                break;
            }
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 给奖励
        /// </summary>
        public void GiveAwards(ElementWarScene scene)
        {
            try
            {
                FuBenMapItem fuBenMapItem = FuBenManager.FindMapCodeByFuBenID(scene.CopyMapInfo.FubenMapID, scene.MapID);
                if (fuBenMapItem == null)
                {
                    return;
                }

                //FuBenInfoItem fuBenInfoItem = FuBenManager.FindFuBenInfoBySeqID(scene.FuBenSeqId);
                //if (null == fuBenInfoItem) return;

                //fuBenInfoItem.EndTicks = TimeUtil.NOW();
                //int addFuBenNum = 1;
                //if (fuBenInfoItem.nDayOfYear != TimeUtil.NowDateTime().DayOfYear)
                //    addFuBenNum = 0;

                //int usedSecs = (int)(scene.EndTime - scene.BeginTime);

                int zhanLi = 0;
                List <GameClient> objsList = scene.CopyMapInfo.GetClientsList();
                if (objsList != null && objsList.Count > 0)
                {
                    for (int n = 0; n < objsList.Count; ++n)
                    {
                        GameClient client = objsList[n];
                        if (client != null && client == GameManager.ClientMgr.FindClient(client.ClientData.RoleID)) //确认角色仍然在线
                        {
                            // 公式
                            long nExp  = fuBenMapItem.Experience;
                            int  money = fuBenMapItem.Money1;

                            int wave = scene.MonsterWaveOld;
                            if (wave > 0)
                            {
                                wave -= 1;
                            }
                            int light = fuBenMapItem.LightAward + _runtimeData.AwardLight[wave];

                            if (nExp > 0)
                            {
                                GameManager.ClientMgr.ProcessRoleExperience(client, nExp, false);
                            }

                            if (money > 0)
                            {
                                GameManager.ClientMgr.AddMoney1(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, money, string.Format(/**/ "副本{0}通关奖励", scene.CopyID), false);
                            }

                            if (light > 0)
                            {
                                GameManager.FluorescentGemMgr.AddFluorescentPoint(client, light, "元素试炼");
                            }


                            ElementWarAwardsData awardsData = new ElementWarAwardsData()
                            {
                                Wave  = scene.MonsterWaveOld,
                                Exp   = nExp,
                                Money = money,
                                Light = light
                            };

                            AddElementWarCount(client);
                            GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 1, 0, (int)_gameType);

                            client.sendCmd((int)TCPGameServerCmds.CMD_SPR_ELEMENT_WAR_AWARD, awardsData);


                            zhanLi += client.ClientData.CombatForce;

                            Global.UpdateFuBenDataForQuickPassTimer(client, scene.CopyMapInfo.FubenMapID, 0, 1);
                        }
                    }
                }

                int roleCount = 0;
                if (objsList != null && objsList.Count > 0)
                {
                    roleCount = objsList.Count;
                    zhanLi    = zhanLi / roleCount;
                }

                // ElementWarClient.getInstance().UpdateCopyPassEvent(scene.FuBenSeqId, roleCount, scene.MonsterWaveOld, zhanLi);
            }
            catch (System.Exception ex)
            {
                DataHelper.WriteExceptionLogEx(ex, "【元素试炼】清场调度异常");
            }
        }
Ejemplo n.º 30
0
        public static void TimerProc()
        {
            if (!GameManager.IsKuaFuServer)
            {
                long nowTicks = TimeUtil.NOW();
                lock (ZhuanShengShiLian.ZhuanShengRunTimeData.Mutex)
                {
                    if (Math.Abs(nowTicks - ZhuanShengShiLian.LastHeartBeatTicks) < 1000L)
                    {
                        return;
                    }
                    ZhuanShengShiLian.LastHeartBeatTicks = nowTicks;
                }
                if (157 == ZhuanShengShiLian.ZhuanShengRunTimeData.ThemeZSActivity.ActivityType && ZhuanShengShiLian.ZhuanShengRunTimeData.ThemeZSActivity.InActivityTime())
                {
                    foreach (KeyValuePair <int, ZSSLScene> scenes in ZhuanShengShiLian.SceneDict)
                    {
                        lock (ZhuanShengShiLian.ZhuanShengRunTimeData.Mutex)
                        {
                            switch (scenes.Value.State)
                            {
                            case BattleStates.NoBattle:
                            {
                                DateTime startTime = DateTime.Parse(scenes.Value.SceneInfo.TimePoints[0]).AddSeconds((double)scenes.Value.SceneInfo.ReadyTime);
                                scenes.Value.StartTick     = startTime.Ticks / 10000L;
                                scenes.Value.EndTick       = startTime.AddSeconds((double)scenes.Value.SceneInfo.FightSecs).Ticks / 10000L;
                                scenes.Value.StatusEndTime = scenes.Value.StartTick;
                                ZhuanShengShiLian.BroadMsg(scenes.Value.SceneInfo.MapCode, GLang.GetLang(4010, new object[0]));
                                scenes.Value.State = BattleStates.WaitingFight;
                                break;
                            }

                            case BattleStates.WaitingFight:
                                if (nowTicks >= scenes.Value.StartTick && null != scenes.Value.m_CopyMap)
                                {
                                    GameManager.MonsterZoneMgr.AddDynamicMonsters(scenes.Value.SceneInfo.MapCode, scenes.Value.SceneInfo.MonstersID, scenes.Value.m_CopyMap.FuBenSeqID, 1, scenes.Value.SceneInfo.BornX / 100, scenes.Value.SceneInfo.BornY / 100, 0, 0, SceneUIClasses.Normal, null, null);
                                    scenes.Value.State         = BattleStates.StartFight;
                                    scenes.Value.StatusEndTime = scenes.Value.EndTick;
                                    ZhuanShengShiLian.SendTimeInfoToAll(scenes.Value, nowTicks);
                                }
                                break;

                            case BattleStates.StartFight:
                                if (nowTicks >= scenes.Value.EndTick)
                                {
                                    scenes.Value.State         = BattleStates.EndFight;
                                    scenes.Value.StatusEndTime = scenes.Value.EndTick;
                                    scenes.Value.BossDie       = false;
                                    List <object> monsterList = GameManager.MonsterMgr.GetObjectsByMap(scenes.Value.SceneInfo.MapCode);
                                    foreach (object monster in monsterList)
                                    {
                                        if (monster is Monster)
                                        {
                                            GameManager.MonsterMgr.DeadMonsterImmediately(monster as Monster);
                                        }
                                    }
                                }
                                break;

                            case BattleStates.EndFight:
                                try
                                {
                                    List <ShiLianReward> rewardList;
                                    if (ZhuanShengShiLian.ZhuanShengRunTimeData.ShiLianRewardDict.TryGetValue(scenes.Value.SceneInfo.MapCode, out rewardList))
                                    {
                                        List <BHAttackLog> bhAttackLogList = scenes.Value.AttackLog.BHInjure.Values.ToList <BHAttackLog>();
                                        int i;
                                        for (i = 0; i < bhAttackLogList.Count; i++)
                                        {
                                            if (bhAttackLogList[i].BHInjure > 0L)
                                            {
                                                int rank = scenes.Value.AttackLog.BHAttackRank.FindIndex((BHAttackLog x) => object.ReferenceEquals(x, bhAttackLogList[i]));
                                                rank++;
                                                ShiLianReward reward = rewardList.Find((ShiLianReward _x) => _x.MinRank <= rank && (rank <= _x.MaxRank || _x.MaxRank < 0));
                                                if (null != reward)
                                                {
                                                    int    exp   = scenes.Value.BossDie ? reward.WinrewardExp : reward.LoseRewardExp;
                                                    int    money = scenes.Value.BossDie ? reward.WinRewardMoney : reward.LoseRewardMoney;
                                                    string goods = scenes.Value.BossDie ? reward.WinRewardItem : reward.LoseRewardItem;
                                                    foreach (KeyValuePair <int, long> role in bhAttackLogList[i].RoleInjure)
                                                    {
                                                        GameClient client = GameManager.ClientMgr.FindClient(role.Key);
                                                        if (null != client)
                                                        {
                                                            if (client.ClientData.MapCode == scenes.Value.SceneInfo.MapCode)
                                                            {
                                                                GameManager.ClientMgr.ProcessRoleExperience(client, (long)exp, false, true, false, "none");
                                                                GameManager.ClientMgr.AddMoney1(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, money, "转生试炼添加绑金", true);
                                                                ZhuanShengShiLian.GiveGoodsAward(client, goods);
                                                                client.sendCmd(1908, string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
                                                                {
                                                                    scenes.Value.BossDie ? 1 : 0,
                                                                    goods,
                                                                    exp,
                                                                    money,
                                                                    rank
                                                                }), false);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    scenes.Value.AttackLog = null;
                                }
                                catch (Exception ex)
                                {
                                    DataHelper.WriteExceptionLogEx(ex, "转生试炼调度异常");
                                }
                                scenes.Value.ClearTick     = nowTicks + (long)(scenes.Value.SceneInfo.ClearRolesSecs * 1000);
                                scenes.Value.StatusEndTime = scenes.Value.ClearTick;
                                scenes.Value.State         = BattleStates.ClearBattle;
                                ZhuanShengShiLian.SendTimeInfoToAll(scenes.Value, nowTicks);
                                break;

                            case BattleStates.ClearBattle:
                                if (nowTicks >= scenes.Value.ClearTick)
                                {
                                    List <GameClient> objsList = scenes.Value.m_CopyMap.GetClientsList();
                                    if (objsList != null && objsList.Count > 0)
                                    {
                                        for (int j = 0; j < objsList.Count; j++)
                                        {
                                            GameClient client = objsList[j];
                                            if (client != null)
                                            {
                                                int toMapCode = GameManager.MainMapCode;
                                                int toPosX    = -1;
                                                int toPosY    = -1;
                                                if (client.ClientData.LastMapCode != -1 && client.ClientData.LastPosX != -1 && client.ClientData.LastPosY != -1)
                                                {
                                                    if (MapTypes.Normal == Global.GetMapType(client.ClientData.LastMapCode))
                                                    {
                                                        toMapCode = client.ClientData.LastMapCode;
                                                        toPosX    = client.ClientData.LastPosX;
                                                        toPosY    = client.ClientData.LastPosY;
                                                    }
                                                }
                                                GameMap gameMap = null;
                                                if (GameManager.MapMgr.DictMaps.TryGetValue(toMapCode, out gameMap))
                                                {
                                                    GameManager.ClientMgr.NotifyChangeMap(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, toMapCode, toPosX, toPosY, -1, 0);
                                                }
                                            }
                                        }
                                    }
                                    scenes.Value.State = BattleStates.NoBattle;
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }