Beispiel #1
0
 private void AddBattleBufferAndFlags(GameClient client)
 {
     double[] actionParams = new double[]
     {
         85200.0,
         2000800.0
     };
     client.ClientData.BattleNameStart = TimeUtil.NOW();
     client.ClientData.BattleNameIndex = 1;
     Global.RemoveBufferData(client, 24);
     Global.RemoveBufferData(client, 26);
     Global.RemoveBufferData(client, 25);
     Global.UpdateBufferData(client, BufferItemTypes.PKKingBuffer, actionParams, 0, true);
     GameManager.DBCmdMgr.AddDBCmd(10059, string.Format("{0}:{1}:{2}", client.ClientData.RoleID, client.ClientData.BattleNameStart, client.ClientData.BattleNameIndex), null, client.ServerId);
     GameManager.ClientMgr.NotifyRoleBattleNameInfo(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client);
     GameManager.ClientMgr.UpdateBattleNum(client, 1, false);
     HuodongCachingMgr.UpdateHeFuPKKingRoleID(client.ClientData.RoleID);
     EventLogManager.AddTitleEvent(client, 1, (int)actionParams[0], "pkKing");
 }
        /// <summary>
        /// <summary>
        /// 新的王城帮会
        /// 2.1若在结束前,王城已有归属,且当前皇宫内成为拥有多个行会的成员或者无人在皇宫中,则王城胜利方属于王城原有归属
        /// 2.2若在结束前,王城无归属,且皇宫内所有成员均为一个行会的成员,则该行会将成为本次王城战的胜利方
        /// 2.3王城战结束时间到后,若之前王城为无归属状态,且皇宫内成员非同一个行会或者无人在皇宫中,则本次王城战流产
        /// </summary>
        /// 尝试产生新帮会[拥有王城所有权的帮会]
        /// </summary>
        /// <returns></returns>
        public bool TryGenerateNewHuangChengBangHui(LangHunLingYuScene scene)
        {
            int newBHid       = 0;
            int newBHServerID = 0;

            GetTheOnlyOneBangHui(scene, out newBHid, out newBHServerID);
            lock (RuntimeData.Mutex)
            {
                //剩下的帮会是王城帮会,没有产生新帮会
                if (newBHid <= 0 || newBHid == scene.LongTaOwnerData.OwnerBHid)
                {
                    scene.LastTheOnlyOneBangHui = 0;
                    return(false);
                }

                //这次的新帮会和上次不一样,替换,并记录时间
                if (scene.LastTheOnlyOneBangHui != newBHid)
                {
                    scene.LastTheOnlyOneBangHui     = newBHid;
                    scene.BangHuiTakeHuangGongTicks = TimeUtil.NOW();

                    //还是没产生
                    return(false);
                }

                if (scene.LastTheOnlyOneBangHui > 0)
                {
                    //超过最小时间之后,产生了新帮会,接下来外面的代码需要进行数据库修改
                    long ticks = TimeUtil.NOW();
                    EventLogManager.AddGameEvent(LogRecordType.LangHunLingYuLongTaOnlyBangHuiLog, scene.CityData.CityId, newBHid, ticks - scene.BangHuiTakeHuangGongTicks, "狼魂领域龙塔占领持续时间");
                    if (ticks - scene.BangHuiTakeHuangGongTicks > RuntimeData.MaxTakingHuangGongSecs)
                    {
                        scene.LongTaOwnerData.OwnerBHid       = scene.LastTheOnlyOneBangHui;
                        scene.LongTaOwnerData.OwnerBHName     = GetBangHuiName(newBHid, out scene.LongTaOwnerData.OwnerBHZoneId); //加载帮会名称等细节信息
                        scene.LongTaOwnerData.OwnerBHServerId = newBHServerID;
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #3
0
        public static bool CostGoodsList(GameClient client, List <List <int> > needGoods, bool notBind, ref string strCostList, string logMsg)
        {
            bool result = true;
            bool bUsedBinding_just_placeholder     = false;
            bool bUsedTimeLimited_just_placeholder = false;

            for (int i = 0; i < needGoods.Count; i++)
            {
                if (needGoods[i].Count >= 2)
                {
                    int goodsId   = needGoods[i][0];
                    int costCount = needGoods[i][1];
                    if (notBind)
                    {
                        if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodsId, costCount, false, out bUsedBinding_just_placeholder, out bUsedTimeLimited_just_placeholder, false))
                        {
                            LogManager.WriteLog(LogTypes.Error, string.Format("{0},消耗{1}个GoodsID={2}的非绑定物品失败", logMsg, costCount, goodsId), null, true);
                            result = false;
                            goto IL_15A;
                        }
                    }
                    else if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodsId, costCount, false, out bUsedBinding_just_placeholder, out bUsedTimeLimited_just_placeholder, false))
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("{0},消耗{1}个GoodsID={2}的物品失败", logMsg, costCount, goodsId), null, true);
                        result = false;
                        goto IL_15A;
                    }
                    if (strCostList != null)
                    {
                        GoodsData goodsDataCost = new GoodsData
                        {
                            GoodsID = goodsId,
                            GCount  = costCount
                        };
                        strCostList += EventLogManager.NewGoodsDataPropString(goodsDataCost);
                    }
                }
                IL_15A :;
            }
            return(result);
        }
 private void TryTriggerSkills(GameClient client, long nowTicks, SkillTriggerTypes type)
 {
     lock (this.mutex)
     {
         foreach (PassiveSkillData data in this.passiveSkillList.Values)
         {
             if (data.triggerType == (int)type)
             {
                 long spanTicks;
                 bool b = this._spanTimeDict.TryGetValue(data.skillId, out spanTicks);
                 if (!b || spanTicks <= nowTicks)
                 {
                     int rnd = Global.GetRandomNumber(0, 100);
                     if (rnd < data.triggerRate)
                     {
                         long coolDownTicks;
                         b = this.coolDownDict.TryGetValue(data.skillId, out coolDownTicks);
                         if (!b || coolDownTicks <= nowTicks)
                         {
                             this.coolDownDict[data.skillId]  = nowTicks + (long)(data.coolDown * 1000);
                             this._spanTimeDict[data.skillId] = nowTicks + (long)(data.triggerCD * 1000);
                             int posX = client.ClientData.PosX;
                             int posY = client.ClientData.PosY;
                             SpriteAttack.AddDelayMagic(client, client.ClientData.RoleID, posX, posY, posX, posY, data.skillId);
                             EventLogManager.AddRoleSkillEvent(client, SkillLogTypes.PassiveSkillTrigger, LogRecordType.IntValue2, new object[]
                             {
                                 data.skillId,
                                 data.skillLevel,
                                 data.triggerRate,
                                 rnd,
                                 data.coolDown
                             });
                         }
                     }
                 }
             }
         }
     }
 }
        /// <summary>
        /// 发放活动奖励
        /// </summary>
        private void GiveLangHunLingYuAwards(LangHunLingYuScene scene)
        {
            LangHunLingYuAwardsData successAwardsData = new LangHunLingYuAwardsData();
            LangHunLingYuAwardsData faildAwardsData   = new LangHunLingYuAwardsData();

            successAwardsData.Success            = 1;
            successAwardsData.AwardsItemDataList = scene.LevelInfo.Award.Items;
            foreach (var copyMap in scene.CopyMapDict.Values)
            {
                List <GameClient> objList = copyMap.GetClientsList();
                foreach (var client in objList)
                {
                    LangHunLingYuAwardsData awardsData = client.ClientData.Faction == scene.LongTaOwnerData.OwnerBHid ? successAwardsData : faildAwardsData;
                    if (awardsData.AwardsItemDataList != null)
                    {
                        // 判断背包空闲格子是否足够
                        if (Global.CanAddGoodsNum(client, awardsData.AwardsItemDataList.Count))
                        {
                            foreach (var item in awardsData.AwardsItemDataList)
                            {
                                Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, item.GoodsNum, 0, "", item.Level, item.Binding, 0,
                                                         "", true, 1, /**/ "圣域争霸胜利奖励", Global.ConstGoodsEndTime, 0, 0, item.IsHaveLuckyProp, 0, item.ExcellencePorpValue, item.AppendLev);
                            }
                        }
                        else
                        {
                            Global.UseMailGivePlayerAward2(client, awardsData.AwardsItemDataList, Global.GetLang("圣域争霸胜利奖励"), Global.GetLang("圣域争霸胜利奖励"));
                        }

                        EventLogManager.AddRoleEvent(client, OpTypes.GiveAwards, OpTags.LangHunLingYu, LogRecordType.IntValue2, client.ClientData.Faction, awardsData.Success);
                    }

                    client.sendCmd((int)TCPGameServerCmds.CMD_SPR_LANGHUNLINGYU_AWARD, awardsData);
                }
            }
        }
        public override bool GiveAward(GameClient client, int _params)
        {
            AwardItem myAwardItem = this.GetAward(_params);
            bool      result      = true;

            if (null != myAwardItem)
            {
                result = base.GiveAward(client, myAwardItem);
            }
            if (result)
            {
                AwardItem myOccAward = this.GetOccAward(_params);
                if (null != myOccAward)
                {
                    result = base.GiveAward(client, myOccAward);
                }
                if (result)
                {
                    string strResList = "";
                    if (null != myAwardItem)
                    {
                        strResList = EventLogManager.MakeGoodsDataPropString(myAwardItem.GoodsDataList);
                    }
                    if (!string.IsNullOrEmpty(strResList))
                    {
                        strResList += "@";
                    }
                    if (null != myOccAward)
                    {
                        strResList += EventLogManager.MakeGoodsDataPropString(myOccAward.GoodsDataList);
                    }
                    EventLogManager.AddJieriCZSongEvent(client, _params, strResList);
                }
            }
            return(result);
        }
        /// <summary>
        /// 心跳处理
        /// </summary>
        public void TimerProc(object sender, EventArgs e)
        {
            lock (RuntimeData.Mutex)
            {
                if (RuntimeData.StatisticalDataQueue.Count > 0)
                {
                    LangHunLingYuStatisticalData data = RuntimeData.StatisticalDataQueue.Peek();
                    int result = YongZheZhanChangClient.getInstance().GameFuBenComplete(data);
                    if (result >= 0)
                    {
                        RuntimeData.StatisticalDataQueue.Dequeue();
                    }
                }
            }

            foreach (var scene in RuntimeData.SceneDict.Values)
            {
                lock (RuntimeData.Mutex)
                {
                    // 当前tick
                    DateTime now   = TimeUtil.NowDateTime();
                    long     ticks = TimeUtil.NOW();

                    if (scene.m_eStatus == GameSceneStatuses.STATUS_NULL)             // 如果处于空状态 -- 是否要切换到准备状态
                    {
                        if (ticks >= scene.StartTimeTicks)
                        {
                            LangHunLingYuFuBenData fuBenData;
                            if (RuntimeData.FuBenDataDict.TryGetValue(scene.GameId, out fuBenData) && fuBenData.State == GameFuBenState.End)
                            {
                                scene.m_eStatus    = GameSceneStatuses.STATUS_AWARD;
                                scene.m_lLeaveTime = TimeUtil.NOW();
                            }

                            scene.m_lPrepareTime = scene.StartTimeTicks;
                            scene.m_lBeginTime   = scene.m_lPrepareTime + scene.SceneInfo.PrepareSecs * TimeUtil.SECOND;
                            scene.m_eStatus      = GameSceneStatuses.STATUS_PREPARE;

                            scene.StateTimeData.GameType = (int)GameTypes.LangHunLingYu;
                            scene.StateTimeData.State    = (int)scene.m_eStatus;
                            scene.StateTimeData.EndTicks = scene.m_lBeginTime;
                            foreach (var copy in scene.CopyMapDict.Values)
                            {
                                GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, copy);
                            }
                        }
                    }
                    else if (scene.m_eStatus == GameSceneStatuses.STATUS_PREPARE)     // 场景战斗状态切换
                    {
                        if (ticks >= scene.m_lBeginTime)
                        {
                            scene.m_eStatus  = GameSceneStatuses.STATUS_BEGIN;
                            scene.m_lEndTime = scene.m_lBeginTime + scene.SceneInfo.FightingSecs * TimeUtil.SECOND;

                            scene.StateTimeData.GameType = (int)GameTypes.LangHunLingYu;
                            scene.StateTimeData.State    = (int)scene.m_eStatus;
                            scene.StateTimeData.EndTicks = scene.m_lEndTime;
                            foreach (var copy in scene.CopyMapDict.Values)
                            {
                                GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, copy);
                            }
                        }
                    }
                    else if (scene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)       // 战斗开始
                    {
                        if (ticks >= scene.m_lEndTime)
                        {
                            scene.m_eStatus    = GameSceneStatuses.STATUS_END;
                            scene.m_lLeaveTime = scene.m_lEndTime + scene.SceneInfo.ClearRolesSecs * TimeUtil.SECOND;

                            scene.StateTimeData.GameType = (int)GameTypes.LangHunLingYu;
                            scene.StateTimeData.State    = (int)GameSceneStatuses.STATUS_CLEAR;
                            scene.StateTimeData.EndTicks = scene.m_lLeaveTime;
                            foreach (var copy in scene.CopyMapDict.Values)
                            {
                                GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, copy);
                            }

                            ProcessWangChengZhanResult(scene, true);
                        }
                        else
                        {
                            ProcessWangChengZhanResult(scene, false);
                        }
                    }
                    else if (scene.m_eStatus == GameSceneStatuses.STATUS_END)         // 战斗结束
                    {
                        //结算奖励
                        scene.m_eStatus = GameSceneStatuses.STATUS_AWARD;

                        LangHunLingYuStatisticalData statisticalData = new LangHunLingYuStatisticalData();
                        statisticalData.CompliteTime = TimeUtil.NowDateTime();
                        statisticalData.CityId       = scene.CityData.CityId;
                        statisticalData.GameId       = scene.GameId;
                        statisticalData.SiteBhids[0] = scene.LongTaOwnerData.OwnerBHid;
                        LangHunLingYuBuildMaxCityOwnerInfo(statisticalData, scene.LongTaOwnerData.OwnerBHServerId);
                        RuntimeData.StatisticalDataQueue.Enqueue(statisticalData);
                        LangHunLingYuFuBenData fuBenData;
                        if (RuntimeData.FuBenDataDict.TryGetValue(scene.GameId, out fuBenData))
                        {
                            fuBenData.State = GameFuBenState.End;
                        }

                        EventLogManager.AddGameEvent(LogRecordType.LangHunLingYuResult, statisticalData.GameId, statisticalData.CityId, statisticalData.SiteBhids[0]);
                    }
                    else if (scene.m_eStatus == GameSceneStatuses.STATUS_AWARD)
                    {
                        if (ticks >= scene.m_lLeaveTime)
                        {
                            foreach (var copy in scene.CopyMapDict.Values)
                            {
                                copy.SetRemoveTicks(scene.m_lLeaveTime);
                                try
                                {
                                    List <GameClient> objsList = copy.GetClientsList();
                                    if (objsList != null && objsList.Count > 0)
                                    {
                                        for (int n = 0; n < objsList.Count; ++n)
                                        {
                                            GameClient c = objsList[n];
                                            if (c != null)
                                            {
                                                KuaFuManager.getInstance().GotoLastMap(c);
                                            }
                                        }
                                    }
                                }
                                catch (System.Exception ex)
                                {
                                    DataHelper.WriteExceptionLogEx(ex, "圣域争霸系统清场调度异常");
                                }
                            }

                            scene.m_eStatus = GameSceneStatuses.STATUS_CLEAR;
                        }
                    }
                }
            }

            return;
        }
