public void ActivationStarConstellationAll(GameClient client) { int nOccupation = client.ClientData.Occupation; Dictionary <int, Dictionary <int, StarConstellationDetailInfo> > dicTmp = null; if (this.m_StarConstellationDetailInfo.TryGetValue(nOccupation, out dicTmp) && dicTmp != null) { if (client.ClientData.RoleStarConstellationInfo == null) { client.ClientData.RoleStarConstellationInfo = new Dictionary <int, int>(); } foreach (KeyValuePair <int, Dictionary <int, StarConstellationDetailInfo> > kvp in dicTmp) { TCPOutPacket tcpOutPacket = null; string strDbCmd = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, kvp.Key, this.m_MaxStarSlotID); TCPProcessCmdResults dbRequestResult = Global.RequestToDBServer2(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, 10166, strDbCmd, out tcpOutPacket, client.ServerId); if (TCPProcessCmdResults.RESULT_FAILED != dbRequestResult) { Global.PushBackTcpOutPacket(tcpOutPacket); } client.ClientData.RoleStarConstellationInfo[kvp.Key] = this.m_MaxStarSlotID; StarConstellationDetailInfo tmpInfo = null; if (kvp.Value.TryGetValue(this.m_MaxStarSlotID, out tmpInfo) && null != tmpInfo.Propertyinfo) { this.ActivationStarConstellationProp(client, tmpInfo.Propertyinfo, 1); } this.ActivationStarConstellationExtendProp(client, kvp.Key); GameManager.StarConstellationMgr.InitPlayerStarConstellationPorperty(client); } GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.ActiveXingZuo)); ProcessTask.ProcessRoleTaskVal(client, TaskTypes.XingZuoStar, -1); GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); client.ClientData.LifeV = (int)RoleAlgorithm.GetMaxLifeV(client); client.ClientData.MagicV = (int)RoleAlgorithm.GetMaxMagicV(client); GameManager.ClientMgr.NotifySelfLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); client.sendCmd <Dictionary <int, int> >(661, client.ClientData.RoleStarConstellationInfo, false); } }
/// <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); }
/// <summary> /// 执行炼制 /// </summary> /// <param name="type">炼制类型: 0 金币,1 绑钻,2钻石</param> /// <param name="count">炼制次数: 非正数表示全部剩余次数</param> /// <returns></returns> public bool ExecLianZhi(GameClient client, int type, int count) { int roleID = client.ClientData.RoleID; int vipLevel = client.ClientData.VipLevel; int nID = (int)TCPGameServerCmds.CMD_SPR_EXEC_LIANZHI; string useMsg = "炼制系统"; List <int> result = new List <int>(); result.Add(StdErrorCode.Error_Success); result.Add(type); result.Add(count); //验证配置和参数 if (!ConfigLoadSuccess) { result[0] = StdErrorCode.Error_Config_Fault; client.sendCmd(nID, result); } else if (type < 0 || type > 2) { result[0] = StdErrorCode.Error_Invalid_Operation; client.sendCmd(nID, result); } else { int needJinBi = 0; int needBangZuan = 0; int needZuanShi = 0; long addExp = 0; int addXingHun = 0; int addJinBi = 0; int lianZhiCount = 0; //当日已用此数 int lianZhiDayID = -1; //使用的日期 int lianZhiMaxCount = 0; //最大次数限制 int dayID = TimeUtil.NowDateTime().DayOfYear; //整理次数、消耗和奖励信息 if (type == 0) { useMsg = "金币炼制"; lianZhiCount = Global.GetRoleParamsInt32FromDB(client, RoleParamName.LianZhiJinBiCount); lianZhiDayID = Global.GetRoleParamsInt32FromDB(client, RoleParamName.LianZhiJinBiDayID); lianZhiMaxCount = JinBiLianZhi[2] + VIPJinBiLianZhi[Math.Min(VIPJinBiLianZhi.Length - 1, vipLevel)]; needJinBi = JinBiLianZhi[0]; addExp = JinBiLianZhi[1]; JieRiMultAwardActivity activity = HuodongCachingMgr.GetJieRiMultAwardActivity(); if (null != activity) { JieRiMultConfig config = activity.GetConfig((int)MultActivityType.ZhuanHuanCount); if (null != config) { lianZhiMaxCount = lianZhiMaxCount * ((int)config.GetMult() + 1); } config = activity.GetConfig((int)MultActivityType.ZhuanHuanAward); if (null != config) { addExp += (int)(addExp * config.GetMult()); } } } else if (type == 1) { useMsg = "绑钻炼制"; lianZhiCount = Global.GetRoleParamsInt32FromDB(client, RoleParamName.LianZhiBangZuanCount); lianZhiDayID = Global.GetRoleParamsInt32FromDB(client, RoleParamName.LianZhiBangZuanDayID); lianZhiMaxCount = BangZuanLianZhi[2] + VIPBangZuanLianZhi[Math.Min(VIPBangZuanLianZhi.Length - 1, vipLevel)]; needBangZuan = BangZuanLianZhi[0]; addXingHun = BangZuanLianZhi[1]; JieRiMultAwardActivity activity = HuodongCachingMgr.GetJieRiMultAwardActivity(); if (null != activity) { JieRiMultConfig config = activity.GetConfig((int)MultActivityType.ZhuanHuanCount); if (null != config) { lianZhiMaxCount = lianZhiMaxCount * ((int)config.GetMult() + 1); } config = activity.GetConfig((int)MultActivityType.ZhuanHuanAward); if (null != config) { addXingHun += (int)(addXingHun * config.GetMult()); } } } else if (type == 2) { useMsg = "钻石炼制"; lianZhiCount = Global.GetRoleParamsInt32FromDB(client, RoleParamName.LianZhiZuanShiCount); lianZhiDayID = Global.GetRoleParamsInt32FromDB(client, RoleParamName.LianZhiZuanShiDayID); lianZhiMaxCount = ZuanShiLianZhi[4] + VIPZuanShiLianZhi[Math.Min(VIPZuanShiLianZhi.Length - 1, vipLevel)]; needZuanShi = ZuanShiLianZhi[0]; addExp = ZuanShiLianZhi[1]; addXingHun = ZuanShiLianZhi[2]; addJinBi = ZuanShiLianZhi[3]; JieRiMultAwardActivity activity = HuodongCachingMgr.GetJieRiMultAwardActivity(); if (null != activity) { JieRiMultConfig config = activity.GetConfig((int)MultActivityType.ZhuanHuanCount); if (null != config) { lianZhiMaxCount = lianZhiMaxCount * ((int)config.GetMult() + 1); } config = activity.GetConfig((int)MultActivityType.ZhuanHuanAward); if (null != config) { addExp += (int)(addExp * config.GetMult()); addXingHun += (int)(addXingHun * config.GetMult()); addJinBi += (int)(addJinBi * config.GetMult()); } } } //炼制日期已经不是今天,则次数归零 if (lianZhiDayID != dayID) { lianZhiCount = 0; } //如果传入0及以下的次数,则默认为最大次数 if (count <= 0) { count = lianZhiMaxCount - lianZhiCount; } //验证剩余次数 if (count <= 0 || lianZhiCount + count > lianZhiMaxCount) { result[0] = StdErrorCode.Error_No_Residue_Degree; client.sendCmd(nID, result); } else { needJinBi *= count; needBangZuan *= count; needZuanShi *= count; addExp *= count; addXingHun *= count; addJinBi *= count; addExp = Global.GetExpMultiByZhuanShengExpXiShu(client, addExp); //扣除消耗所需 if (needJinBi > 0 && !Global.SubBindTongQianAndTongQian(client, needJinBi, useMsg)) { result[0] = StdErrorCode.Error_JinBi_Not_Enough; client.sendCmd(nID, result); } else if (needBangZuan > 0 && !GameManager.ClientMgr.SubUserGold(client, needBangZuan, useMsg)) { result[0] = StdErrorCode.Error_BangZuan_Not_Enough; client.sendCmd(nID, result); } else if (needZuanShi > 0 && !GameManager.ClientMgr.SubUserMoney(client, needZuanShi, useMsg)) { result[0] = StdErrorCode.Error_ZuanShi_Not_Enough; client.sendCmd(nID, result); } else { //既然该扣的都扣除了,下面可以给奖励了 if (addExp > 0) { GameManager.ClientMgr.ProcessRoleExperience(client, addExp); } if (addJinBi > 0) { GameManager.ClientMgr.AddMoney1(client, addJinBi, useMsg); } if (addXingHun > 0) { GameManager.ClientMgr.ModifyStarSoulValue(client, addXingHun, useMsg, true); } //计次存盘 lianZhiCount += count; lianZhiDayID = dayID; if (type == 0) { // 七日活动 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.JinBiZhuanHuanTimes)); Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.LianZhiJinBiCount, lianZhiCount, true); Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.LianZhiJinBiDayID, lianZhiDayID, true); } else if (type == 1) { // 七日活动 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.BangZuanZhuanHuanTimes)); Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.LianZhiBangZuanCount, lianZhiCount, true); Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.LianZhiBangZuanDayID, lianZhiDayID, true); } else if (type == 2) { // 七日活动 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.ZuanShiZhuanHuanTimes)); Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.LianZhiZuanShiCount, lianZhiCount, true); Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.LianZhiZuanShiDayID, lianZhiDayID, true); } //返回结果 client.sendCmd(nID, result); } } } return(true); }
public bool processCmd(GameClient client, string[] cmdParams) { int nID = 609; int nRoleID = Global.SafeConvertToInt32(cmdParams[0]); int nUpWingMode = Global.SafeConvertToInt32(cmdParams[1]); bool result; if (null == client.ClientData.MyWingData) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -3, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); result = true; } else if (client.ClientData.MyWingData.WingID >= MUWingsManager.MaxWingID) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -8, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); result = true; } else { SystemXmlItem upStarXmlItem = MUWingsManager.GetWingUPCacheItem(client.ClientData.MyWingData.WingID + 1); if (null == upStarXmlItem) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -3, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); result = true; } else { SystemXmlItem upStarXmlItem2 = WingStarCacheManager.GetWingStarCacheItem(Global.CalcOriginalOccupationID(client), client.ClientData.MyWingData.WingID, client.ClientData.MyWingData.ForgeLevel + 1); if (null != upStarXmlItem2) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -3, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); result = true; } else { string strCostList = ""; if (0 == nUpWingMode) { string strReqItemID = upStarXmlItem.GetStringValue("NeedGoods"); string[] itemParams = strReqItemID.Split(new char[] { ',' }); if (itemParams == null || itemParams.Length != 2) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -3, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); return(true); } int originGoodsID = Convert.ToInt32(itemParams[0]); int originGoodsNum = Convert.ToInt32(itemParams[1]); if (originGoodsID <= 0 || originGoodsNum <= 0) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -3, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); return(true); } GoodsReplaceResult replaceRet = SingletonTemplate <GoodsReplaceManager> .Instance().GetReplaceResult(client, originGoodsID); if (replaceRet == null || replaceRet.TotalGoodsCnt() < originGoodsNum) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -4, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); return(true); } List <GoodsReplaceResult.ReplaceItem> realCostList = new List <GoodsReplaceResult.ReplaceItem>(); realCostList.AddRange(replaceRet.BindList); realCostList.AddRange(replaceRet.UnBindList); realCostList.Add(replaceRet.OriginBindGoods); realCostList.Add(replaceRet.OriginUnBindGoods); int stillNeedCnt = originGoodsNum; foreach (GoodsReplaceResult.ReplaceItem item in realCostList) { if (item.GoodsCnt > 0) { int realCostCnt = Math.Min(stillNeedCnt, item.GoodsCnt); if (realCostCnt <= 0) { break; } bool bUsedBinding = false; bool bUsedTimeLimited = 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 bUsedBinding, out bUsedTimeLimited, false)) { bFailed = true; } } else if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited, false)) { bFailed = true; } stillNeedCnt -= realCostCnt; if (bFailed) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -5, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); return(true); } GoodsData goodsDataLog = new GoodsData { GoodsID = item.GoodsID, GCount = realCostCnt }; strCostList = EventLogManager.NewGoodsDataPropString(goodsDataLog); } } } else { int nReqZuanShi = upStarXmlItem.GetIntValue("NeedZuanShi", -1); if (nReqZuanShi <= 0) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -3, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); return(true); } int oldUserMoney = client.ClientData.UserMoney; int oldUserGlod = client.ClientData.Gold; if (client.ClientData.UserMoney < nReqZuanShi && !HuanLeDaiBiManager.GetInstance().HuanledaibiEnough(client, nReqZuanShi)) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -6, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); return(true); } if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nReqZuanShi, "翅膀进阶", true, true, false, DaiBiSySType.ChiBangShengJie)) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -7, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); return(true); } strCostList = EventLogManager.NewResPropString(ResLogType.FristBindZuanShi, new object[] { -nReqZuanShi, oldUserGlod, client.ClientData.Gold, oldUserMoney, client.ClientData.UserMoney }); } int nLuckOne = upStarXmlItem.GetIntValue("LuckyOne", -1); int nLuckyTwo = upStarXmlItem.GetIntValue("LuckyTwo", -1); int nLuckTwoRate = (int)(upStarXmlItem.GetDoubleValue("LuckyTwoRate") * 100.0); int nNextWingID = client.ClientData.MyWingData.WingID; int nNextJinJieFailedNum = client.ClientData.MyWingData.JinJieFailedNum; int nNextStarLevel = client.ClientData.MyWingData.ForgeLevel; int nNextStarExp = client.ClientData.MyWingData.StarExp; int nOldWingID = client.ClientData.MyWingData.WingID; int nOldJinJieFailedNum = client.ClientData.MyWingData.JinJieFailedNum; int nOldStarLevel = client.ClientData.MyWingData.ForgeLevel; int nOldStarExp = client.ClientData.MyWingData.StarExp; if (nLuckOne + client.ClientData.MyWingData.JinJieFailedNum < nLuckyTwo) { nNextJinJieFailedNum++; } else if (nLuckOne + client.ClientData.MyWingData.JinJieFailedNum < 110000) { int nRandNum = Global.GetRandomNumber(0, 100); if (nRandNum < nLuckTwoRate) { nNextWingID++; nNextJinJieFailedNum = 0; nNextStarLevel = 0; nNextStarExp = 0; } else { nNextJinJieFailedNum++; } } else { nNextWingID++; nNextJinJieFailedNum = 0; nNextStarLevel = 0; nNextStarExp = 0; } GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingSuitStarTimes)); int iRet = MUWingsManager.WingUpDBCommand(client, client.ClientData.MyWingData.DbID, nNextWingID, nNextJinJieFailedNum, nNextStarLevel, nNextStarExp, client.ClientData.MyWingData.ZhuLingNum, client.ClientData.MyWingData.ZhuHunNum); if (iRet < 0) { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { -3, nRoleID, 0, 0 }); client.sendCmd(nID, strCmd, false); result = true; } else { string strCmd = string.Format("{0}:{1}:{2}:{3}", new object[] { 0, nRoleID, nNextWingID, nNextJinJieFailedNum }); client.sendCmd(nID, strCmd, false); client.ClientData.MyWingData.JinJieFailedNum = nNextJinJieFailedNum; if (client.ClientData.MyWingData.WingID != nNextWingID) { if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, false); } bool oldWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu, false); client.ClientData.MyWingData.WingID = nNextWingID; client.ClientData.MyWingData.ForgeLevel = 0; client.ClientData.MyWingData.StarExp = 0; GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingLevel)); bool newWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu, false); if (!oldWingLingYuOpened && newWingLingYuOpened) { LingYuManager.InitAsOpened(client); } if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, true); ZhuLingZhuHunManager.UpdateZhuLingZhuHunProps(client); GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7); } if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriWing) || client._IconStateMgr.CheckReborn(client)) { client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived()); client._IconStateMgr.SendIconStateToClient(client); } EventLogManager.AddWingStarEvent(client, 2, 0, nOldStarLevel, client.ClientData.MyWingData.WingID, client.ClientData.MyWingData.ForgeLevel, client.ClientData.MyWingData.StarExp, strCostList); } EventLogManager.AddWingUpgradeEvent(client, nUpWingMode, nOldJinJieFailedNum, client.ClientData.MyWingData.JinJieFailedNum, nOldWingID, client.ClientData.MyWingData.WingID, nOldStarLevel, client.ClientData.MyWingData.ForgeLevel, nOldStarExp, client.ClientData.MyWingData.StarExp, strCostList); ProcessTask.ProcessRoleTaskVal(client, TaskTypes.WingIDLevel, -1); result = true; } } } } return(result); }
public int ActivationStarConstellation(GameClient client, int nStarSiteID) { int result; if (nStarSiteID < 1 || nStarSiteID > this.m_MaxStarSiteID) { result = -1; } else { if (client.ClientData.RoleStarConstellationInfo == null) { client.ClientData.RoleStarConstellationInfo = new Dictionary <int, int>(); } int nStarSlot = 0; client.ClientData.RoleStarConstellationInfo.TryGetValue(nStarSiteID, out nStarSlot); if (nStarSlot >= this.m_MaxStarSlotID) { result = -1; } else if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.GamePayerRolePartXingZuo, false)) { result = -1; } else { nStarSlot++; int nOccupation = client.ClientData.Occupation; Dictionary <int, Dictionary <int, StarConstellationDetailInfo> > dicTmp = null; if (!this.m_StarConstellationDetailInfo.TryGetValue(nOccupation, out dicTmp) || dicTmp == null) { result = -2; } else { Dictionary <int, StarConstellationDetailInfo> dicTmpInfo = null; if (!dicTmp.TryGetValue(nStarSiteID, out dicTmpInfo) || dicTmpInfo == null) { result = -2; } else { StarConstellationDetailInfo tmpInfo = null; if (!dicTmpInfo.TryGetValue(nStarSlot, out tmpInfo) || tmpInfo == null) { result = -2; } else { int nNeeChangeLife = tmpInfo.ChangeLifeLimit; int nNeedLev = tmpInfo.LevelLimit; int nReqUnionLevel = Global.GetUnionLevel(nNeeChangeLife, nNeedLev, false); if (Global.GetUnionLevel(client.ClientData.ChangeLifeCount, client.ClientData.Level, false) < nReqUnionLevel) { result = -3; } else { int nGoods = tmpInfo.NeedGoodsID; int nNum = tmpInfo.NeedGoodsNum; if (nGoods > 0 && nNum > 0) { GoodsData goods = Global.GetGoodsByID(client, nGoods); if (goods == null || goods.GCount < nNum) { GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(533, new object[0]), new object[0]), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0); return(-5); } } int nNeedStarSoul = tmpInfo.NeedStarSoul; if (nNeedStarSoul > 0) { if (nNeedStarSoul > client.ClientData.StarSoul) { GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(534, new object[0]), new object[0]), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0); return(-9); } } int nNeedMoney = tmpInfo.NeedJinBi; if (nNeedMoney > 0) { if (!Global.SubBindTongQianAndTongQian(client, nNeedMoney, "激活星座")) { GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(535, new object[0]), new object[0]), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0); return(-10); } } if (nGoods > 0 && nNum > 0) { bool usedBinding = false; bool usedTimeLimited = false; if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nGoods, nNum, false, out usedBinding, out usedTimeLimited, false)) { return(-6); } } if (nNeedStarSoul > 0) { GameManager.ClientMgr.ModifyStarSoulValue(client, -nNeedStarSoul, "激活星座", true, true); } int nRate = Global.GetRandomNumber(1, 10001); if (nRate > tmpInfo.SuccessRate) { GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(536, new object[0]), new object[0]), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0); result = -100; } else { TCPOutPacket tcpOutPacket = null; string strDbCmd = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, nStarSiteID, nStarSlot); TCPProcessCmdResults dbRequestResult = Global.RequestToDBServer2(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, 10166, strDbCmd, out tcpOutPacket, client.ServerId); if (TCPProcessCmdResults.RESULT_FAILED == dbRequestResult) { result = -7; } else { Global.PushBackTcpOutPacket(tcpOutPacket); PropertyInfo tmpProp = tmpInfo.Propertyinfo; if (tmpProp == null) { result = -8; } else { client.ClientData.RoleStarConstellationInfo[nStarSiteID] = nStarSlot; this.ActivationStarConstellationProp(client, tmpProp, 1); if (0 == nStarSlot % 12) { this.ActivationStarConstellationExtendProp(client, nStarSiteID); GameManager.StarConstellationMgr.InitPlayerStarConstellationPorperty(client); } GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.ActiveXingZuo)); ProcessTask.ProcessRoleTaskVal(client, TaskTypes.XingZuoStar, -1); GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); client.ClientData.LifeV = (int)RoleAlgorithm.GetMaxLifeV(client); client.ClientData.MagicV = (int)RoleAlgorithm.GetMaxMagicV(client); GameManager.ClientMgr.NotifySelfLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); result = 1; } } } } } } } } } return(result); }
public bool GM_OneKeyActiveTuJianType(GameClient client, int typeId, out string failedMsg) { failedMsg = string.Empty; if (client == null) { failedMsg = "unknown"; return(false); } TuJianType type = null; if (!TuJianTypes.TryGetValue(typeId, out type)) { failedMsg = "图鉴类型找不到: " + typeId.ToString(); return(false); } // 等级不满足 if (client.ClientData.ChangeLifeCount < type.OpenChangeLife || (client.ClientData.ChangeLifeCount == type.OpenChangeLife && client.ClientData.Level < type.OpenLevel)) { failedMsg = "该项图鉴未开启,类型=" + typeId.ToString() + " ,需求转生:" + type.OpenChangeLife + " , 等级:" + type.OpenLevel; return(false); } bool bRealRefer = false; foreach (var itemId in type.ItemList) { TuJianItem item = null; if (!TuJianItems.TryGetValue(itemId, out item)) { continue; } // 该子项已激活 if (client.ClientData.PictureJudgeReferInfo.ContainsKey(itemId) && client.ClientData.PictureJudgeReferInfo[itemId] >= item.CostGoodsCnt) { continue; } string strDbCmd = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, itemId, item.CostGoodsCnt); string[] dbRsp = Global.ExecuteDBCmd((int)TCPGameServerCmds.CMD_DB_REFERPICTUREJUDGE, strDbCmd, client.ServerId); if (dbRsp == null || dbRsp.Length != 1 || Convert.ToInt32(dbRsp[0]) <= 0) { failedMsg = "数据库异常"; return(false); } bRealRefer = true; if (!client.ClientData.PictureJudgeReferInfo.ContainsKey(itemId)) { client.ClientData.PictureJudgeReferInfo.Add(itemId, item.CostGoodsCnt); } else { client.ClientData.PictureJudgeReferInfo[itemId] = item.CostGoodsCnt; } } // 只有在任何一项提交成功时,才重新计算属性加成 if (bRealRefer) { client.sendCmd(DataHelper.ObjectToTCPOutPacket <Dictionary <int, int> >(client.ClientData.PictureJudgeReferInfo, Global._TCPManager.TcpOutPacketPool, (int)TCPGameServerCmds.CMD_SPR_REFERPICTUREJUDGE)); UpdateTuJianProps(client); // 激活的图鉴项变化了,检查守护雕像的激活情况 GuardStatueManager.Instance().OnActiveTuJian(client); // 七日活动 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.CompleteTuJian)); // 通知客户端属性变化 GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); // 总生命值和魔法值变化通知(同一个地图才需要通知) GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); } return(true); }
public bool processCmd(GameClient client, string[] cmdParams) { int nRoleID = Global.SafeConvertToInt32(cmdParams[0]); int nUpStarMode = Global.SafeConvertToInt32(cmdParams[1]); string strCostList = ""; bool result; if (null == client.ClientData.MyWingData) { SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); result = true; } else { SystemXmlItem upStarXmlItem = WingStarCacheManager.GetWingStarCacheItem(Global.CalcOriginalOccupationID(client), client.ClientData.MyWingData.WingID, client.ClientData.MyWingData.ForgeLevel + 1); if (null == upStarXmlItem) { SCWingStarUp scData = new SCWingStarUp(-23, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); result = true; } else { string strWingShengXing = GameManager.systemParamsList.GetParamValueByName("WingShengXing"); if ("" == strWingShengXing) { SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); result = true; } else { string[] wingShengXing = strWingShengXing.Split(new char[] { ',' }); if (3 != wingShengXing.Length) { SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); result = true; } else { int nAddExp = 0; int nPowRate; if (0 == nUpStarMode) { nPowRate = (int)(Convert.ToDouble(wingShengXing[0]) * 100.0); nAddExp = Convert.ToInt32(upStarXmlItem.GetIntValue("GoodsExp", -1)); } else { nPowRate = (int)(Convert.ToDouble(wingShengXing[1]) * 100.0); nAddExp = Convert.ToInt32(upStarXmlItem.GetIntValue("ZuanShiExp", -1)); } int nRandNum = Global.GetRandomNumber(0, 100); if (nRandNum < nPowRate) { nAddExp *= Convert.ToInt32(wingShengXing[2]); } int nUpStarReqExp = upStarXmlItem.GetIntValue("StarExp", -1); int nOldStarLevel = client.ClientData.MyWingData.ForgeLevel; int nNextStarLevel = client.ClientData.MyWingData.ForgeLevel; int nNextStarExp = 0; if (client.ClientData.MyWingData.StarExp + nAddExp >= nUpStarReqExp) { if (nNextStarLevel < MUWingsManager.MaxWingEnchanceLevel) { nNextStarLevel++; nNextStarExp = client.ClientData.MyWingData.StarExp + nAddExp - nUpStarReqExp; while (nNextStarLevel < MUWingsManager.MaxWingEnchanceLevel) { SystemXmlItem nextStarXmlItem = WingStarCacheManager.GetWingStarCacheItem(Global.CalcOriginalOccupationID(client), client.ClientData.MyWingData.WingID, nNextStarLevel + 1); if (null != upStarXmlItem) { int nNextUpStarReqExp = nextStarXmlItem.GetIntValue("StarExp", -1); if (nNextStarExp >= nNextUpStarReqExp) { nNextStarLevel++; nNextStarExp -= nNextUpStarReqExp; continue; } } break; } } else { nNextStarExp = nUpStarReqExp; } } else { nNextStarExp = client.ClientData.MyWingData.StarExp + nAddExp; } if (0 == nUpStarMode) { string strReqItemID = upStarXmlItem.GetStringValue("NeedGoods"); string[] itemParams = strReqItemID.Split(new char[] { ',' }); if (itemParams == null || itemParams.Length != 2) { SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); return(true); } int originGoodsID = Convert.ToInt32(itemParams[0]); int originGoodsNum = Convert.ToInt32(itemParams[1]); if (originGoodsID <= 0 || originGoodsNum <= 0) { SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); return(true); } GoodsReplaceResult replaceRet = SingletonTemplate <GoodsReplaceManager> .Instance().GetReplaceResult(client, originGoodsID); if (replaceRet == null || replaceRet.TotalGoodsCnt() < originGoodsNum) { SCWingStarUp scData = new SCWingStarUp(-4, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); return(true); } List <GoodsReplaceResult.ReplaceItem> realCostList = new List <GoodsReplaceResult.ReplaceItem>(); realCostList.AddRange(replaceRet.BindList); realCostList.AddRange(replaceRet.UnBindList); realCostList.Add(replaceRet.OriginBindGoods); realCostList.Add(replaceRet.OriginUnBindGoods); int stillNeedCnt = originGoodsNum; foreach (GoodsReplaceResult.ReplaceItem item in realCostList) { if (item.GoodsCnt > 0) { int realCostCnt = Math.Min(stillNeedCnt, item.GoodsCnt); if (realCostCnt <= 0) { break; } bool bUsedBinding = false; bool bUsedTimeLimited = 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 bUsedBinding, out bUsedTimeLimited, false)) { bFailed = true; } } else if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited, false)) { bFailed = true; } stillNeedCnt -= realCostCnt; if (bFailed) { SCWingStarUp scData = new SCWingStarUp(-5, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); return(true); } GoodsData goodsData = new GoodsData { GoodsID = item.GoodsID, GCount = realCostCnt }; strCostList = EventLogManager.NewGoodsDataPropString(goodsData); } } } else { int nReqZuanShi = upStarXmlItem.GetIntValue("NeedZuanShi", -1); if (nReqZuanShi <= 0) { SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); return(true); } if (client.ClientData.UserMoney < nReqZuanShi) { SCWingStarUp scData = new SCWingStarUp(-6, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); return(true); } int oldUserMoney = client.ClientData.UserMoney; int oldUserGlod = client.ClientData.Gold; if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nReqZuanShi, "翅膀升星", true, true, false, DaiBiSySType.ChiBangShengXing)) { SCWingStarUp scData = new SCWingStarUp(-7, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); return(true); } strCostList = EventLogManager.NewResPropString(ResLogType.FristBindZuanShi, new object[] { -nReqZuanShi, oldUserGlod, client.ClientData.Gold, oldUserMoney, client.ClientData.UserMoney }); } GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingSuitStarTimes)); int iRet = MUWingsManager.WingUpStarDBCommand(client, client.ClientData.MyWingData.DbID, nNextStarLevel, nNextStarExp); if (iRet < 0) { SCWingStarUp scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd <SCWingStarUp>(608, scData, false); result = true; } else { SCWingStarUp scData = new SCWingStarUp(0, nRoleID, nNextStarLevel, nNextStarExp); client.sendCmd <SCWingStarUp>(608, scData, false); client.ClientData.MyWingData.StarExp = nNextStarExp; if (client.ClientData.MyWingData.ForgeLevel != nNextStarLevel) { if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, false); } bool oldWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu, false); client.ClientData.MyWingData.ForgeLevel = nNextStarLevel; GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingLevel)); bool newWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu, false); if (!oldWingLingYuOpened && newWingLingYuOpened) { LingYuManager.InitAsOpened(client); } if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, true); ZhuLingZhuHunManager.UpdateZhuLingZhuHunProps(client); GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7); } if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriWing) || client._IconStateMgr.CheckSpecialActivity(client) || client._IconStateMgr.CheckEverydayActivity(client) || client._IconStateMgr.CheckReborn(client)) { client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived()); client._IconStateMgr.SendIconStateToClient(client); } } EventLogManager.AddWingStarEvent(client, nUpStarMode, nAddExp, nOldStarLevel, client.ClientData.MyWingData.WingID, client.ClientData.MyWingData.ForgeLevel, client.ClientData.MyWingData.StarExp, strCostList); ProcessTask.ProcessRoleTaskVal(client, TaskTypes.WingIDLevel, -1); result = true; } } } } } return(result); }
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); }
public void HandleActiveTuJian(GameClient client, string[] itemArr) { if (itemArr != null && itemArr.Length != 0 && client != null) { bool anySuccess = false; foreach (string strItemID in itemArr) { int itemID = Convert.ToInt32(strItemID); TuJianItem item = null; TuJianType type = null; if (this.TuJianItems.TryGetValue(itemID, out item) && this.TuJianTypes.TryGetValue(item.TypeID, out type)) { if (client.ClientData.ChangeLifeCount >= type.OpenChangeLife && (client.ClientData.ChangeLifeCount != type.OpenChangeLife || client.ClientData.Level >= type.OpenLevel)) { int hadReferCnt = 0; if (client.ClientData.PictureJudgeReferInfo.ContainsKey(itemID)) { hadReferCnt = client.ClientData.PictureJudgeReferInfo[itemID]; } if (hadReferCnt < item.CostGoodsCnt) { int needReferCnt = item.CostGoodsCnt - hadReferCnt; int hasGoodsCnt = Global.GetTotalGoodsCountByID(client, item.CostGoodsID); if (hasGoodsCnt > 0) { int thisTimeReferCnt = Math.Min(needReferCnt, hasGoodsCnt); bool usedBinding_just_placeholder = false; bool usedTimeLimited_just_placeholder = false; if (GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.CostGoodsID, thisTimeReferCnt, false, out usedBinding_just_placeholder, out usedTimeLimited_just_placeholder, false)) { string strDbCmd = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, itemID, hadReferCnt + thisTimeReferCnt); string[] dbRsp = Global.ExecuteDBCmd(10155, strDbCmd, client.ServerId); if (dbRsp == null || dbRsp.Length != 1 || Convert.ToInt32(dbRsp[0]) <= 0) { LogManager.WriteLog(LogTypes.Error, string.Format("角色RoleID={0},RoleName={1} 激活图鉴Item={2}时,与db通信失败,物品已扣除GoodsID={3},Cnt={4}", new object[] { client.ClientData.RoleID, client.ClientData.RoleName, itemID, item.CostGoodsID, thisTimeReferCnt }), null, true); } else { anySuccess = true; if (!client.ClientData.PictureJudgeReferInfo.ContainsKey(itemID)) { client.ClientData.PictureJudgeReferInfo.Add(itemID, hadReferCnt + thisTimeReferCnt); } else { client.ClientData.PictureJudgeReferInfo[itemID] = hadReferCnt + thisTimeReferCnt; } ProcessTask.ProcessAddTaskVal(client, TaskTypes.JiHuoTuJian, -1, 1, new object[0]); } } } } } } } if (anySuccess) { this.UpdateTuJianProps(client); SingletonTemplate <GuardStatueManager> .Instance().OnActiveTuJian(client); GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.CompleteTuJian)); GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7); } } }
/// <summary> /// 翅膀升星处理 /// </summary> public bool processCmd(Logic.GameClient client, string[] cmdParams) { //int nID = (int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR; int nRoleID = Global.SafeConvertToInt32(cmdParams[0]); int nUpStarMode = Global.SafeConvertToInt32(cmdParams[1]); //0: 道具升星, 1: 钻石升星 //string strCmd = ""; SCWingStarUp scData = null; if (null == client.ClientData.MyWingData) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } // 获取升星信息表 SystemXmlItem upStarXmlItem = WingStarCacheManager.GetWingStarCacheItem(Global.CalcOriginalOccupationID(client), client.ClientData.MyWingData.WingID, client.ClientData.MyWingData.ForgeLevel + 1); if (null == upStarXmlItem) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(StdErrorCode.Error_Level_Reach_Max_Level, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } string strWingShengXing = GameManager.systemParamsList.GetParamValueByName("WingShengXing"); if ("" == strWingShengXing) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } // 解析升级暴率 string[] wingShengXing = strWingShengXing.Split(','); if (3 != wingShengXing.Length) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } // 暴率 int nPowRate = 0; // 增加的星经验 int nAddExp = 0; if (0 == nUpStarMode) { nPowRate = (int)(Convert.ToDouble(wingShengXing[0]) * 100.0); nAddExp = Convert.ToInt32(upStarXmlItem.GetIntValue("GoodsExp")); } else { nPowRate = (int)(Convert.ToDouble(wingShengXing[1]) * 100.0); nAddExp = Convert.ToInt32(upStarXmlItem.GetIntValue("ZuanShiExp")); } // 暴升,乘以经验倍数 int nRandNum = Global.GetRandomNumber(0, 100); if (nRandNum < nPowRate) { nAddExp *= Convert.ToInt32(wingShengXing[2]); } int nUpStarReqExp = upStarXmlItem.GetIntValue("StarExp"); int nNextStarLevel = client.ClientData.MyWingData.ForgeLevel; int nNextStarExp = 0; if (client.ClientData.MyWingData.StarExp + nAddExp >= nUpStarReqExp) { if (nNextStarLevel < MUWingsManager.MaxWingEnchanceLevel) { // 改变星级,剩余的经验改到下级 nNextStarLevel += 1; nNextStarExp = client.ClientData.MyWingData.StarExp + nAddExp - nUpStarReqExp; // 连续升星 while (true) { if (nNextStarLevel >= MUWingsManager.MaxWingEnchanceLevel) { break; } SystemXmlItem nextStarXmlItem = WingStarCacheManager.GetWingStarCacheItem(Global.CalcOriginalOccupationID(client), client.ClientData.MyWingData.WingID, nNextStarLevel + 1); if (null == upStarXmlItem) { break; } int nNextUpStarReqExp = nextStarXmlItem.GetIntValue("StarExp"); if (nNextStarExp >= nNextUpStarReqExp) { nNextStarLevel += 1; nNextStarExp = nNextStarExp - nNextUpStarReqExp; } else { break; } } } else { // 已经达到最高星 nNextStarExp = nUpStarReqExp; } } else { nNextStarExp = client.ClientData.MyWingData.StarExp + nAddExp; } if (0 == nUpStarMode) { //获取强化需要的道具的物品ID string strReqItemID = upStarXmlItem.GetStringValue("NeedGoods"); // 解析物品ID与数量 string[] itemParams = strReqItemID.Split(','); if (null == itemParams || itemParams.Length != 2) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } int originGoodsID = Convert.ToInt32(itemParams[0]); int originGoodsNum = Convert.ToInt32(itemParams[1]); if (originGoodsID <= 0 || originGoodsNum <= 0) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } GoodsReplaceResult replaceRet = GoodsReplaceManager.Instance().GetReplaceResult(client, originGoodsID); if (replaceRet == null || replaceRet.TotalGoodsCnt() < originGoodsNum) { // 物品数量不够 //strCmd = string.Format("{0}:{1}:{2}:{3}", -4, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-4, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } List <GoodsReplaceResult.ReplaceItem> realCostList = new List <GoodsReplaceResult.ReplaceItem>(); // 1:替换后的绑定材料 // 2:替换后的非绑定材料 // 3:原始绑定材料 // 4:原始非绑定材料 realCostList.AddRange(replaceRet.BindList); realCostList.AddRange(replaceRet.UnBindList); realCostList.Add(replaceRet.OriginBindGoods); realCostList.Add(replaceRet.OriginUnBindGoods); int hasUseCnt = 0; int stillNeedCnt = originGoodsNum; foreach (var item in realCostList) { if (item.GoodsCnt <= 0) { continue; } int realCostCnt = Math.Min(stillNeedCnt, item.GoodsCnt); if (realCostCnt <= 0) { break; } bool bUsedBinding = false; bool bUsedTimeLimited = 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 bUsedBinding, out bUsedTimeLimited)) { bFailed = true; } } else { if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited)) { bFailed = true; } } stillNeedCnt -= realCostCnt; if (bFailed) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -5, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-5, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } } } else { // 获取强化需要的钻石数量 int nReqZuanShi = upStarXmlItem.GetIntValue("NeedZuanShi"); if (nReqZuanShi <= 0) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } //判断用户点卷额是否不足【钻石】 if (client.ClientData.UserMoney < nReqZuanShi) { //用户点卷额不足【钻石】 //strCmd = string.Format("{0}:{1}:{2}:{3}", -6, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-6, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } //先DBServer请求扣费 //扣除用户点卷 if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nReqZuanShi, "翅膀升星")) { //扣除用户点卷失败 //strCmd = string.Format("{0}:{1}:{2}:{3}", -7, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-7, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } } // 七日活动 // 翅膀升级和升阶次数,成功失败都算 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingSuitStarTimes)); // 将改变保存到数据库 int iRet = MUWingsManager.WingUpStarDBCommand(client, client.ClientData.MyWingData.DbID, nNextStarLevel, nNextStarExp); if (iRet < 0) { //strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(-3, nRoleID, 0, 0); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); return(true); } else { //strCmd = string.Format("{0}:{1}:{2}:{3}", 0, nRoleID, nNextStarLevel, nNextStarExp); //client.sendCmd(nID, strCmd); scData = new SCWingStarUp(0, nRoleID, nNextStarLevel, nNextStarExp); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_WINGUPSTAR, scData); client.ClientData.MyWingData.StarExp = nNextStarExp; if (client.ClientData.MyWingData.ForgeLevel != nNextStarLevel) { // 先移除原来的属性 if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, false); } bool oldWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu); client.ClientData.MyWingData.ForgeLevel = nNextStarLevel; // 七日活动 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingLevel)); bool newWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu); if (!oldWingLingYuOpened && newWingLingYuOpened) { // 翎羽功能开启了,执行初始化 LingYuManager.InitAsOpened(client); } // 按新等级增加属性 if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, true); //升星时候,翅膀的基础属性的改变会影响注魂加成 ZhuLingZhuHunManager.UpdateZhuLingZhuHunProps(client); // 通知客户端属性变化 GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); // 总生命值和魔法值变化通知(同一个地图才需要通知) GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); } //[bing] 刷新客户端活动叹号 if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriWing) || client._IconStateMgr.CheckSpecialActivity(client)) { client._IconStateMgr.AddFlushIconState((ushort)ActivityTipTypes.JieRiActivity, client._IconStateMgr.IsAnyJieRiTipActived()); client._IconStateMgr.SendIconStateToClient(client); } } } return(true); }
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); }
/// <summary> /// 处理砸金蛋挖宝的操作,10连抽的特殊随机池 /// </summary> /// <param name="client"></param> /// <returns></returns> 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; // 把属性带进DB记录中 [4/1/2014 LiaoWei] int nGoodsLevel = 0; int nAppendProp = 0; int nLuckyProp = 0; int nExcellenceProp = 0; int nGoodCount = 1; int[] goodsInfo = Global.GetRandomGoods(GameManager.systemParamsList.GetParamValueByName("QiFuTen")); int goodsID = goodsInfo[0]; nGoodCount = goodsInfo[1]; //判断金蛋仓库是否已经满了? if (Global.CanAddGoodsToJinDanCangKu(client, goodsID, 1, binding, Global.ConstGoodsEndTime, true)) { // 注意 MU 新增加--物品1.强化 2.追加 3.幸运 4.卓越 的随机掉落 begin[1/22/2014 LiaoWei] { // 1.强化 int nForgeFallId = goodsInfo[3]; nGoodsLevel = GameManager.GoodsPackMgr.GetFallGoodsLevel(nForgeFallId); // 2.追加 int nAppendPropFallId = goodsInfo[4]; nAppendProp = GameManager.GoodsPackMgr.GetZhuiJiaGoodsLevelID(nAppendPropFallId); // 3.幸运 int nLuckyPropFallId = goodsInfo[5]; nLuckyProp = GameManager.GoodsPackMgr.GetLuckyGoodsID(nLuckyPropFallId); // 4.卓越 int nExcellencePropFallId = goodsInfo[6]; nExcellenceProp = GameManager.GoodsPackMgr.GetExcellencePropertysID(nExcellencePropFallId); } //想DBServer请求加入某个新的物品到金蛋仓库中 int dbRet = Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, goodsID, nGoodCount, 0, "", nGoodsLevel, binding, (int)SaleGoodsConsts.JinDanGoodsID, "", true, 1, /**/ "乾坤袋挖宝获取道具", Global.ConstGoodsEndTime, 0, 0, nLuckyProp, 0, nExcellenceProp, nAppendProp); if (dbRet < 0) { LogManager.WriteLog(LogTypes.Error, string.Format("使用乾坤袋挖宝时背包满,放入物品时错误, RoleID={0}, GoodsID={1}, Binding={2}, Ret={3}", client.ClientData.RoleID, goodsID, binding, dbRet)); } else { //开启乾坤袋成功的提示 Global.BroadcastQianKunDaiGoodsHint(client, goodsID, nType); /* * string msgText = string.Format(Global.GetLang("恭喜您开启开启乾坤袋得到: {0}"), Global.GetGoodsNameByID(goodsID)); * GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, * client, msgText, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0); */ gainGoodsID = goodsID; gainGoodsNum = 1; // 七日活动 SevenDayGoalEventObject evObj = SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.GetEquipCountByQiFu); evObj.Arg1 = goodsID; evObj.Arg2 = gainGoodsNum; GlobalEventSource.getInstance().fireEvent(evObj); } }
/// <summary> /// 处理挖宝的操作 /// </summary> /// <param name="client"></param> /// <returns></returns> public static void ProcessRandomWaBao(GameClient client, int binding, Dictionary <int, SystemXmlItem> SystemXmlItemDict, int nType) { //算一个万以内的随机数 int randomNum = Global.GetRandomNumber(1, 10001); Dictionary <int, SystemXmlItem> dict = SystemXmlItemDict; List <SystemXmlItem> itemList = new List <SystemXmlItem>(); foreach (var systemWaBaoItem in dict.Values) { if (randomNum >= systemWaBaoItem.GetIntValue("StartValues") && randomNum <= systemWaBaoItem.GetIntValue("EndValues")) { itemList.Add(systemWaBaoItem); } } //没有挖到物品 if (itemList.Count <= 0) { return; //没有挖到任何东西 } List <string> mstTextList = new List <string>(); int index = Global.GetRandomNumber(0, itemList.Count); SystemXmlItem waBaoItem = itemList[index]; //先判断是否给予物品(背包的判断在使用物品哪儿做截获处理) int goodsID = (int)waBaoItem.GetIntValue("GoodsID"); if (goodsID > 0) { //判断背包是否已经满了? if (Global.CanAddGoods(client, goodsID, 1, binding, Global.ConstGoodsEndTime, true)) { //想DBServer请求加入某个新的物品到背包中 int dbRet = Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, goodsID, 1, 0, "", 0, binding, 0, "", true, 1, /**/ "乾坤袋挖宝获取道具", Global.ConstGoodsEndTime, 0, 0, 0, 0); if (dbRet < 0) { LogManager.WriteLog(LogTypes.Error, string.Format("使用乾坤袋挖宝时背包满,放入物品时错误, RoleID={0}, GoodsID={1}, Binding={2}, Ret={3}", client.ClientData.RoleID, goodsID, binding, dbRet)); } else { //开启乾坤袋成功的提示 Global.BroadcastQianKunDaiGoodsHint(client, goodsID, nType); string msgText = string.Format(Global.GetLang("恭喜您开启开启乾坤袋得到: {0}"), Global.GetGoodsNameByID(goodsID)); GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, msgText, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0); } } else { LogManager.WriteLog(LogTypes.Error, string.Format("使用乾坤袋挖宝时背包满,无法放入物品, RoleID={0}, GoodsID={1}, Binding={2}", client.ClientData.RoleID, goodsID, binding)); } } //给予非绑定金币 int minMoney = (int)waBaoItem.GetIntValue("MinMoney"); int maxMoney = (int)waBaoItem.GetIntValue("MaxMoney"); 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, "开启乾坤袋一"); string msgText = string.Format(Global.GetLang("开启乾坤袋得到金币: +{0}"), giveMoney); GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, msgText, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0); } } //给予绑定元宝 int minBindYuanBao = (int)waBaoItem.GetIntValue("MinBindYuanBao"); int maxBindYuanBao = (int)waBaoItem.GetIntValue("MaxBindYuanBao"); 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, "开启乾坤袋"); string msgText = string.Format(Global.GetLang("开启乾坤袋得到绑定元宝: +{0}"), giveBingYuanBao); GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, msgText, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0); } } //给予经验奖励 int minExp = (int)waBaoItem.GetIntValue("MinExp"); int maxExp = (int)waBaoItem.GetIntValue("MaxExp"); if (minExp >= 0 && maxExp > minExp) { int giveExp = Global.GetRandomNumber(minExp, maxExp); if (giveExp > 0) { GameManager.ClientMgr.ProcessRoleExperience(client, giveExp, false, true); string msgText = string.Format(Global.GetLang("开启乾坤袋得到高额经验: +{0}"), giveExp); GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, msgText, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0); } } } /// <summary> /// 处理砸金蛋挖宝的操作 /// </summary> /// <param name="client"></param> /// <returns></returns> public static String ProcessRandomWaBaoByZaDan(GameClient client, Dictionary <int, SystemXmlItem> SystemXmlItemDic, int nType, out String strRecord, int binding = 0, bool bMuProject = false) { //默认非绑定 //int binding = 0; strRecord = null; //砸金蛋获取的各种奖励值 int gainGoodsID = 0; int gainGoodsNum = 0; int gainGold = 0; int gainYinLiang = 0; int gainExp = 0; //算一个万以内的随机数 int randomNum = Global.GetRandomNumber(1, 100001); Dictionary <int, SystemXmlItem> dict = SystemXmlItemDic; List <SystemXmlItem> itemList = new List <SystemXmlItem>(); foreach (var systemWaBaoItem in dict.Values) { if (randomNum >= systemWaBaoItem.GetIntValue("StartValues") && randomNum <= systemWaBaoItem.GetIntValue("EndValues")) { itemList.Add(systemWaBaoItem); break; // 直接往下执行 [8/27/2014 LiaoWei] } } //没有挖到物品 if (itemList.Count <= 0) { return(""); //没有挖到任何东西 } List <string> mstTextList = new List <string>(); int index = Global.GetRandomNumber(0, itemList.Count); SystemXmlItem waBaoItem = itemList[index]; // 把属性带进DB记录中 [4/1/2014 LiaoWei] int nGoodsLevel = 0; int nAppendProp = 0; int nLuckyProp = 0; int nExcellenceProp = 0; int nGoodCount = 1; nGoodCount = (int)waBaoItem.GetIntValue("Num"); //先判断是否给予物品(背包的判断在使用物品哪儿做截获处理) int goodsID = (int)waBaoItem.GetIntValue("GoodsID"); if (goodsID > 0) { //判断金蛋仓库是否已经满了? if (Global.CanAddGoodsToJinDanCangKu(client, goodsID, 1, binding, Global.ConstGoodsEndTime, true)) { // 注意 MU 新增加--物品1.强化 2.追加 3.幸运 4.卓越 的随机掉落 begin[1/22/2014 LiaoWei] { // 1.强化 int nForgeFallId = -1; nForgeFallId = (int)waBaoItem.GetIntValue("QiangHuaFallID"); if (nForgeFallId != -1) { nGoodsLevel = GameManager.GoodsPackMgr.GetFallGoodsLevel(nForgeFallId); } // 2.追加 int nAppendPropFallId = -1; nAppendPropFallId = (int)waBaoItem.GetIntValue("ZhuiJiaFallID"); if (nAppendPropFallId != -1) { nAppendProp = GameManager.GoodsPackMgr.GetZhuiJiaGoodsLevelID(nAppendPropFallId); } // 3.幸运 int nLuckyPropFallId = -1; nLuckyPropFallId = (int)waBaoItem.GetIntValue("LckyProbability"); if (nLuckyPropFallId != -1) { int nValue = 0; nValue = GameManager.GoodsPackMgr.GetLuckyGoodsID(nLuckyPropFallId); if (nValue >= 1) { nLuckyProp = 1; } } // 4.卓越 int nExcellencePropFallId = -1; nExcellencePropFallId = (int)waBaoItem.GetIntValue("ZhuoYueFallID"); if (nExcellencePropFallId != -1) { nExcellenceProp = GameManager.GoodsPackMgr.GetExcellencePropertysID(nExcellencePropFallId); } } // 注意 MU 新增加--物品1.强化 2.追加 3.幸运 4.卓越 的随机掉落 end[1/22/2014 LiaoWei] //想DBServer请求加入某个新的物品到金蛋仓库中 int dbRet = Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, goodsID, nGoodCount, 0, "", nGoodsLevel, binding, (int)SaleGoodsConsts.JinDanGoodsID, "", true, 1, /**/ "乾坤袋挖宝获取道具", Global.ConstGoodsEndTime, 0, 0, nLuckyProp, 0, nExcellenceProp, nAppendProp); if (dbRet < 0) { LogManager.WriteLog(LogTypes.Error, string.Format("使用乾坤袋挖宝时背包满,放入物品时错误, RoleID={0}, GoodsID={1}, Binding={2}, Ret={3}", client.ClientData.RoleID, goodsID, binding, dbRet)); } else { //开启乾坤袋成功的提示 Global.BroadcastQianKunDaiGoodsHint(client, goodsID, nType); /* * string msgText = string.Format(Global.GetLang("恭喜您开启开启乾坤袋得到: {0}"), Global.GetGoodsNameByID(goodsID)); * GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, * client, msgText, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0); */ 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)); } } //给予非绑定金币 int minMoney = (int)waBaoItem.GetIntValue("MinMoney"); int maxMoney = (int)waBaoItem.GetIntValue("MaxMoney"); 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, "开启乾坤袋二"); /* * string msgText = string.Format(Global.GetLang("开启乾坤袋得到铜钱: +{0}"), giveMoney); * GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, * client, msgText, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0); */ gainYinLiang = giveMoney; } } //给予绑定元宝 int minBindYuanBao = (int)waBaoItem.GetIntValue("MinBindYuanBao"); int maxBindYuanBao = (int)waBaoItem.GetIntValue("MaxBindYuanBao"); 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, "开启乾坤袋二"); /* * string msgText = string.Format(Global.GetLang("开启乾坤袋得到绑定元宝: +{0}"), giveBingYuanBao); * GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, * client, msgText, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0); */ gainGold = giveBingYuanBao; } } //给予经验奖励 int minExp = (int)waBaoItem.GetIntValue("MinExp"); int maxExp = (int)waBaoItem.GetIntValue("MaxExp"); if (minExp >= 0 && maxExp > minExp) { int giveExp = Global.GetRandomNumber(minExp, maxExp); if (giveExp > 0) { GameManager.ClientMgr.ProcessRoleExperience(client, giveExp, false, true); /* * string msgText = string.Format(Global.GetLang("开启乾坤袋得到高额经验: +{0}"), giveExp); * GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, * client, msgText, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox, 0); */ gainExp = giveExp; } } string strProp = ""; strProp = String.Format("{0}|{1}|{2}|{3}", nGoodsLevel, nAppendProp, nLuckyProp, nExcellenceProp); String sResult = null; if (bMuProject) { sResult = String.Format("{0},{1},{2},{3},{4},{5},{6}", gainGoodsID, nGoodCount, binding, nGoodsLevel, nAppendProp, nLuckyProp, nExcellenceProp); } else { sResult = String.Format("{0}_{1}_{2}_{3}_{4}_{5}", gainGoodsID, gainGoodsNum, gainGold, gainYinLiang, gainExp, strProp); } strRecord = String.Format("{0}_{1}_{2}_{3}_{4}_{5}", gainGoodsID, gainGoodsNum, gainGold, gainYinLiang, gainExp, strProp); return(sResult); }
/// <summary> /// 用材料合成新物品 /// </summary> /// <param name="cacheMergeItem"></param> /// <returns></returns> private static int ProcessMergeNewGoods(GameClient client, int mergeItemID, CacheMergeItem cacheMergeItem, int luckyGoodsID, int nUseBindItemFirst) { //新合成的物品是否绑定 int newGoodsBinding = 0; int addSuccessPercent = 0; bool bLeftGrid = false; int nNewGoodsID = cacheMergeItem.NewGoodsID[0]; if (cacheMergeItem.NewGoodsID.Count > 1) { if (!Global.CanAddGoodsNum(client, 1)) { return(-1); //包裹已满,因为合成物品未知,所以必须有一个空格子, } nNewGoodsID = cacheMergeItem.NewGoodsID[Global.GetRandomNumber(0, cacheMergeItem.NewGoodsID.Count)]; bLeftGrid = true; } //检查是否满足合成的条件 int ret = CanMergeNewGoods(client, cacheMergeItem, nNewGoodsID, bLeftGrid); if (ret < 0) { return(ret); } if (luckyGoodsID > 0) { int luckyPercent = Global.GetLuckyValue(luckyGoodsID); if (luckyPercent > 0) { bool usedBinding = false; bool usedTimeLimited = false; //从用户物品中扣除消耗的数量 if (GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, luckyGoodsID, 1, false, out usedBinding, out usedTimeLimited)) { if (newGoodsBinding <= 0) { newGoodsBinding = usedBinding ? 1 : 0; } addSuccessPercent = luckyPercent; } } } //检查概率 bool success = JugeSucess(mergeItemID, cacheMergeItem, addSuccessPercent); //检查物品 for (int i = 0; i < cacheMergeItem.OrigGoodsIDList.Count; i++) { int usingGoodsNum = GetUsingGoodsNum(success, cacheMergeItem, cacheMergeItem.OrigGoodsIDList[i], cacheMergeItem.OrigGoodsNumList[i]); int nBindGoodNum = Global.GetTotalBindGoodsCountByID(client, cacheMergeItem.OrigGoodsIDList[i]); int nNotBindGoodNum = Global.GetTotalNotBindGoodsCountByID(client, cacheMergeItem.OrigGoodsIDList[i]); if (usingGoodsNum > nBindGoodNum + nNotBindGoodNum) { return(-10); } bool usedBinding = false; bool usedTimeLimited = false; int nSubNum = usingGoodsNum; int nSum = 0; if (nUseBindItemFirst > 0 && nBindGoodNum > 0) { if (usingGoodsNum > nBindGoodNum) { nSum = nBindGoodNum; nSubNum = usingGoodsNum - nBindGoodNum; } else { nSum = usingGoodsNum; nSubNum = 0; } if (nSum > 0) { if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, cacheMergeItem.OrigGoodsIDList[i], nSum, false, out usedBinding, out usedTimeLimited, true)) { return(-10); } } if (nSubNum > 0) { if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, cacheMergeItem.OrigGoodsIDList[i], nSubNum, false, out usedBinding, out usedTimeLimited, true)) { return(-10); } } newGoodsBinding = 1; } else { if (usingGoodsNum > nNotBindGoodNum) { nSum = nNotBindGoodNum; nSubNum = usingGoodsNum - nNotBindGoodNum; } else { nSum = usingGoodsNum; nSubNum = 0; } if (nSum > 0) { if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, cacheMergeItem.OrigGoodsIDList[i], nSum, false, out usedBinding, out usedTimeLimited, true)) { return(-10); } } if (nSubNum > 0) { if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, cacheMergeItem.OrigGoodsIDList[i], nSubNum, false, out usedBinding, out usedTimeLimited, true)) { return(-10); } newGoodsBinding = 1; } } // if (newGoodsBinding <= 0) // { // newGoodsBinding = usedBinding ? 1 : 0; // } } //检查点卷 if (cacheMergeItem.DianJuan > 0) { //优先扣除金币 //扣除的金币 //int hasSubGold = 0; //扣除的元宝 //int hasSubYuanBao = 0; if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, cacheMergeItem.DianJuan, "合成新物品")) { return(-11); } //if (hasSubGold > 0) //{ // newGoodsBinding = 1; //} } //检查银两 if (cacheMergeItem.Money > 0) { //if (!GameManager.ClientMgr.SubUserYinLiang(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, // Global._TCPManager.TcpOutPacketPool, client, cacheMergeItem.Money)) if (!Global.SubBindTongQianAndTongQian(client, cacheMergeItem.Money, "材料合成")) { return(-12); } } // 合成改造 -- 注释掉真气和积分 [12/14/2013 LiaoWei] //检查真气 /*if (cacheMergeItem.ZhenQi > 0) * { * //扣除角色的真气 * GameManager.ClientMgr.ModifyZhenQiValue(client, -cacheMergeItem.ZhenQi, true, true); * }*/ //检查积分 /*if (cacheMergeItem.JiFen > 0) * { * //扣除角色的积分 * GameManager.ClientMgr.ModifyZhuangBeiJiFenValue(client, -cacheMergeItem.JiFen, true, true); * }*/ //检查天地精元 if (cacheMergeItem.JingYuan > 0) { //扣除角色的天地精元 GameManager.ClientMgr.ModifyTianDiJingYuanValue(client, -cacheMergeItem.JingYuan, "材料合成", true, true); } if (!success) { return(-1000); } //添加合成的新物品到角色的背包中 //想DBServer请求加入某个新的物品到背包中 int dbRet = Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, nNewGoodsID, 1, 0, "", 0, newGoodsBinding, 0, "", true, 1, "材料合成新物品"); if (dbRet < 0) { return(-20); } //判断如果是宝石,并且超过了4级,则提示 if ((int)ItemCategories.ItemJewel == Global.GetGoodsCatetoriy(nNewGoodsID)) { //如果是宝石,处理成就 //ChengJiuManager.OnRoleGoodsHeCheng(client, cacheMergeItem.NewGoodsID[0]); if (Global.GetJewelLevel(nNewGoodsID) >= 6) //6级以上 { //宝石合成 Global.BroadcastMergeJewelOk(client, nNewGoodsID); } } //如果是合成强化石,则处理成就 if ((int)ItemCategories.ItemMaterial == Global.GetGoodsCatetoriy(nNewGoodsID)) { //如果是宝石,处理成就 //ChengJiuManager.OnRoleGoodsHeCheng(client, cacheMergeItem.NewGoodsID[0]); } //成就处理 第一次合成 ChengJiuManager.OnFirstHeCheng(client); ChengJiuManager.OnRoleGoodsHeCheng(client, nNewGoodsID); // 七日活动 SevenDayGoalEventObject evObj = SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.HeChengTimes); evObj.Arg1 = nNewGoodsID; GlobalEventSource.getInstance().fireEvent(evObj); return(0); }
/// <summary> /// 激活星座信息 /// </summary> public int ActivationStarConstellation(GameClient client, int nStarSiteID) { if (nStarSiteID < 1 || nStarSiteID > m_MaxStarSiteID) { return(-1); } if (client.ClientData.RoleStarConstellationInfo == null) { client.ClientData.RoleStarConstellationInfo = new Dictionary <int, int>(); } int nStarSlot = 0; client.ClientData.RoleStarConstellationInfo.TryGetValue(nStarSiteID, out nStarSlot); if (nStarSlot >= m_MaxStarSlotID) { return(-1); } ++nStarSlot; int nOccupation = client.ClientData.Occupation; Dictionary <int, Dictionary <int, StarConstellationDetailInfo> > dicTmp = null; if (!m_StarConstellationDetailInfo.TryGetValue(nOccupation, out dicTmp) || dicTmp == null) { return(-2); } Dictionary <int, StarConstellationDetailInfo> dicTmpInfo = null; if (!dicTmp.TryGetValue(nStarSiteID, out dicTmpInfo) || dicTmpInfo == null) { return(-2); } StarConstellationDetailInfo tmpInfo = null; if (!dicTmpInfo.TryGetValue(nStarSlot, out tmpInfo) || tmpInfo == null) { return(-2); } int nNeeChangeLife = 0; nNeeChangeLife = tmpInfo.ChangeLifeLimit; int nNeedLev = tmpInfo.LevelLimit; int nReqUnionLevel = Global.GetUnionLevel(nNeeChangeLife, nNeedLev); if (Global.GetUnionLevel(client.ClientData.ChangeLifeCount, client.ClientData.Level) < nReqUnionLevel) { return(-3); } int nGoods = tmpInfo.NeedGoodsID; int nNum = tmpInfo.NeedGoodsNum; if (nGoods > 0 && nNum > 0) { GoodsData goods = null; goods = Global.GetGoodsByID(client, nGoods); if (goods == null || goods.GCount < nNum) { GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(Global.GetLang("所需物品不足")), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox); return(-5); } } int nNeedStarSoul = tmpInfo.NeedStarSoul; if (nNeedStarSoul > 0) { if (nNeedStarSoul > client.ClientData.StarSoul) { GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(Global.GetLang("星魂不足")), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox); return(-9); } } int nNeedMoney = tmpInfo.NeedJinBi; if (nNeedMoney > 0) { if (!Global.SubBindTongQianAndTongQian(client, nNeedMoney, "激活星座")) { GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(Global.GetLang("金币不足")), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox); return(-10); } } if (nGoods > 0 && nNum > 0) { bool usedBinding = false; bool usedTimeLimited = false; if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nGoods, nNum, false, out usedBinding, out usedTimeLimited)) { return(-6); } } if (nNeedStarSoul > 0) { GameManager.ClientMgr.ModifyStarSoulValue(client, -nNeedStarSoul, "激活星座", true, true); //client.ClientData.StarSoul -= nNeedStarSoul; //if (client.ClientData.StarSoul < 0) // client.ClientData.StarSoul = 0; //Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.StarSoul, client.ClientData.StarSoul, true); //GameManager.ClientMgr.NotifySelfParamsValueChange(client, RoleCommonUseIntParamsIndexs.StarSoulValue, client.ClientData.StarSoul); } // 概率 int nRate = 0; nRate = Global.GetRandomNumber(1, 10001); if (nRate > tmpInfo.SuccessRate) { GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(Global.GetLang("激活星位失败")), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.ErrAndBox); return(-100); } // 通知DB TCPOutPacket tcpOutPacket = null; string strDbCmd = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, nStarSiteID, nStarSlot); TCPProcessCmdResults dbRequestResult = Global.RequestToDBServer2(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, (int)TCPGameServerCmds.CMD_DB_UPDATESTARCONSTELLATION, strDbCmd, out tcpOutPacket, client.ServerId); if (TCPProcessCmdResults.RESULT_FAILED == dbRequestResult) { return(-7); } Global.PushBackTcpOutPacket(tcpOutPacket); PropertyInfo tmpProp = null; tmpProp = tmpInfo.Propertyinfo; if (tmpProp == null) { return(-8); } client.ClientData.RoleStarConstellationInfo[nStarSiteID] = nStarSlot; ActivationStarConstellationProp(client, tmpProp); /*int nCount = 0; * * if (!client.ClientData.StarConstellationCount.TryGetValue(nStarSiteID, out nCount)) * { ++nCount; * client.ClientData.StarConstellationCount.Add(nStarSiteID, nCount); * } * else * { ++client.ClientData.StarConstellationCount[nStarSiteID]; * }*/ if (0 == nStarSlot % 12) { ActivationStarConstellationExtendProp(client, nStarSiteID); // 星座属性 [8/4/2014 LiaoWei] GameManager.StarConstellationMgr.InitPlayerStarConstellationPorperty(client); } // 七日活动 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.ActiveXingZuo)); GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); client.ClientData.LifeV = (int)RoleAlgorithm.GetMaxLifeV(client); client.ClientData.MagicV = (int)RoleAlgorithm.GetMaxMagicV(client); GameManager.ClientMgr.NotifySelfLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); return(1); }
public bool GM_OneKeyActiveTuJianType(GameClient client, int typeId, out string failedMsg) { failedMsg = string.Empty; bool result; if (client == null) { failedMsg = "unknown"; result = false; } else { TuJianType type = null; if (!this.TuJianTypes.TryGetValue(typeId, out type)) { failedMsg = "图鉴类型找不到: " + typeId.ToString(); result = false; } else if (client.ClientData.ChangeLifeCount < type.OpenChangeLife || (client.ClientData.ChangeLifeCount == type.OpenChangeLife && client.ClientData.Level < type.OpenLevel)) { failedMsg = string.Concat(new object[] { "该项图鉴未开启,类型=", typeId.ToString(), " ,需求转生:", type.OpenChangeLife, " , 等级:", type.OpenLevel }); result = false; } else { bool bRealRefer = false; foreach (int itemId in type.ItemList) { TuJianItem item = null; if (this.TuJianItems.TryGetValue(itemId, out item)) { if (!client.ClientData.PictureJudgeReferInfo.ContainsKey(itemId) || client.ClientData.PictureJudgeReferInfo[itemId] < item.CostGoodsCnt) { string strDbCmd = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, itemId, item.CostGoodsCnt); string[] dbRsp = Global.ExecuteDBCmd(10155, strDbCmd, client.ServerId); if (dbRsp == null || dbRsp.Length != 1 || Convert.ToInt32(dbRsp[0]) <= 0) { failedMsg = "数据库异常"; return(false); } bRealRefer = true; if (!client.ClientData.PictureJudgeReferInfo.ContainsKey(itemId)) { client.ClientData.PictureJudgeReferInfo.Add(itemId, item.CostGoodsCnt); } else { client.ClientData.PictureJudgeReferInfo[itemId] = item.CostGoodsCnt; } } } } if (bRealRefer) { client.sendCmd(DataHelper.ObjectToTCPOutPacket <Dictionary <int, int> >(client.ClientData.PictureJudgeReferInfo, Global._TCPManager.TcpOutPacketPool, 612), true); this.UpdateTuJianProps(client); SingletonTemplate <GuardStatueManager> .Instance().OnActiveTuJian(client); GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.CompleteTuJian)); GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7); } result = true; } } return(result); }
// 玩家激活图鉴 public void HandleActiveTuJian(GameClient client, string[] itemArr) { if (itemArr == null || itemArr.Length == 0 || client == null) { return; } bool anySuccess = false; foreach (string strItemID in itemArr) { // 客户端请求激活的图鉴Item int itemID = Convert.ToInt32(strItemID); TuJianItem item = null; TuJianType type = null; if (!TuJianItems.TryGetValue(itemID, out item) || !TuJianTypes.TryGetValue(item.TypeID, out type)) { continue; } // 等级不满足 if (client.ClientData.ChangeLifeCount < type.OpenChangeLife || (client.ClientData.ChangeLifeCount == type.OpenChangeLife && client.ClientData.Level < type.OpenLevel)) { continue; } int hadReferCnt = 0; if (client.ClientData.PictureJudgeReferInfo.ContainsKey(itemID)) { hadReferCnt = client.ClientData.PictureJudgeReferInfo[itemID]; } // 已激活 if (hadReferCnt >= item.CostGoodsCnt) { continue; } int needReferCnt = item.CostGoodsCnt - hadReferCnt; int hasGoodsCnt = Global.GetTotalGoodsCountByID(client, item.CostGoodsID); // 材料不足 if (hasGoodsCnt <= 0) { continue; } // 允许提交一部分材料 int thisTimeReferCnt = Math.Min(needReferCnt, hasGoodsCnt); bool usedBinding_just_placeholder = false; bool usedTimeLimited_just_placeholder = false; // 扣除物品失败 if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.CostGoodsID, thisTimeReferCnt, false, out usedBinding_just_placeholder, out usedTimeLimited_just_placeholder)) { continue; } string strDbCmd = string.Format("{0}:{1}:{2}", client.ClientData.RoleID, itemID, hadReferCnt + thisTimeReferCnt); string[] dbRsp = Global.ExecuteDBCmd((int)TCPGameServerCmds.CMD_DB_REFERPICTUREJUDGE, strDbCmd, client.ServerId); if (dbRsp == null || dbRsp.Length != 1 || Convert.ToInt32(dbRsp[0]) <= 0) { LogManager.WriteLog(LogTypes.Error, string.Format("角色RoleID={0},RoleName={1} 激活图鉴Item={2}时,与db通信失败,物品已扣除GoodsID={3},Cnt={4}", client.ClientData.RoleID, client.ClientData.RoleName, itemID, item.CostGoodsID, thisTimeReferCnt)); continue; } anySuccess = true; if (!client.ClientData.PictureJudgeReferInfo.ContainsKey(itemID)) { client.ClientData.PictureJudgeReferInfo.Add(itemID, hadReferCnt + thisTimeReferCnt); } else { client.ClientData.PictureJudgeReferInfo[itemID] = hadReferCnt + thisTimeReferCnt; } } // 只有在任何一项提交成功时,才重新计算属性加成 if (anySuccess) { UpdateTuJianProps(client); // 激活的图鉴项变化了,检查守护雕像的激活情况 GuardStatueManager.Instance().OnActiveTuJian(client); // 七日活动 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.CompleteTuJian)); // 通知客户端属性变化 GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); // 总生命值和魔法值变化通知(同一个地图才需要通知) GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); } }
private static int ProcessMergeNewGoods(GameClient client, int mergeItemID, CacheMergeItem cacheMergeItem, int luckyGoodsID, int nUseBindItemFirst) { int newGoodsBinding = 0; int addSuccessPercent = 0; bool bLeftGrid = false; int nNewGoodsID = cacheMergeItem.NewGoodsID[0]; if (cacheMergeItem.NewGoodsID.Count > 1) { if (!Global.CanAddGoodsNum(client, 1)) { return(-1); } nNewGoodsID = cacheMergeItem.NewGoodsID[Global.GetRandomNumber(0, cacheMergeItem.NewGoodsID.Count)]; bLeftGrid = true; } int ret = MergeNewGoods.CanMergeNewGoods(client, cacheMergeItem, nNewGoodsID, bLeftGrid); int result; if (ret < 0) { result = ret; } else { if (luckyGoodsID > 0) { int luckyPercent = Global.GetLuckyValue(luckyGoodsID); if (luckyPercent > 0) { bool usedBinding = false; bool usedTimeLimited = false; if (GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, luckyGoodsID, 1, false, out usedBinding, out usedTimeLimited, false)) { if (newGoodsBinding <= 0) { newGoodsBinding = (usedBinding ? 1 : 0); } addSuccessPercent = luckyPercent; } } } bool success = MergeNewGoods.JugeSucess(mergeItemID, cacheMergeItem, addSuccessPercent); for (int i = 0; i < cacheMergeItem.OrigGoodsIDList.Count; i++) { int usingGoodsNum = MergeNewGoods.GetUsingGoodsNum(success, cacheMergeItem, cacheMergeItem.OrigGoodsIDList[i], cacheMergeItem.OrigGoodsNumList[i]); int nBindGoodNum = Global.GetTotalBindGoodsCountByID(client, cacheMergeItem.OrigGoodsIDList[i]); int nNotBindGoodNum = Global.GetTotalNotBindGoodsCountByID(client, cacheMergeItem.OrigGoodsIDList[i]); if (usingGoodsNum > nBindGoodNum + nNotBindGoodNum) { return(-10); } bool usedBinding = false; bool usedTimeLimited = false; if (nUseBindItemFirst > 0 && nBindGoodNum > 0) { int nSum; int nSubNum; if (usingGoodsNum > nBindGoodNum) { nSum = nBindGoodNum; nSubNum = usingGoodsNum - nBindGoodNum; } else { nSum = usingGoodsNum; nSubNum = 0; } if (nSum > 0) { if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, cacheMergeItem.OrigGoodsIDList[i], nSum, false, out usedBinding, out usedTimeLimited, true)) { return(-10); } } if (nSubNum > 0) { if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, cacheMergeItem.OrigGoodsIDList[i], nSubNum, false, out usedBinding, out usedTimeLimited, true)) { return(-10); } } newGoodsBinding = 1; } else { int nSum; int nSubNum; if (usingGoodsNum > nNotBindGoodNum) { nSum = nNotBindGoodNum; nSubNum = usingGoodsNum - nNotBindGoodNum; } else { nSum = usingGoodsNum; nSubNum = 0; } if (nSum > 0) { if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, cacheMergeItem.OrigGoodsIDList[i], nSum, false, out usedBinding, out usedTimeLimited, true)) { return(-10); } } if (nSubNum > 0) { if (!GameManager.ClientMgr.NotifyUseBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, cacheMergeItem.OrigGoodsIDList[i], nSubNum, false, out usedBinding, out usedTimeLimited, true)) { return(-10); } newGoodsBinding = 1; } } } if (cacheMergeItem.DianJuan > 0) { if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, cacheMergeItem.DianJuan, "合成新物品", true, true, false, DaiBiSySType.None)) { return(-11); } } if (cacheMergeItem.Money > 0) { if (!Global.SubBindTongQianAndTongQian(client, cacheMergeItem.Money, "材料合成")) { return(-12); } } if (cacheMergeItem.JingYuan > 0) { GameManager.ClientMgr.ModifyTianDiJingYuanValue(client, -cacheMergeItem.JingYuan, "材料合成", true, true, false); } if (!success) { result = -1000; } else { int dbRet = Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, nNewGoodsID, 1, 0, "", 0, newGoodsBinding, 0, "", true, 1, "材料合成新物品", "1900-01-01 12:00:00", 0, 0, 0, 0, 0, 0, 0, null, null, 0, true); if (dbRet < 0) { result = -20; } else { if (90 == Global.GetGoodsCatetoriy(nNewGoodsID)) { if (Global.GetJewelLevel(nNewGoodsID) >= 6) { Global.BroadcastMergeJewelOk(client, nNewGoodsID); } } if (120 == Global.GetGoodsCatetoriy(nNewGoodsID)) { } ChengJiuManager.OnFirstHeCheng(client); ChengJiuManager.OnRoleGoodsHeCheng(client, nNewGoodsID); SevenDayGoalEventObject evObj = SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.HeChengTimes); evObj.Arg1 = nNewGoodsID; GlobalEventSource.getInstance().fireEvent(evObj); ProcessTask.ProcessAddTaskVal(client, TaskTypes.Merge_GuoShi, cacheMergeItem.MergeType, 1, new object[0]); result = 0; } } } return(result); }
public bool processCmd(Logic.GameClient client, string[] cmdParams) { int nID = (int)TCPGameServerCmds.CMD_SPR_WINGUPGRADE; int nRoleID = Global.SafeConvertToInt32(cmdParams[0]); int nUpWingMode = Global.SafeConvertToInt32(cmdParams[1]); //0: 道具进阶, 1: 钻石进阶 string strCmd = ""; if (null == client.ClientData.MyWingData) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } // 已到最高级 if (client.ClientData.MyWingData.WingID >= MUWingsManager.MaxWingID) { strCmd = string.Format("{0}:{1}:{2}:{3}", -8, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } // 获取进阶信息表 SystemXmlItem upStarXmlItem = MUWingsManager.GetWingUPCacheItem(client.ClientData.MyWingData.WingID + 1); if (null == upStarXmlItem) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } if (0 == nUpWingMode) { // 获取进阶需要的道具的物品信息 string strReqItemID = upStarXmlItem.GetStringValue("NeedGoods"); // 解析物品ID与数量 string[] itemParams = strReqItemID.Split(','); if (null == itemParams || itemParams.Length != 2) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } int originGoodsID = Convert.ToInt32(itemParams[0]); int originGoodsNum = Convert.ToInt32(itemParams[1]); if (originGoodsID <= 0 || originGoodsNum <= 0) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } GoodsReplaceResult replaceRet = GoodsReplaceManager.Instance().GetReplaceResult(client, originGoodsID); if (replaceRet == null || replaceRet.TotalGoodsCnt() < originGoodsNum) { // 物品数量不够 strCmd = string.Format("{0}:{1}:{2}:{3}", -4, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } List <GoodsReplaceResult.ReplaceItem> realCostList = new List <GoodsReplaceResult.ReplaceItem>(); // 1:替换后的绑定材料 // 2:替换后的非绑定材料 // 3:原始绑定材料 // 4:原始非绑定材料 realCostList.AddRange(replaceRet.BindList); realCostList.AddRange(replaceRet.UnBindList); realCostList.Add(replaceRet.OriginBindGoods); realCostList.Add(replaceRet.OriginUnBindGoods); int hasUseCnt = 0; int stillNeedCnt = originGoodsNum; foreach (var item in realCostList) { if (item.GoodsCnt <= 0) { continue; } int realCostCnt = Math.Min(stillNeedCnt, item.GoodsCnt); if (realCostCnt <= 0) { break; } bool bUsedBinding = false; bool bUsedTimeLimited = 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 bUsedBinding, out bUsedTimeLimited)) { bFailed = true; } } else { if (!GameManager.ClientMgr.NotifyUseNotBindGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, item.GoodsID, realCostCnt, false, out bUsedBinding, out bUsedTimeLimited)) { bFailed = true; } } stillNeedCnt -= realCostCnt; if (bFailed) { strCmd = string.Format("{0}:{1}:{2}:{3}", -5, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } } } else { // 获取进阶需要的钻石数量 int nReqZuanShi = upStarXmlItem.GetIntValue("NeedZuanShi"); if (nReqZuanShi <= 0) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } // 判断用户点卷额是否不足【钻石】 if (client.ClientData.UserMoney < nReqZuanShi) { //用户点卷额不足【钻石】 strCmd = string.Format("{0}:{1}:{2}:{3}", -6, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } //先DBServer请求扣费 //扣除用户点卷 if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, nReqZuanShi, "翅膀进阶")) { //扣除用户点卷失败 strCmd = string.Format("{0}:{1}:{2}:{3}", -7, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } } int nLuckOne = upStarXmlItem.GetIntValue("LuckyOne"); int nLuckyTwo = upStarXmlItem.GetIntValue("LuckyTwo"); int nLuckTwoRate = (int)(upStarXmlItem.GetDoubleValue("LuckyTwoRate") * 100.0); int nNextWingID = client.ClientData.MyWingData.WingID; int nNextJinJieFailedNum = client.ClientData.MyWingData.JinJieFailedNum; int nNextStarLevel = client.ClientData.MyWingData.ForgeLevel; int nNextStarExp = client.ClientData.MyWingData.StarExp; // LuckyOne+提升获得幸运点 < LuckyTwo;必定不会提升成功 if (nLuckOne + client.ClientData.MyWingData.JinJieFailedNum < nLuckyTwo) { // 幸运点加1 nNextJinJieFailedNum++; } // LuckyOne+提升获得幸运点>= LuckyTwo,则根据配置得到LuckyTwoRate概率判定是否能够完成进阶操作 else if (nLuckOne + client.ClientData.MyWingData.JinJieFailedNum < 110000) { // int nRandNum = Global.GetRandomNumber(0, 100); if (nRandNum < nLuckTwoRate) { // 进阶成功 nNextWingID++; // 幸运点清0 nNextJinJieFailedNum = 0; // 星级清0 nNextStarLevel = 0; // 星级经验清0 nNextStarExp = 0; } else { // 幸运点加1 nNextJinJieFailedNum++; } } // LuckyOne+提升获得幸运点>=110000时,进阶必定成功 else { // 进阶成功 nNextWingID++; // 幸运点清0 nNextJinJieFailedNum = 0; // 星级清0 nNextStarLevel = 0; // 星级经验清0 nNextStarExp = 0; } // 七日活动 // 翅膀升级和升阶次数,成功失败都算 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingSuitStarTimes)); // 将改变保存到数据库 int iRet = MUWingsManager.WingUpDBCommand(client, client.ClientData.MyWingData.DbID, nNextWingID, nNextJinJieFailedNum, nNextStarLevel, nNextStarExp, client.ClientData.MyWingData.ZhuLingNum, client.ClientData.MyWingData.ZhuHunNum); if (iRet < 0) { strCmd = string.Format("{0}:{1}:{2}:{3}", -3, nRoleID, 0, 0); client.sendCmd(nID, strCmd); return(true); } else { strCmd = string.Format("{0}:{1}:{2}:{3}", 0, nRoleID, nNextWingID, nNextJinJieFailedNum); client.sendCmd(nID, strCmd); client.ClientData.MyWingData.JinJieFailedNum = nNextJinJieFailedNum; if (client.ClientData.MyWingData.WingID != nNextWingID) { // 先移除原来的属性 if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, false); } bool oldWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu); // 更新翅膀的新等级,星数 client.ClientData.MyWingData.WingID = nNextWingID; client.ClientData.MyWingData.ForgeLevel = 0; client.ClientData.MyWingData.StarExp = 0; // 七日活动 GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.WingLevel)); bool newWingLingYuOpened = GlobalNew.IsGongNengOpened(client, GongNengIDs.WingLingYu); if (!oldWingLingYuOpened && newWingLingYuOpened) { //翎羽功能开启了,初始化 LingYuManager.InitAsOpened(client); } // 按新等级增加属性 if (1 == client.ClientData.MyWingData.Using) { MUWingsManager.UpdateWingDataProps(client, true); //升阶时候,翅膀的基础属性的改变会影响注魂加成 ZhuLingZhuHunManager.UpdateZhuLingZhuHunProps(client); // 通知客户端属性变化 GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); // 总生命值和魔法值变化通知(同一个地图才需要通知) GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); } //[bing] 刷新客户端活动叹号 if (client._IconStateMgr.CheckJieRiFanLi(client, ActivityTypes.JieriWing)) { client._IconStateMgr.AddFlushIconState((ushort)ActivityTipTypes.JieRiActivity, client._IconStateMgr.IsAnyJieRiTipActived()); client._IconStateMgr.SendIconStateToClient(client); } } } return(true); }
public bool ExecLianZhi(GameClient client, int type, int count) { int roleID = client.ClientData.RoleID; int vipLevel = client.ClientData.VipLevel; int nID = 668; string useMsg = "炼制系统"; List <int> result = new List <int>(); result.Add(1); result.Add(type); result.Add(count); if (!this.ConfigLoadSuccess) { result[0] = -3; client.sendCmd <List <int> >(nID, result, false); } else if (type < 0 || type > 2) { result[0] = -5; client.sendCmd <List <int> >(nID, result, false); } else { int needJinBi = 0; int needBangZuan = 0; int needZuanShi = 0; long addExp = 0L; int addXingHun = 0; int addJinBi = 0; int lianZhiCount = 0; int lianZhiDayID = -1; int lianZhiMaxCount = 0; int dayID = TimeUtil.NowDateTime().DayOfYear; if (type == 0) { useMsg = "金币炼制"; lianZhiCount = Global.GetRoleParamsInt32FromDB(client, "LianZhiJinBiCount"); lianZhiDayID = Global.GetRoleParamsInt32FromDB(client, "LianZhiJinBiDayID"); lianZhiMaxCount = this.JinBiLianZhi[2] + this.VIPJinBiLianZhi[Math.Min(this.VIPJinBiLianZhi.Length - 1, vipLevel)]; needJinBi = this.JinBiLianZhi[0]; addExp = (long)this.JinBiLianZhi[1]; ProcessTask.ProcessAddTaskVal(client, TaskTypes.LianZhi_JinBi, -1, 1, new object[0]); double awardmuti = 0.0; double awardmuticount = 0.0; double awardcount = 0.0; JieRiMultAwardActivity activity = HuodongCachingMgr.GetJieRiMultAwardActivity(); if (null != activity) { JieRiMultConfig config = activity.GetConfig(6); if (null != config) { awardmuticount += config.GetMult(); } config = activity.GetConfig(9); if (null != config) { awardmuti += config.GetMult(); } } SpecPriorityActivity spAct = HuodongCachingMgr.GetSpecPriorityActivity(); if (null != spAct) { awardmuti += spAct.GetMult(SpecPActivityBuffType.SPABT_ZhuanHuanAward); awardcount += spAct.GetMult(SpecPActivityBuffType.SPABT_ZhuanHuanCount); } awardmuti = Math.Max(1.0, awardmuti); awardmuticount = Math.Max(1.0, awardmuticount); addExp = (long)((int)((double)addExp * awardmuti)); lianZhiMaxCount = lianZhiMaxCount * (int)awardmuticount + (int)awardcount; } else if (type == 1) { useMsg = "绑钻炼制"; lianZhiCount = Global.GetRoleParamsInt32FromDB(client, "LianZhiBangZuanCount"); lianZhiDayID = Global.GetRoleParamsInt32FromDB(client, "LianZhiBangZuanDayID"); lianZhiMaxCount = this.BangZuanLianZhi[2] + this.VIPBangZuanLianZhi[Math.Min(this.VIPBangZuanLianZhi.Length - 1, vipLevel)]; needBangZuan = this.BangZuanLianZhi[0]; addXingHun = this.BangZuanLianZhi[1]; double awardmuti = 0.0; double awardmuticount = 0.0; double awardcount = 0.0; JieRiMultAwardActivity activity = HuodongCachingMgr.GetJieRiMultAwardActivity(); if (null != activity) { JieRiMultConfig config = activity.GetConfig(6); if (null != config) { awardmuticount += config.GetMult(); } config = activity.GetConfig(9); if (null != config) { awardmuti += config.GetMult(); } } SpecPriorityActivity spAct = HuodongCachingMgr.GetSpecPriorityActivity(); if (null != spAct) { awardmuti += spAct.GetMult(SpecPActivityBuffType.SPABT_ZhuanHuanAward); awardcount += spAct.GetMult(SpecPActivityBuffType.SPABT_ZhuanHuanCount); } awardmuti = Math.Max(1.0, awardmuti); awardmuticount = Math.Max(1.0, awardmuticount); addXingHun = (int)((double)addXingHun * awardmuti); lianZhiMaxCount = lianZhiMaxCount * (int)awardmuticount + (int)awardcount; } else if (type == 2) { useMsg = "钻石炼制"; lianZhiCount = Global.GetRoleParamsInt32FromDB(client, "LianZhiZuanShiCount"); lianZhiDayID = Global.GetRoleParamsInt32FromDB(client, "LianZhiZuanShiDayID"); lianZhiMaxCount = this.ZuanShiLianZhi[4] + this.VIPZuanShiLianZhi[Math.Min(this.VIPZuanShiLianZhi.Length - 1, vipLevel)]; needZuanShi = this.ZuanShiLianZhi[0]; addExp = (long)this.ZuanShiLianZhi[1]; addXingHun = this.ZuanShiLianZhi[2]; addJinBi = this.ZuanShiLianZhi[3]; double awardmuti = 0.0; double awardmuticount = 0.0; double awardcount = 0.0; JieRiMultAwardActivity activity = HuodongCachingMgr.GetJieRiMultAwardActivity(); if (null != activity) { JieRiMultConfig config = activity.GetConfig(6); if (null != config) { awardmuticount += config.GetMult(); } config = activity.GetConfig(9); if (null != config) { awardmuti += config.GetMult(); } } SpecPriorityActivity spAct = HuodongCachingMgr.GetSpecPriorityActivity(); if (null != spAct) { awardmuti += spAct.GetMult(SpecPActivityBuffType.SPABT_ZhuanHuanAward); awardcount += spAct.GetMult(SpecPActivityBuffType.SPABT_ZhuanHuanCount); } awardmuti = Math.Max(1.0, awardmuti); awardmuticount = Math.Max(1.0, awardmuticount); addExp = (long)((int)((double)addExp * awardmuti)); addXingHun = (int)((double)addXingHun * awardmuti); addJinBi = (int)((double)addJinBi * awardmuti); lianZhiMaxCount = lianZhiMaxCount * (int)awardmuticount + (int)awardcount; } if (lianZhiDayID != dayID) { lianZhiCount = 0; } if (count <= 0) { count = lianZhiMaxCount - lianZhiCount; } if (count <= 0 || lianZhiCount + count > lianZhiMaxCount) { result[0] = -16; client.sendCmd <List <int> >(nID, result, false); } else { needJinBi *= count; needBangZuan *= count; needZuanShi *= count; addExp *= (long)count; addXingHun *= count; addJinBi *= count; addExp = Global.GetExpMultiByZhuanShengExpXiShu(client, addExp); if (needJinBi > 0 && !Global.SubBindTongQianAndTongQian(client, needJinBi, useMsg)) { result[0] = -9; client.sendCmd <List <int> >(nID, result, false); } else if (needBangZuan > 0 && !GameManager.ClientMgr.SubUserGold(client, needBangZuan, useMsg)) { result[0] = -17; client.sendCmd <List <int> >(nID, result, false); } else if (needZuanShi > 0 && !GameManager.ClientMgr.SubUserMoney(client, needZuanShi, useMsg, true, true, true, true, DaiBiSySType.None)) { result[0] = -10; client.sendCmd <List <int> >(nID, result, false); } else { if (addExp > 0L) { GameManager.ClientMgr.ProcessRoleExperience(client, addExp, true, true, false, "none"); } if (addJinBi > 0) { GameManager.ClientMgr.AddMoney1(client, addJinBi, useMsg, true); } if (addXingHun > 0) { GameManager.ClientMgr.ModifyStarSoulValue(client, addXingHun, useMsg, true, true); } lianZhiCount += count; lianZhiDayID = dayID; if (type == 0) { GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.JinBiZhuanHuanTimes)); Global.SaveRoleParamsInt32ValueToDB(client, "LianZhiJinBiCount", lianZhiCount, true); Global.SaveRoleParamsInt32ValueToDB(client, "LianZhiJinBiDayID", lianZhiDayID, true); } else if (type == 1) { GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.BangZuanZhuanHuanTimes)); Global.SaveRoleParamsInt32ValueToDB(client, "LianZhiBangZuanCount", lianZhiCount, true); Global.SaveRoleParamsInt32ValueToDB(client, "LianZhiBangZuanDayID", lianZhiDayID, true); } else if (type == 2) { GlobalEventSource.getInstance().fireEvent(SevenDayGoalEvPool.Alloc(client, ESevenDayGoalFuncType.ZuanShiZhuanHuanTimes)); Global.SaveRoleParamsInt32ValueToDB(client, "LianZhiZuanShiCount", lianZhiCount, true); Global.SaveRoleParamsInt32ValueToDB(client, "LianZhiZuanShiDayID", lianZhiDayID, true); } client.sendCmd <List <int> >(nID, result, false); } } } return(true); }