Beispiel #8
0
        public void PushGameResultData(KarenBattleScene scene)
        {
            JunTuanRankData rankData = this.GetJunTuanRankDataBySide(scene.SuccessSide);

            if (null != rankData)
            {
                JunTuanBaseData baseData = JunTuanManager.getInstance().GetJunTuanBaseDataByJunTuanID(rankData.JunTuanId);
                if (null == baseData)
                {
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("无法获取军团基本信息 JunTuanId={0}", rankData.JunTuanId), null, true);
                }
                else if (baseData.BhList == null || baseData.BhList.Count == 0)
                {
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("军团基本信息BhList为空 JunTuanId={0}", rankData.JunTuanId), null, true);
                }
                else
                {
                    int               leaderBangHui  = baseData.BhList[0];
                    int               leaderServerID = 0;
                    SceneUIClasses    mapType        = Global.GetMapSceneType(scene.m_nMapCode);
                    int               lingDiType     = this.ConvertMapSceneTypeToCaiJiLingDiType(mapType);
                    LingDiData        oldLingDiData  = null;
                    List <LingDiData> LingDiList     = JunTuanClient.getInstance().GetLingDiData();
                    if (null != LingDiList)
                    {
                        oldLingDiData = LingDiList.Find((LingDiData x) => x.LingDiType == lingDiType);
                    }
                    RoleData4Selector oldLeader = (oldLingDiData != null && oldLingDiData.RoleData != null) ? DataHelper.BytesToObject <RoleData4Selector>(oldLingDiData.RoleData, 0, oldLingDiData.RoleData.Length) : null;
                    lock (this.Mutex)
                    {
                        if (!this.FactionIDVsServerIDDict.TryGetValue(leaderBangHui, out leaderServerID))
                        {
                            JunTuanData data = JunTuanClient.getInstance().GetJunTuanData(leaderBangHui, rankData.JunTuanId, true);
                            if (null == data)
                            {
                                LogManager.WriteLog(LogTypes.Fatal, string.Format("无法获取JunTuanData BangHuiID={0} JunTuanId={1}", leaderBangHui, rankData.JunTuanId), null, true);
                                return;
                            }
                            LingDiCaiJiManager.getInstance().SetLingZhu(lingDiType, data.LeaderRoleId, rankData.JunTuanId, rankData.JunTuanName, null);
                            EventLogManager.AddKarenBattleEvent(lingDiType, oldLeader, data.LeaderZoneId, rankData.JunTuanId, data.LeaderRoleId);
                            return;
                        }
                    }
                    BangHuiDetailData bhData = Global.GetBangHuiDetailData(-1, leaderBangHui, leaderServerID);
                    if (null == bhData)
                    {
                        LogManager.WriteLog(LogTypes.Fatal, string.Format("无法获取帮会详细信息 BangHuiID={0} ServerID={1}", leaderBangHui, leaderServerID), null, true);
                    }
                    else
                    {
                        RoleDataEx dbRd = Global.sendToDB <RoleDataEx, string>(275, string.Format("{0}:{1}", -1, bhData.BZRoleID), leaderServerID);
                        if (dbRd == null || dbRd.RoleID <= 0)
                        {
                            LogManager.WriteLog(LogTypes.Fatal, string.Format("无法获取帮主详细信息 BangHuiID={0} BZRoleID={1} ServerID={2}", leaderBangHui, bhData.BZRoleID, leaderServerID), null, true);
                        }
                        else
                        {
                            JunTuanManager.getInstance().OnInitGame(dbRd);
                            RoleData4Selector leaderShowInfo = Global.RoleDataEx2RoleData4Selector(dbRd);
                            LingDiCaiJiManager.getInstance().SetLingZhu(lingDiType, dbRd.RoleID, rankData.JunTuanId, rankData.JunTuanName, leaderShowInfo);
                            EventLogManager.AddKarenBattleEvent(lingDiType, oldLeader, dbRd.ZoneID, rankData.JunTuanId, dbRd.RoleID);
                        }
                    }
                }
            }
        }
Beispiel #9
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);
        }
Beispiel #10
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);
        }
Beispiel #11
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);
        }
Beispiel #12
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);
            }
        }
        public QingGongYanResult HoldQingGongYan(GameClient client, int index, int onlyCheck = 0)
        {
            QingGongYanResult result;

            if (!Global.IsKingCityLeader(client))
            {
                result = QingGongYanResult.NotKing;
            }
            else
            {
                QingGongYanInfo InfoData = this.GetQingGongYanConfig(index);
                if (null == InfoData)
                {
                    result = QingGongYanResult.ErrorParam;
                }
                else if (InfoData.IfBanTime(TimeUtil.NowDateTime()))
                {
                    result = QingGongYanResult.OutTime;
                }
                else
                {
                    int DBStartDay = GameManager.GameConfigMgr.GetGameConfigItemInt("qinggongyan_startday", 0);
                    int currDay    = Global.GetOffsetDay(TimeUtil.NowDateTime());
                    if (DBStartDay == currDay && TimeUtil.NowDateTime() <= DateTime.Parse(InfoData.OverTime))
                    {
                        result = QingGongYanResult.RepeatHold;
                    }
                    else
                    {
                        int startDay;
                        if (TimeUtil.NowDateTime() < DateTime.Parse(InfoData.BeginTime))
                        {
                            startDay = currDay;
                        }
                        else
                        {
                            startDay = currDay + 1;
                        }
                        if (startDay == DBStartDay)
                        {
                            result = QingGongYanResult.RepeatHold;
                        }
                        else
                        {
                            if (InfoData.HoldBindJinBi > 0)
                            {
                                if (InfoData.HoldBindJinBi > Global.GetTotalBindTongQianAndTongQianVal(client))
                                {
                                    return(QingGongYanResult.MoneyNotEnough);
                                }
                            }
                            if (onlyCheck > 0)
                            {
                                result = QingGongYanResult.CheckSuccess;
                            }
                            else
                            {
                                if (InfoData.HoldBindJinBi > 0)
                                {
                                    if (!Global.SubBindTongQianAndTongQian(client, InfoData.HoldBindJinBi, "举办庆功宴"))
                                    {
                                        return(QingGongYanResult.MoneyNotEnough);
                                    }
                                }
                                Global.UpdateDBGameConfigg("qinggongyan_roleid", client.ClientData.RoleID.ToString());
                                GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_roleid", client.ClientData.RoleID.ToString());
                                BangHuiMiniData bangHuiMiniData = Global.GetBangHuiMiniData(client.ClientData.Faction, 0);
                                if (null != bangHuiMiniData)
                                {
                                    Global.UpdateDBGameConfigg("qinggongyan_guildname", bangHuiMiniData.BHName);
                                    GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_guildname", bangHuiMiniData.BHName);
                                }
                                else
                                {
                                    Global.UpdateDBGameConfigg("qinggongyan_guildname", "");
                                    GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_guildname", "");
                                }
                                GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_guildname", client.ClientData.RoleName);
                                Global.UpdateDBGameConfigg("qinggongyan_startday", startDay.ToString());
                                GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_startday", startDay.ToString());
                                Global.UpdateDBGameConfigg("qinggongyan_grade", index.ToString());
                                GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_grade", index.ToString());
                                Global.UpdateDBGameConfigg("qinggongyan_joincount", "0");
                                GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_joincount", "0");
                                Global.UpdateDBGameConfigg("qinggongyan_joinmoney", "0");
                                GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_joinmoney", "0");
                                Global.UpdateDBGameConfigg("qinggongyan_jubanmoney", InfoData.HoldBindJinBi.ToString());
                                GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_jubanmoney", InfoData.HoldBindJinBi.ToString());
                                GameManager.logDBCmdMgr.AddDBLogInfo(-1, "举办庆功宴", startDay.ToString(), "", client.ClientData.RoleName, "", index, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, null);
                                EventLogManager.AddRoleEvent(client, OpTypes.Hold, OpTags.QingGongYan, LogRecordType.OffsetDayId, new object[]
                                {
                                    startDay
                                });
                                result = QingGongYanResult.Success;
                            }
                        }
                    }
                }
            }
            return(result);
        }
Beispiel #14
0
        public static string ProcessRandomWaBaoByZaDanSP(GameClient client, Dictionary <int, SystemXmlItem> SystemXmlItemDic, int nType, out string strRecord, int binding = 0, bool bMuProject = false)
        {
            strRecord = null;
            int gainGoodsID     = 0;
            int gainGoodsNum    = 0;
            int gainGold        = 0;
            int gainYinLiang    = 0;
            int gainExp         = 0;
            int nGoodsLevel     = 0;
            int nAppendProp     = 0;
            int nLuckyProp      = 0;
            int nExcellenceProp = 0;

            int[] goodsInfo  = Global.GetRandomGoods(GameManager.systemParamsList.GetParamValueByName("QiFuTen"));
            int   goodsID    = goodsInfo[0];
            int   nGoodCount = goodsInfo[1];

            if (Global.CanAddGoodsToJinDanCangKu(client, goodsID, 1, binding, "1900-01-01 12:00:00", true))
            {
                int nForgeFallId = goodsInfo[3];
                nGoodsLevel = GameManager.GoodsPackMgr.GetFallGoodsLevel(nForgeFallId);
                int nAppendPropFallId = goodsInfo[4];
                nAppendProp = GameManager.GoodsPackMgr.GetZhuiJiaGoodsLevelID(nAppendPropFallId);
                int nLuckyPropFallId = goodsInfo[5];
                nLuckyProp = GameManager.GoodsPackMgr.GetLuckyGoodsID(nLuckyPropFallId);
                int nExcellencePropFallId = goodsInfo[6];
                nExcellenceProp = GameManager.GoodsPackMgr.GetExcellencePropertysID(goodsID, nExcellencePropFallId);
                int dbRet = Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, goodsID, nGoodCount, 0, "", nGoodsLevel, binding, 2000, "", true, 1, "乾坤袋挖宝获取道具", "1900-01-01 12:00:00", 0, 0, nLuckyProp, 0, nExcellenceProp, nAppendProp, 0, null, null, 0, true);
                if (dbRet < 0)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("使用乾坤袋挖宝时背包满,放入物品时错误, RoleID={0}, GoodsID={1}, Binding={2}, Ret={3}", new object[]
                    {
                        client.ClientData.RoleID,
                        goodsID,
                        binding,
                        dbRet
                    }), null, true);
                }
                else
                {
                    Global.BroadcastQianKunDaiGoodsHint(client, goodsID, nType);
                    gainGoodsID  = goodsID;
                    gainGoodsNum = 1;
                    SevenDayGoalEventObject evObj = SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.GetEquipCountByQiFu);
                    evObj.Arg1 = goodsID;
                    evObj.Arg2 = gainGoodsNum;
                    GlobalEventSource.getInstance().fireEvent(evObj);
                }
            }
            else
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("使用乾坤袋挖宝时背包满,无法放入物品, RoleID={0}, GoodsID={1}, Binding={2}", client.ClientData.RoleID, goodsID, binding), null, true);
            }
            string strProp = string.Format("{0}|{1}|{2}|{3}", new object[]
            {
                nGoodsLevel,
                nAppendProp,
                nLuckyProp,
                nExcellenceProp
            });
            string sResult;

            if (bMuProject)
            {
                sResult = string.Format("{0},{1},{2},{3},{4},{5},{6}", new object[]
                {
                    gainGoodsID,
                    nGoodCount,
                    binding,
                    nGoodsLevel,
                    nAppendProp,
                    nLuckyProp,
                    nExcellenceProp
                });
            }
            else
            {
                sResult = string.Format("{0}_{1}_{2}_{3}_{4}_{5}", new object[]
                {
                    gainGoodsID,
                    gainGoodsNum,
                    gainGold,
                    gainYinLiang,
                    gainExp,
                    strProp
                });
            }
            strRecord = string.Format("{0}_{1}_{2}_{3}_{4}_{5}", new object[]
            {
                gainGoodsID,
                gainGoodsNum,
                gainGold,
                gainYinLiang,
                gainExp,
                strProp
            });
            if (gainGoodsID > 0)
            {
                EventLogManager.AddRoleQiFuEvent(client, "【{0}】在祈福抽取中获得了【{1}】", new object[]
                {
                    client.ClientData.RoleName,
                    Global.GetGoodsLogName(new GoodsData
                    {
                        GoodsID        = gainGoodsID,
                        ExcellenceInfo = nExcellenceProp
                    })
                });
            }
            return(sResult);
        }
Beispiel #15
0
        /// <summary>
        /// 举办庆功宴
        /// </summary>
        public QingGongYanResult HoldQingGongYan(GameClient client, int index, int onlyCheck = 0)
        {
            // 是不是王城占领者
            if (!Global.IsKingCityLeader(client))
            {
                return(QingGongYanResult.NotKing);
            }

            QingGongYanInfo InfoData = GetQingGongYanConfig(index);

            if (null == InfoData)
            {
                return(QingGongYanResult.ErrorParam);
            }

            /// 此时是否能够开启庆功宴
            if (InfoData.IfBanTime(TimeUtil.NowDateTime()))
            {
                return(QingGongYanResult.OutTime);
            }

            int DBStartDay = GameManager.GameConfigMgr.GetGameConfigItemInt(GameConfigNames.QGYStartDay, 0);
            int currDay    = Global.GetOffsetDay(TimeUtil.NowDateTime());

            //  如果今天有庆功宴 并且庆功宴结束时间还没到 提示已经申请
            if (DBStartDay == currDay && TimeUtil.NowDateTime() <= DateTime.Parse(InfoData.OverTime))
            {
                return(QingGongYanResult.RepeatHold);
            }

            // 计算申请之后,庆功宴的举办时间
            int startDay = 0;

            // 在庆功宴开始时间之前,就在今天开启
            if (TimeUtil.NowDateTime() < DateTime.Parse(InfoData.BeginTime))
            {
                startDay = currDay;
            }
            // 否则在明天开启
            else
            {
                startDay = currDay + 1;
            }

            // 如果计算出来的举办时间和数据库的举办时间相同,则返回已经申请
            if (startDay == DBStartDay)
            {
                return(QingGongYanResult.RepeatHold);
            }

            // 检查举办所需金币是否足够
            if (InfoData.HoldBindJinBi > 0)
            {
                if (InfoData.HoldBindJinBi > Global.GetTotalBindTongQianAndTongQianVal(client))
                {
                    return(QingGongYanResult.MoneyNotEnough);
                }
            }

            if (onlyCheck > 0)
            {
                return(QingGongYanResult.CheckSuccess);
            }

            // 扣除举办所需金币
            if (InfoData.HoldBindJinBi > 0)
            {
                if (!Global.SubBindTongQianAndTongQian(client, InfoData.HoldBindJinBi, "举办庆功宴"))
                {
                    return(QingGongYanResult.MoneyNotEnough);
                }
            }

            Global.UpdateDBGameConfigg(GameConfigNames.QGYRoleID, client.ClientData.RoleID.ToString());
            GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYRoleID, client.ClientData.RoleID.ToString());

            BangHuiMiniData bangHuiMiniData = Global.GetBangHuiMiniData(client.ClientData.Faction);

            if (null != bangHuiMiniData)
            {
                Global.UpdateDBGameConfigg(GameConfigNames.QGYGuildName, bangHuiMiniData.BHName);
                GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYGuildName, bangHuiMiniData.BHName);
            }
            else
            {
                Global.UpdateDBGameConfigg(GameConfigNames.QGYGuildName, "");
                GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYGuildName, "");
            }

            GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYGuildName, client.ClientData.RoleName);
            Global.UpdateDBGameConfigg(GameConfigNames.QGYStartDay, startDay.ToString());
            GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYStartDay, startDay.ToString());
            Global.UpdateDBGameConfigg(GameConfigNames.QGYGrade, index.ToString());
            GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYGrade, index.ToString());
            Global.UpdateDBGameConfigg(GameConfigNames.QGYJoinCount, "0");
            GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYJoinCount, "0");
            Global.UpdateDBGameConfigg(GameConfigNames.QGYJoinMoney, "0");
            GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYJoinMoney, "0");

            // 为了合服,要记录举办人花了多少金币
            Global.UpdateDBGameConfigg(GameConfigNames.QGYJuBanMoney, InfoData.HoldBindJinBi.ToString());
            GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYJuBanMoney, InfoData.HoldBindJinBi.ToString());

            // log it...
            GameManager.logDBCmdMgr.AddDBLogInfo(-1, "举办庆功宴", startDay.ToString(), "", client.ClientData.RoleName, "", index, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId);
            EventLogManager.AddRoleEvent(client, OpTypes.Hold, OpTags.QingGongYan, LogRecordType.OffsetDayId, startDay);

            return(QingGongYanResult.Success);
        }
        public bool ProcessJingLingYuanSuJueXingUpgradeCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                if (!CheckHelper.CheckCmdLengthAndRole(client, nID, cmdParams, 4))
                {
                    return(false);
                }
                int result      = 0;
                int yuanSuType  = Convert.ToInt32(cmdParams[1]);
                int shuXingType = Convert.ToInt32(cmdParams[2]);
                int useShenYou  = Convert.ToInt32(cmdParams[3]);
                int newID       = 0;
                JingLingYuanSuJueXingData jueXingData = client.ClientData.JingLingYuanSuJueXingData;
                if (jueXingData == null || jueXingData.ActiveIDs == null)
                {
                    jueXingData           = new JingLingYuanSuJueXingData();
                    jueXingData.ActiveIDs = new int[6];
                }
                int idx = (yuanSuType - 1) * 2 + shuXingType - 1;
                if (idx < 0 || idx >= jueXingData.ActiveIDs.Length)
                {
                    result = -18;
                }
                else
                {
                    int currentLevel = 0;
                    int currentID    = jueXingData.ActiveIDs[idx];
                    JingLingYuanSuInfo currentLevelInfo = null;
                    JingLingYuanSuInfo nextLevelInfo    = null;
                    JingLingYuanSuInfo preLevelInfo     = null;
                    lock (this.RuntimeData.Mutex)
                    {
                        if (currentID > 0)
                        {
                            if (this.RuntimeData.YuanSuInfoDict.Value.TryGetValue(currentID, out currentLevelInfo))
                            {
                                if (currentLevelInfo.YuanSuType != yuanSuType || currentLevelInfo.ShuXingType != shuXingType)
                                {
                                    result = -3;
                                    goto IL_4AB;
                                }
                                currentLevel = currentLevelInfo.QiangHuaLevel;
                            }
                        }
                        int nextLevel = currentLevel + 1;
                        int preLevel  = currentLevel - 1;
                        foreach (JingLingYuanSuInfo info in this.RuntimeData.YuanSuInfoDict.Value.Values)
                        {
                            if (info.YuanSuType == yuanSuType && info.ShuXingType == shuXingType)
                            {
                                if (info.QiangHuaLevel == currentLevel)
                                {
                                    currentLevelInfo = info;
                                }
                                else if (info.QiangHuaLevel == nextLevel)
                                {
                                    nextLevelInfo = info;
                                }
                                else if (info.QiangHuaLevel == preLevel)
                                {
                                    preLevelInfo = info;
                                }
                            }
                        }
                    }
                    if (currentLevelInfo == null)
                    {
                        result = -3;
                    }
                    else
                    {
                        newID = currentLevelInfo.ID;
                        if (nextLevelInfo == null)
                        {
                            result = -23;
                        }
                        else if (client.ClientData.MoneyData[144] < (long)currentLevelInfo.JieXingCurrency)
                        {
                            result = -47;
                        }
                        else if (!GoodsUtil.CheckHasGoodsList(client, currentLevelInfo.NeedGoods, false))
                        {
                            result = -6;
                        }
                        else
                        {
                            if (useShenYou > 0)
                            {
                                if (!GoodsUtil.CheckHasGoodsList(client, currentLevelInfo.Failtofail, false))
                                {
                                    result = -6;
                                    goto IL_4AB;
                                }
                            }
                            if (!GameManager.ClientMgr.ModifyYuanSuJueXingShiValue(client, -currentLevelInfo.JieXingCurrency, "精灵元素觉醒", true, true, false))
                            {
                                result = -47;
                            }
                            else
                            {
                                string strCostList = "";
                                if (!GoodsUtil.CostGoodsList(client, currentLevelInfo.NeedGoods, false, ref strCostList, "精灵元素觉醒"))
                                {
                                }
                                if (useShenYou > 0)
                                {
                                    if (!GoodsUtil.CostGoodsList(client, currentLevelInfo.Failtofail, false, ref strCostList, "精灵元素觉醒"))
                                    {
                                    }
                                }
                                bool   upLevel = false;
                                double rnd     = Global.GetRandom();
                                if (rnd <= currentLevelInfo.Success)
                                {
                                    upLevel = true;
                                }
                                int newLevel;
                                if (upLevel)
                                {
                                    newID    = nextLevelInfo.ID;
                                    newLevel = nextLevelInfo.QiangHuaLevel;
                                    jueXingData.ActiveIDs[idx] = newID;
                                }
                                else
                                {
                                    if (useShenYou > 0 || null == preLevelInfo)
                                    {
                                        result = 6;
                                        goto IL_4AB;
                                    }
                                    newID    = preLevelInfo.ID;
                                    newLevel = preLevelInfo.QiangHuaLevel;
                                    jueXingData.ActiveIDs[idx] = newID;
                                }
                                if (jueXingData.ActiveType == yuanSuType)
                                {
                                    JingLingYuanSuJueXingManager.getInstance().RefreshProps(client, false);
                                    client.delayExecModule.SetDelayExecProc(new DelayExecProcIds[]
                                    {
                                        DelayExecProcIds.NotifyRefreshProps
                                    });
                                }
                                EventLogManager.AddRoleEvent(client, OpTypes.Upgrade, OpTags.Trace, LogRecordType.JingLingYuanSuJueXing, new object[]
                                {
                                    currentID,
                                    currentLevel,
                                    newID,
                                    newLevel,
                                    currentLevelInfo.JieXingCurrency,
                                    useShenYou,
                                    strCostList
                                });
                                result = Global.sendToDB <int, RoleDataCmdT <JingLingYuanSuJueXingData> >(1452, new RoleDataCmdT <JingLingYuanSuJueXingData>(client.ClientData.RoleID, jueXingData), client.ServerId);
                            }
                        }
                    }
                }
IL_4AB:
                client.sendCmd(nID, string.Format("{0}:{1}:{2}", result, newID, useShenYou), false);
                return(true);
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("JingLingYuanSuJueXing :: 激活觉醒石错误。rid:{0}, ex:{1}", client.ClientData.RoleID, ex.Message), null, true);
            }
            return(false);
        }
Beispiel #17
0
        /// <summary>
        /// 神器再造
        /// </summary>
        /// <param name="client"></param>
        /// <param name="equipID"></param>
        /// <returns></returns>
        public static ArtifactResultData UpArtifact(GameClient client, int equipID, bool isUseBind)
        {
            ArtifactResultData result = new ArtifactResultData();

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

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

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

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

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

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

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

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

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

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

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

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

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

            #region 扣除

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

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

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

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

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

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

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

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

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

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

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

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

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

            #endregion

            #region 再造

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

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

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

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

            #endregion

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

            result.State     = (int)ArtifactResultType.Success;
            result.EquipDbID = nItemDBID;
            result.Bind      = _Binding;
            return(result);
        }
Beispiel #18
0
        private void TimerProc(object sender, EventArgs e)
        {
            bool     notifyPrepareGame = false;
            bool     notifyEnterGame   = false;
            bool     notifyEndGame     = false;
            DateTime now = TimeUtil.NowDateTime();

            lock (this.Mutex)
            {
                KarenBattleSceneInfo sceneItem = this.SceneDataDict.Values.FirstOrDefault <KarenBattleSceneInfo>();
                for (int i = 0; i < sceneItem.TimePoints.Count - 1; i += 2)
                {
                    if (now.DayOfWeek == (DayOfWeek)sceneItem.TimePoints[i].Days && now.TimeOfDay.TotalSeconds >= sceneItem.SecondsOfDay[i] - 120.0 && now.TimeOfDay.TotalSeconds <= sceneItem.SecondsOfDay[i + 1] + 120.0)
                    {
                        double secsPrepare = sceneItem.SecondsOfDay[i] - now.TimeOfDay.TotalSeconds;
                        double secsEnd     = sceneItem.SecondsOfDay[i + 1] + 120.0 - now.TimeOfDay.TotalSeconds;
                        if (!this.PrepareGame)
                        {
                            if (secsPrepare > 0.0 && secsPrepare < 120.0)
                            {
                                this.PrepareGame  = true;
                                notifyPrepareGame = true;
                                break;
                            }
                        }
                        else if (secsPrepare < 0.0)
                        {
                            notifyEnterGame  = true;
                            this.PrepareGame = false;
                            break;
                        }
                        if (!this.EndGame)
                        {
                            if (secsEnd > 0.0 && secsEnd < 120.0)
                            {
                                this.EndGame  = true;
                                notifyEndGame = true;
                                break;
                            }
                        }
                        else if (secsEnd < 0.0)
                        {
                            this.EndGame = false;
                            break;
                        }
                    }
                }
            }
            if (notifyPrepareGame)
            {
                LogManager.WriteLog(LogTypes.Error, "阿卡伦战场活动即将开始,准备通知军团角色进入!", null, true);
                lock (this.Mutex)
                {
                    this.FactionIDVsServerIDDict.Clear();
                }
            }
            if (notifyEnterGame)
            {
                int westcount = 0;
                int eastcount = 0;
                lock (this.Mutex)
                {
                    LogManager.WriteLog(LogTypes.Error, "阿卡伦战场开启,可以通知已分配到场次的玩家进入游戏了", null, true);
                    KarenBattleSceneInfo sceneItem = this.SceneDataDict.Values.FirstOrDefault <KarenBattleSceneInfo>();
                    foreach (GameClient client in GameManager.ClientMgr.GetAllClients(true))
                    {
                        if (this.CheckCanEnterKarenBattle(client) && this.CheckMap(client) && this.IsGongNengOpened(client, false))
                        {
                            if (null != client)
                            {
                                client.sendCmd(1210, string.Format("{0}:{1}:{2}:{3}", new object[]
                                {
                                    1,
                                    1,
                                    westcount,
                                    eastcount
                                }), false);
                            }
                        }
                    }
                }
            }
            if (notifyEndGame)
            {
                lock (this.Mutex)
                {
                    foreach (KarenBattleSceneInfo item in this.SceneDataDict.Values)
                    {
                        KarenFuBenData fubenData = JunTuanClient.getInstance().GetKarenKuaFuFuBenData(item.MapCode);
                        if (fubenData != null && fubenData.ServerId == GameManager.ServerId)
                        {
                            SceneUIClasses mapType = Global.GetMapSceneType(item.MapCode);
                            if (mapType != SceneUIClasses.KarenEast || KarenBattleManager_MapEast.getInstance().SceneDict.Count == 0)
                            {
                                if (mapType != SceneUIClasses.KarenWest || KarenBattleManager_MapWest.getInstance().SceneDict.Count == 0)
                                {
                                    int               lingDiType    = this.ConvertMapSceneTypeToCaiJiLingDiType(mapType);
                                    LingDiData        oldLingDiData = null;
                                    List <LingDiData> LingDiList    = JunTuanClient.getInstance().GetLingDiData();
                                    if (null != LingDiList)
                                    {
                                        oldLingDiData = LingDiList.Find((LingDiData x) => x.LingDiType == lingDiType);
                                    }
                                    RoleData4Selector oldLeader = (oldLingDiData != null && oldLingDiData.RoleData != null) ? DataHelper.BytesToObject <RoleData4Selector>(oldLingDiData.RoleData, 0, oldLingDiData.RoleData.Length) : null;
                                    LingDiCaiJiManager.getInstance().SetLingZhu(lingDiType, 0, 0, "", null);
                                    EventLogManager.AddKarenBattleEvent(lingDiType, oldLeader, 0, 0, 0);
                                }
                            }
                        }
                    }
                }
            }
            this.UpdateKuaFuMapClientCount(KarenBattleManager_MapWest.getInstance().SceneDict.Values.FirstOrDefault <KarenBattleScene>());
            this.UpdateKuaFuMapClientCount(KarenBattleManager_MapEast.getInstance().SceneDict.Values.FirstOrDefault <KarenBattleScene>());
        }
Beispiel #19
0
 public void UpdateMarriageGoodWill(GameClient client, int addGoodwillValue)
 {
     if (MarryLogic.IsVersionSystemOpenOfMarriage())
     {
         if (client.ClientData.MyMarriageData.byMarrytype != -1)
         {
             if (addGoodwillValue != 0)
             {
                 sbyte tmpGoodwilllv   = client.ClientData.MyMarriageData.byGoodwilllevel;
                 sbyte tmpGoodwillstar = client.ClientData.MyMarriageData.byGoodwillstar;
                 if (tmpGoodwilllv != this.byMaxGoodwillLv || tmpGoodwillstar != this.byMaxGoodwillStar)
                 {
                     int oldLevel = (int)client.ClientData.MyMarriageData.byGoodwilllevel;
                     int oldStart = (int)client.ClientData.MyMarriageData.byGoodwillstar;
                     client.ClientData.MyMarriageData.nGoodwillexp += addGoodwillValue;
                     int nNowLvAddExp = this.GoodwillAllExpList[(int)((tmpGoodwilllv - 1) * this.byMaxGoodwillStar + tmpGoodwillstar)];
                     client.ClientData.MyMarriageData.nGoodwillexp += nNowLvAddExp;
                     bool bUpdateLv   = false;
                     bool bUpdateStar = false;
                     for (int i = 1; i < this.GoodwillAllExpList.Count; i++)
                     {
                         if (i == this.GoodwillAllExpList.Count - 1 && client.ClientData.MyMarriageData.nGoodwillexp >= this.GoodwillAllExpList[i])
                         {
                             client.ClientData.MyMarriageData.byGoodwilllevel = this.byMaxGoodwillLv;
                             client.ClientData.MyMarriageData.byGoodwillstar  = this.byMaxGoodwillStar;
                             bUpdateStar = true;
                             client.ClientData.MyMarriageData.nGoodwillexp = this.GoodwillAllExpList[i] - this.GoodwillAllExpList[i - 1];
                         }
                         else if (client.ClientData.MyMarriageData.nGoodwillexp < this.GoodwillAllExpList[i])
                         {
                             int nLv;
                             int nStar;
                             if (i <= (int)(this.byMaxGoodwillStar + 1))
                             {
                                 nLv   = 1;
                                 nStar = i - 1;
                             }
                             else
                             {
                                 nLv   = (i - 2) / (int)this.byMaxGoodwillStar + 1;
                                 nStar = (i - 1) % (int)this.byMaxGoodwillStar;
                                 if (nStar == 0)
                                 {
                                     nStar = 10;
                                 }
                             }
                             if (nLv != (int)tmpGoodwilllv)
                             {
                                 bUpdateLv = true;
                             }
                             if (nStar != (int)tmpGoodwillstar)
                             {
                                 bUpdateStar = true;
                             }
                             client.ClientData.MyMarriageData.byGoodwilllevel = (sbyte)nLv;
                             client.ClientData.MyMarriageData.byGoodwillstar  = (sbyte)nStar;
                             client.ClientData.MyMarriageData.nGoodwillexp   -= this.GoodwillAllExpList[i - 1];
                             break;
                         }
                     }
                     if (bUpdateLv || bUpdateStar)
                     {
                         client.ClientData.MyMarriageData.ChangTime = TimeUtil.NowDateTime().ToString("yyyy-MM-dd HH:mm:ss");
                     }
                     MarryFuBenMgr.UpdateMarriageData2DB(client);
                     if (bUpdateLv || bUpdateStar)
                     {
                         this.UpdateRingAttr(client, true, false);
                     }
                     this.SendMarriageDataToClient(client, bUpdateLv || bUpdateStar);
                     if (bUpdateLv)
                     {
                         if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriMarriage) || client._IconStateMgr.CheckSpecialActivity(client) || client._IconStateMgr.CheckEverydayActivity(client))
                         {
                             client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived());
                             client._IconStateMgr.SendIconStateToClient(client);
                         }
                     }
                     if (addGoodwillValue > 0)
                     {
                         string strHint = StringUtil.substitute(GLang.GetLang(490, new object[0]), new object[]
                         {
                             addGoodwillValue
                         });
                         GameManager.ClientMgr.NotifyImportantMsg(client, strHint, GameInfoTypeIndexes.Normal, ShowGameInfoTypes.PiaoFuZi, 0);
                     }
                     EventLogManager.AddRingStarSuitEvent(client, client.ClientData.MyMarriageData.nRingID, oldLevel, (int)client.ClientData.MyMarriageData.byGoodwilllevel, oldStart, (int)client.ClientData.MyMarriageData.byGoodwillstar, "");
                 }
             }
         }
     }
 }
Beispiel #20
0
        public static bool CostMoney(GameClient client, int moneyType, int modifyValue, ref string strCostList, string logMsg, bool consume = true)
        {
            bool subRes = false;

            if (moneyType <= 50)
            {
                if (moneyType <= 8)
                {
                    if (moneyType == 1)
                    {
                        int useJinBi    = modifyValue;
                        int useYinLiang = 0;
                        if (modifyValue > client.ClientData.Money1)
                        {
                            useJinBi    = client.ClientData.Money1;
                            useYinLiang = modifyValue - useJinBi;
                        }
                        subRes = GameManager.ClientMgr.SubMoney1(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, useJinBi, logMsg);
                        if (subRes)
                        {
                            strCostList += EventLogManager.AddResPropString(strCostList, (ResLogType)moneyType, new object[]
                            {
                                -useJinBi
                            });
                            if (useYinLiang > 0)
                            {
                                subRes = GameManager.ClientMgr.SubUserYinLiang(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, useYinLiang, logMsg, false);
                                if (subRes)
                                {
                                    strCostList += EventLogManager.AddResPropString(strCostList, ResLogType.ZuanShi, new object[]
                                    {
                                        -useYinLiang
                                    });
                                }
                            }
                        }
                        return(subRes);
                    }
                    if (moneyType == 8)
                    {
                        subRes = GameManager.ClientMgr.SubUserYinLiang(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, modifyValue, logMsg, false);
                        goto IL_425;
                    }
                }
                else
                {
                    switch (moneyType)
                    {
                    case 13:
                        subRes = GameManager.ClientMgr.ModifyTianDiJingYuanValue(client, -modifyValue, logMsg, true, true, false);
                        goto IL_425;

                    case 14:
                        break;

                    case 15:
                        subRes = Global.AddZaJinDanJiFen(client, -modifyValue, logMsg, false);
                        goto IL_425;

                    default:
                        if (moneyType == 40)
                        {
                            subRes = GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, modifyValue, logMsg, true, true, false, DaiBiSySType.None);
                            goto IL_425;
                        }
                        if (moneyType == 50)
                        {
                            subRes = GameManager.ClientMgr.SubUserGold(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, modifyValue, logMsg, false);
                            goto IL_425;
                        }
                        break;
                    }
                }
            }
            else if (moneyType <= 120)
            {
                switch (moneyType)
                {
                case 99:
                    subRes = true;
                    GameManager.ClientMgr.ModifyLangHunFenMoValue(client, -modifyValue, logMsg, true, true);
                    goto IL_425;

                case 100:
                case 102:
                case 103:
                case 104:
                case 105:
                    break;

                case 101:
                    subRes = GameManager.ClientMgr.ModifyZaiZaoValue(client, -modifyValue, logMsg, true, true, false);
                    goto IL_425;

                case 106:
                    subRes = GameManager.ClientMgr.ModifyMUMoHeValue(client, -modifyValue, logMsg, true, true, false);
                    goto IL_425;

                case 107:
                    subRes = GameManager.ClientMgr.ModifyYuanSuFenMoValue(client, -modifyValue, logMsg, true, false);
                    goto IL_425;

                case 108:
                    subRes = true;
                    SingletonTemplate <GuardStatueManager> .Instance().AddGuardPoint(client, -modifyValue, logMsg);

                    goto IL_425;

                case 109:
                    subRes = GameManager.FluorescentGemMgr.DecFluorescentPoint(client, modifyValue, logMsg, false);
                    goto IL_425;

                default:
                    switch (moneyType)
                    {
                    case 119:
                        subRes = GameManager.ClientMgr.ModifyOrnamentCharmPointValue(client, -modifyValue, logMsg, true, true, false);
                        goto IL_425;

                    case 120:
                        subRes = true;
                        GameManager.ClientMgr.ModifyShenLiJingHuaPointsValue(client, -modifyValue, logMsg, true, true);
                        goto IL_425;
                    }
                    break;
                }
            }
            else
            {
                switch (moneyType)
                {
                case 129:
                    subRes = GameManager.ClientMgr.ModifyFuWenZhiChenPointsValue(client, -modifyValue, logMsg, true, true, false);
                    goto IL_425;

                case 130:
                    subRes = GameManager.ClientMgr.ModifyAlchemyElementValue(client, -modifyValue, logMsg, true, false);
                    goto IL_425;

                case 131:
                    break;

                case 132:
                    subRes = GameManager.ClientMgr.ModifyJueXingValue(client, -modifyValue, logMsg, false);
                    goto IL_425;

                case 133:
                    subRes = GameManager.ClientMgr.ModifyJueXingZhiChenValue(client, -modifyValue, logMsg, true, true, false);
                    goto IL_425;

                default:
                    switch (moneyType)
                    {
                    case 139:
                        subRes = GameManager.ClientMgr.ModifyHunJingValue(client, -modifyValue, logMsg, true, true, false);
                        goto IL_425;

                    case 140:
                        subRes = GameManager.ClientMgr.ModifyMountPointValue(client, -modifyValue, logMsg, true, true, false);
                        goto IL_425;

                    default:
                        if (moneyType == 163)
                        {
                            subRes = GameManager.ClientMgr.ModifyLuckStarValue(client, -modifyValue, logMsg, false, DaiBiSySType.None);
                            goto IL_425;
                        }
                        break;
                    }
                    break;
                }
            }
            LogManager.WriteLog(LogTypes.Error, " CheckHasMoney 不支持的货币类型:" + moneyType, null, true);
IL_425:
            if (subRes)
            {
                strCostList += EventLogManager.AddResPropString(strCostList, (ResLogType)moneyType, new object[]
                {
                    -modifyValue
                });
            }
            return(subRes);
        }
Beispiel #21
0
        private bool ChangeOccupation(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            int result           = 0;
            int targetOccupation = Global.SafeConvertToInt32(cmdParams[1]);
            int occupation       = client.ClientData.Occupation;

            GameManager.ClientMgr.StopClientStoryboard(client, -1);
            if (!this.IsGongNengOpened(client))
            {
                result = -12;
            }
            else if (!client.InSafeRegion)
            {
                result = -33;
            }
            else if (occupation == targetOccupation)
            {
                result = -18;
            }
            else
            {
                lock (this.RuntimeData.Mutex)
                {
                    if (!this.RuntimeData.CanChangeOccupationMapCodes.Contains(client.ClientData.MapCode))
                    {
                        result = -34;
                        goto IL_221;
                    }
                    if (!client.ClientData.OccupationList.Contains(targetOccupation))
                    {
                        result = -20;
                        goto IL_221;
                    }
                }
                RoleCustomData customData = Global.sendToDB <RoleCustomData, int>(10230, client.ClientData.RoleID, client.ServerId);
                if (null == customData)
                {
                    customData = new RoleCustomData
                    {
                        roleId = client.ClientData.RoleID
                    };
                }
                this.SaveRoleCustomData(client, customData);
                if (!this.StoreRoleOccGoodsList(client))
                {
                    result = -15;
                }
                if (result >= 0)
                {
                    string[] args = Global.SendToDB <string>(10126, string.Format("{0}:{1}", client.ClientData.RoleID, targetOccupation), client.ServerId);
                    if (args[1] != targetOccupation.ToString())
                    {
                        result = -15;
                    }
                    else
                    {
                        EventLogManager.AddChangeOccupationEvent(client, targetOccupation);
                        client.ClientData.Occupation       = targetOccupation;
                        client.ClientData.IsMainOccupation = (client.ClientData.OccupationList[0] == client.ClientData.Occupation);
                        this.RestoreRoleCustomData(client, customData);
                        this.RestoreRoleOccGoodsList(client);
                        RebornManager.getInstance().InitPlayerRebornPorperty(client);
                        client.sendCmd <int>(13999, client.ClientData.RoleID, false);
                    }
                }
            }
IL_221:
            if (result < 0)
            {
                client.sendCmd <int>(nID, result, false);
            }
            return(true);
        }
Beispiel #22
0
        public MazingerStore ProcessMazingerStoreUpGrade(GameClient client, int ClientType, int ClientOpt)
        {
            MazingerStore res = new MazingerStore();

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

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

            QingGongYanInfo InfoData = GetInfoData();

            if (null == InfoData)
            {
                return(QingGongYanResult.OutTime);
            }

            int JoinCount = GameManager.GameConfigMgr.GetGameConfigItemInt(GameConfigNames.QGYJoinCount, 0);

            if (JoinCount > 0)
            {
                if (JoinCount >= InfoData.TotalNum)
                {
                    return(QingGongYanResult.TotalNotEnough);
                }
            }

            // 检查参加所需金币是否足够
            if (InfoData.JoinBindJinBi > 0)
            {
                if (InfoData.JoinBindJinBi > Global.GetTotalBindTongQianAndTongQianVal(client))
                {
                    return(QingGongYanResult.MoneyNotEnough);
                }
            }

            String QingGongYanJoinFlag = Global.GetRoleParamByName(client, RoleParamName.QingGongYanJoinFlag);
            int    currDay             = Global.GetOffsetDay(TimeUtil.NowDateTime());
            int    lastJoinDay         = 0;
            int    joinCount           = 0;

            // day:count
            if (null != QingGongYanJoinFlag)
            {
                string[] fields = QingGongYanJoinFlag.Split(',');
                if (2 == fields.Length)
                {
                    lastJoinDay = Convert.ToInt32(fields[0]);
                    joinCount   = Convert.ToInt32(fields[1]);
                }
            }

            if (currDay != lastJoinDay)
            {
                joinCount = 0;
            }


            if (InfoData.SingleNum > 0)
            {
                if (joinCount >= InfoData.SingleNum)
                {
                    return(QingGongYanResult.CountNotEnough);
                }
            }

            // 扣除参加所需金币
            if (InfoData.JoinBindJinBi > 0)
            {
                if (!Global.SubBindTongQianAndTongQian(client, InfoData.JoinBindJinBi, "参加庆功宴"))
                {
                    return(QingGongYanResult.MoneyNotEnough);
                }
            }

            // 玩家计数
            string roleParam = currDay.ToString() + "," + (joinCount + 1).ToString();

            Global.UpdateRoleParamByName(client, RoleParamName.QingGongYanJoinFlag, roleParam, true);

            // 参加全局计数叠加
            // 由于这里是异步操作,数量可能会少
            Global.UpdateDBGameConfigg(GameConfigNames.QGYJoinCount, (JoinCount + 1).ToString());
            GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYJoinCount, (JoinCount + 1).ToString());
            // 记录缴纳的
            int JoinMoney = GameManager.GameConfigMgr.GetGameConfigItemInt(GameConfigNames.QGYJoinMoney, 0);

            Global.UpdateDBGameConfigg(GameConfigNames.QGYJoinMoney, (JoinMoney + InfoData.JoinBindJinBi).ToString());
            GameManager.GameConfigMgr.SetGameConfigItem(GameConfigNames.QGYJoinMoney, (JoinMoney + InfoData.JoinBindJinBi).ToString());

            // 发奖
            if (InfoData.ExpAward > 0)
            {
                GameManager.ClientMgr.ProcessRoleExperience(client, InfoData.ExpAward);
            }

            if (InfoData.XingHunAward > 0)
            {
                GameManager.ClientMgr.ModifyStarSoulValue(client, InfoData.XingHunAward, "庆功宴", true, true);
            }

            if (InfoData.ZhanGongAward > 0)
            {
                int nZhanGong = InfoData.ZhanGongAward;
                if (GameManager.ClientMgr.AddBangGong(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, ref nZhanGong, AddBangGongTypes.BG_QGY))
                {
                    //[bing] 记录战功增加流向log
                    if (0 != nZhanGong)
                    {
                        GameManager.logDBCmdMgr.AddDBLogInfo(-1, "战功", "罗兰宴会领取", "系统", client.ClientData.RoleName, "增加", nZhanGong, client.ClientData.ZoneID, client.strUserID, client.ClientData.BangGong, client.ServerId);
                    }
                }
                GameManager.SystemServerEvents.AddEvent(string.Format("角色获取帮贡, roleID={0}({1}), BangGong={2}, newBangGong={3}", client.ClientData.RoleID, client.ClientData.RoleName, client.ClientData.BangGong, nZhanGong), EventLevels.Record);
            }

            // log it
            GameManager.logDBCmdMgr.AddDBLogInfo(-1, "参加庆功宴", "", "", client.ClientData.RoleName, "", 1, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId);
            EventLogManager.AddRoleEvent(client, OpTypes.Join, OpTags.QingGongYan, LogRecordType.OffsetDayId, currDay);

            return(QingGongYanResult.Success);
        }
Beispiel #25
0
        public static string ProcessRandomWaBaoByZaDan(GameClient client, Dictionary <int, SystemXmlItem> SystemXmlItemDic, int nType, out string strRecord, int binding = 0, bool bMuProject = false)
        {
            strRecord = null;
            int gainGoodsID  = 0;
            int gainGoodsNum = 0;
            int gainGold     = 0;
            int gainYinLiang = 0;
            int gainExp      = 0;
            int randomNum    = Global.GetRandomNumber(1, 100001);
            List <SystemXmlItem> itemList = new List <SystemXmlItem>();

            foreach (SystemXmlItem systemWaBaoItem in SystemXmlItemDic.Values)
            {
                if (randomNum >= systemWaBaoItem.GetIntValue("StartValues", -1) && randomNum <= systemWaBaoItem.GetIntValue("EndValues", -1))
                {
                    itemList.Add(systemWaBaoItem);
                    break;
                }
            }
            string result;

            if (itemList.Count <= 0)
            {
                result = "";
            }
            else
            {
                List <string> mstTextList     = new List <string>();
                int           index           = Global.GetRandomNumber(0, itemList.Count);
                SystemXmlItem waBaoItem       = itemList[index];
                int           nGoodsLevel     = 0;
                int           nAppendProp     = 0;
                int           nLuckyProp      = 0;
                int           nExcellenceProp = 0;
                int           nGoodCount      = waBaoItem.GetIntValue("Num", -1);
                int           goodsID         = waBaoItem.GetIntValue("GoodsID", -1);
                if (goodsID > 0)
                {
                    if (Global.CanAddGoodsToJinDanCangKu(client, goodsID, 1, binding, "1900-01-01 12:00:00", true))
                    {
                        int nForgeFallId = waBaoItem.GetIntValue("QiangHuaFallID", -1);
                        if (nForgeFallId != -1)
                        {
                            nGoodsLevel = GameManager.GoodsPackMgr.GetFallGoodsLevel(nForgeFallId);
                        }
                        int nAppendPropFallId = waBaoItem.GetIntValue("ZhuiJiaFallID", -1);
                        if (nAppendPropFallId != -1)
                        {
                            nAppendProp = GameManager.GoodsPackMgr.GetZhuiJiaGoodsLevelID(nAppendPropFallId);
                        }
                        int nLuckyPropFallId = waBaoItem.GetIntValue("LckyProbability", -1);
                        if (nLuckyPropFallId != -1)
                        {
                            int nValue = GameManager.GoodsPackMgr.GetLuckyGoodsID(nLuckyPropFallId);
                            if (nValue >= 1)
                            {
                                nLuckyProp = 1;
                            }
                        }
                        int nExcellencePropFallId = waBaoItem.GetIntValue("ZhuoYueFallID", -1);
                        if (nExcellencePropFallId != -1)
                        {
                            nExcellenceProp = GameManager.GoodsPackMgr.GetExcellencePropertysID(goodsID, nExcellencePropFallId);
                        }
                        int dbRet = Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, goodsID, nGoodCount, 0, "", nGoodsLevel, binding, 2000, "", true, 1, "乾坤袋挖宝获取道具", "1900-01-01 12:00:00", 0, 0, nLuckyProp, 0, nExcellenceProp, nAppendProp, 0, null, null, 0, true);
                        if (dbRet < 0)
                        {
                            LogManager.WriteLog(LogTypes.Error, string.Format("使用乾坤袋挖宝时背包满,放入物品时错误, RoleID={0}, GoodsID={1}, Binding={2}, Ret={3}", new object[]
                            {
                                client.ClientData.RoleID,
                                goodsID,
                                binding,
                                dbRet
                            }), null, true);
                        }
                        else
                        {
                            Global.BroadcastQianKunDaiGoodsHint(client, goodsID, nType);
                            gainGoodsID  = goodsID;
                            gainGoodsNum = 1;
                            SevenDayGoalEventObject evObj = SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.GetEquipCountByQiFu);
                            evObj.Arg1 = goodsID;
                            evObj.Arg2 = gainGoodsNum;
                            GlobalEventSource.getInstance().fireEvent(evObj);
                        }
                    }
                    else
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("使用乾坤袋挖宝时背包满,无法放入物品, RoleID={0}, GoodsID={1}, Binding={2}", client.ClientData.RoleID, goodsID, binding), null, true);
                    }
                }
                int minMoney = waBaoItem.GetIntValue("MinMoney", -1);
                int maxMoney = waBaoItem.GetIntValue("MaxMoney", -1);
                if (minMoney >= 0 && maxMoney > minMoney)
                {
                    int giveMoney = Global.GetRandomNumber(minMoney, maxMoney);
                    if (giveMoney > 0)
                    {
                        GameManager.ClientMgr.AddUserYinLiang(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, giveMoney, "开启乾坤袋二", false);
                        gainYinLiang = giveMoney;
                    }
                }
                int minBindYuanBao = waBaoItem.GetIntValue("MinBindYuanBao", -1);
                int maxBindYuanBao = waBaoItem.GetIntValue("MaxBindYuanBao", -1);
                if (minBindYuanBao >= 0 && maxBindYuanBao > minBindYuanBao)
                {
                    int giveBingYuanBao = Global.GetRandomNumber(minBindYuanBao, maxBindYuanBao);
                    if (giveBingYuanBao > 0)
                    {
                        GameManager.ClientMgr.AddUserGold(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, giveBingYuanBao, "开启乾坤袋二");
                        gainGold = giveBingYuanBao;
                    }
                }
                int minExp = waBaoItem.GetIntValue("MinExp", -1);
                int maxExp = waBaoItem.GetIntValue("MaxExp", -1);
                if (minExp >= 0 && maxExp > minExp)
                {
                    int giveExp = Global.GetRandomNumber(minExp, maxExp);
                    if (giveExp > 0)
                    {
                        GameManager.ClientMgr.ProcessRoleExperience(client, (long)giveExp, false, true, false, "none");
                        gainExp = giveExp;
                    }
                }
                string strProp = string.Format("{0}|{1}|{2}|{3}", new object[]
                {
                    nGoodsLevel,
                    nAppendProp,
                    nLuckyProp,
                    nExcellenceProp
                });
                string sResult;
                if (bMuProject)
                {
                    sResult = string.Format("{0},{1},{2},{3},{4},{5},{6}", new object[]
                    {
                        gainGoodsID,
                        nGoodCount,
                        binding,
                        nGoodsLevel,
                        nAppendProp,
                        nLuckyProp,
                        nExcellenceProp
                    });
                }
                else
                {
                    sResult = string.Format("{0}_{1}_{2}_{3}_{4}_{5}", new object[]
                    {
                        gainGoodsID,
                        gainGoodsNum,
                        gainGold,
                        gainYinLiang,
                        gainExp,
                        strProp
                    });
                }
                strRecord = string.Format("{0}_{1}_{2}_{3}_{4}_{5}", new object[]
                {
                    gainGoodsID,
                    gainGoodsNum,
                    gainGold,
                    gainYinLiang,
                    gainExp,
                    strProp
                });
                if (gainGoodsID > 0)
                {
                    EventLogManager.AddRoleQiFuEvent(client, "【{0}】在祈福抽取中获得了【{1}】", new object[]
                    {
                        client.ClientData.RoleName,
                        Global.GetGoodsLogName(new GoodsData
                        {
                            GoodsID        = gainGoodsID,
                            ExcellenceInfo = nExcellenceProp
                        })
                    });
                }
                result = sResult;
            }
            return(result);
        }
Beispiel #26
0
        private bool ProcessBianShenStarUpCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            int result = 0;
            BianShenUpdateResultData resultData   = new BianShenUpdateResultData();
            RoleBianShenData         BianShenData = client.ClientData.BianShenData;
            BianShenUpdateResultData requestData  = DataHelper.BytesToObject <BianShenUpdateResultData>(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 = -400;
            }
            else
            {
                string strCostList = "";
                lock (this.RuntimeData.Mutex)
                {
                    List <BianShenStarInfo> list;
                    if (BianShenData.BianShen != requestData.BianShen)
                    {
                        result = -18;
                    }
                    else if (!this.RuntimeData.BianShenUpDict.TryGetValue(client.ClientData.Occupation, out list))
                    {
                        result = -400;
                    }
                    else if (BianShenData.BianShen >= list.Count - 1)
                    {
                        result = -23;
                    }
                    else
                    {
                        BianShenStarInfo starInfo  = list[BianShenData.BianShen];
                        BianShenStarInfo starInfo2 = list[BianShenData.BianShen + 1];
                        if (starInfo == null || starInfo2 == null)
                        {
                            result = -3;
                        }
                        else if (!GoodsUtil.CostGoodsList(client, starInfo.NeedGoods, false, ref strCostList, "变身升级"))
                        {
                            result = -6;
                        }
                        else
                        {
                            int exp = starInfo.GoodsExp;
                            if (Global.GetRandom() < starInfo.ExpCritRate)
                            {
                                exp = (int)((double)exp * starInfo.ExpCritTimes);
                            }
                            BianShenData.Exp += exp;
                            if (BianShenData.Exp >= starInfo.UpExp)
                            {
                                BianShenData.BianShen++;
                                BianShenData.Exp -= starInfo.UpExp;
                            }
                            Global.SendToDB <RoleDataCmdT <RoleBianShenData> >(1449, new RoleDataCmdT <RoleBianShenData>(client.ClientData.RoleID, BianShenData), client.ServerId);
                            if (BianShenData.BianShen > requestData.BianShen)
                            {
                                client.ClientData.PropsCacheManager.SetExtProps(new object[]
                                {
                                    PropsSystemTypes.BianShen,
                                    starInfo2.ExtPropValues
                                });
                                client.delayExecModule.SetDelayExecProc(new DelayExecProcIds[]
                                {
                                    DelayExecProcIds.RecalcProps,
                                    DelayExecProcIds.NotifyRefreshProps
                                });
                                EventLogManager.AddBianShenEvent(client, type, (zuanshi > 0) ? 1 : 0, exp, starInfo.Level, starInfo2.Level, BianShenData.Exp, strCostList);
                            }
                            else
                            {
                                EventLogManager.AddBianShenEvent(client, type, (zuanshi > 0) ? 1 : 0, exp, starInfo.Level, starInfo.Level, BianShenData.Exp, strCostList);
                            }
                        }
                    }
                }
            }
            resultData.Result   = result;
            resultData.BianShen = BianShenData.BianShen;
            resultData.Exp      = BianShenData.Exp;
            resultData.Auto     = auto;
            resultData.Type     = type;
            client.sendCmd <BianShenUpdateResultData>(nID, resultData, false);
            return(true);
        }
        public QingGongYanResult JoinQingGongYan(GameClient client)
        {
            QingGongYanResult result;

            if (null == this.QingGongYanNpc)
            {
                result = QingGongYanResult.OutTime;
            }
            else
            {
                QingGongYanInfo InfoData = this.GetInfoData();
                if (null == InfoData)
                {
                    result = QingGongYanResult.OutTime;
                }
                else
                {
                    int JoinCount = GameManager.GameConfigMgr.GetGameConfigItemInt("qinggongyan_joincount", 0);
                    if (JoinCount > 0)
                    {
                        if (JoinCount >= InfoData.TotalNum)
                        {
                            return(QingGongYanResult.TotalNotEnough);
                        }
                    }
                    if (InfoData.JoinBindJinBi > 0)
                    {
                        if (InfoData.JoinBindJinBi > Global.GetTotalBindTongQianAndTongQianVal(client))
                        {
                            return(QingGongYanResult.MoneyNotEnough);
                        }
                    }
                    string QingGongYanJoinFlag = Global.GetRoleParamByName(client, "QingGongYanJoinFlag");
                    int    currDay             = Global.GetOffsetDay(TimeUtil.NowDateTime());
                    int    lastJoinDay         = 0;
                    int    joinCount           = 0;
                    if (null != QingGongYanJoinFlag)
                    {
                        string[] fields = QingGongYanJoinFlag.Split(new char[]
                        {
                            ','
                        });
                        if (2 == fields.Length)
                        {
                            lastJoinDay = Convert.ToInt32(fields[0]);
                            joinCount   = Convert.ToInt32(fields[1]);
                        }
                    }
                    if (currDay != lastJoinDay)
                    {
                        joinCount = 0;
                    }
                    if (InfoData.SingleNum > 0)
                    {
                        if (joinCount >= InfoData.SingleNum)
                        {
                            return(QingGongYanResult.CountNotEnough);
                        }
                    }
                    if (InfoData.JoinBindJinBi > 0)
                    {
                        if (!Global.SubBindTongQianAndTongQian(client, InfoData.JoinBindJinBi, "参加庆功宴"))
                        {
                            return(QingGongYanResult.MoneyNotEnough);
                        }
                    }
                    string roleParam = currDay.ToString() + "," + (joinCount + 1).ToString();
                    Global.UpdateRoleParamByName(client, "QingGongYanJoinFlag", roleParam, true);
                    Global.UpdateDBGameConfigg("qinggongyan_joincount", (JoinCount + 1).ToString());
                    GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_joincount", (JoinCount + 1).ToString());
                    int JoinMoney = GameManager.GameConfigMgr.GetGameConfigItemInt("qinggongyan_joinmoney", 0);
                    Global.UpdateDBGameConfigg("qinggongyan_joinmoney", (JoinMoney + InfoData.JoinBindJinBi).ToString());
                    GameManager.GameConfigMgr.SetGameConfigItem("qinggongyan_joinmoney", (JoinMoney + InfoData.JoinBindJinBi).ToString());
                    if (InfoData.ExpAward > 0)
                    {
                        GameManager.ClientMgr.ProcessRoleExperience(client, (long)InfoData.ExpAward, true, true, false, "none");
                    }
                    if (InfoData.XingHunAward > 0)
                    {
                        GameManager.ClientMgr.ModifyStarSoulValue(client, InfoData.XingHunAward, "庆功宴", true, true);
                    }
                    if (InfoData.ZhanGongAward > 0)
                    {
                        int nZhanGong = InfoData.ZhanGongAward;
                        if (GameManager.ClientMgr.AddBangGong(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, ref nZhanGong, AddBangGongTypes.BG_QGY, 0))
                        {
                            if (0 != nZhanGong)
                            {
                                GameManager.logDBCmdMgr.AddDBLogInfo(-1, "战功", "罗兰宴会领取", "系统", client.ClientData.RoleName, "增加", nZhanGong, client.ClientData.ZoneID, client.strUserID, client.ClientData.BangGong, client.ServerId, null);
                            }
                        }
                        GameManager.SystemServerEvents.AddEvent(string.Format("角色获取帮贡, roleID={0}({1}), BangGong={2}, newBangGong={3}", new object[]
                        {
                            client.ClientData.RoleID,
                            client.ClientData.RoleName,
                            client.ClientData.BangGong,
                            nZhanGong
                        }), EventLevels.Record);
                    }
                    GameManager.logDBCmdMgr.AddDBLogInfo(-1, "参加庆功宴", "", "", client.ClientData.RoleName, "", 1, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, null);
                    EventLogManager.AddRoleEvent(client, OpTypes.Join, OpTags.QingGongYan, LogRecordType.OffsetDayId, new object[]
                    {
                        currDay
                    });
                    result = QingGongYanResult.Success;
                }
            }
            return(result);
        }