public void UpdateHolyItemBuJianAttr(GameClient client, sbyte sShenWu_slot, sbyte sBuJian_slot) { Dictionary <sbyte, HolyItemData> holyitemdata = client.ClientData.MyHolyItemDataDic; if (null != holyitemdata) { HolyItemData tmpdata = null; HolyItemPartData tmppartdata = null; if (holyitemdata.TryGetValue(sShenWu_slot, out tmpdata)) { if (tmpdata.m_PartArray.TryGetValue(sBuJian_slot, out tmppartdata)) { int nDataID = HolyPartInfo.GetBujianID(sShenWu_slot, sBuJian_slot, tmppartdata.m_sSuit); HolyPartInfo nXmlData = null; if (this._partDataDic.TryGetValue(nDataID, out nXmlData)) { for (int i = 0; i < nXmlData.m_PropertyList.Count; i++) { this.ProcessAction(client, nXmlData.m_PropertyList[i].MagicActionID, nXmlData.m_PropertyList[i].MagicActionParams, 16, sShenWu_slot, sBuJian_slot); } } } } } }
//更新某个圣物某个部件属性 public void UpdateHolyItemBuJianAttr(GameClient client, sbyte sShenWu_slot, sbyte sBuJian_slot) { Dictionary <sbyte, HolyItemData> holyitemdata = client.ClientData.MyHolyItemDataDic; if (null == holyitemdata) { return; } HolyItemData tmpdata = null; HolyItemPartData tmppartdata = null; if (true == holyitemdata.TryGetValue(sShenWu_slot, out tmpdata)) { if (true == tmpdata.m_PartArray.TryGetValue(sBuJian_slot, out tmppartdata)) { int nDataID = HolyPartInfo.GetBujianID(sShenWu_slot, sBuJian_slot, (sbyte)tmppartdata.m_sSuit); HolyPartInfo nXmlData = null; if (false == _partDataDic.TryGetValue(nDataID, out nXmlData)) { return; } for (int i = 0; i < nXmlData.m_PropertyList.Count; ++i) { ProcessAction( client , nXmlData.m_PropertyList[i].MagicActionID , nXmlData.m_PropertyList[i].MagicActionParams , (int)PropsSystemTypes.HolyItem , sShenWu_slot , sBuJian_slot); } } } }
//圣物进阶 private EHolyResult HolyItem_Suit_Up(GameClient client, sbyte sShengWu_slot, sbyte sBuJian_slot) { // 如果1.7的功能没开放 if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot7)) { return(EHolyResult.NotOpen); } //增加系统开启判断 if (false == GameManager.VersionSystemOpenMgr.IsVersionSystemOpen(VersionSystemOpenKey.HolyItem)) { return(EHolyResult.NotOpen); } //不满足任务条件 if (GlobalNew.IsGongNengOpened(client, GongNengIDs.HolyItem, true) == false) { return(EHolyResult.NotOpen); } if (null == client.ClientData.MyHolyItemDataDic) { return(EHolyResult.Error); } Dictionary <sbyte, HolyItemData> holyitemdata = client.ClientData.MyHolyItemDataDic; HolyItemData tmpdata = null; HolyItemPartData tmppartdata = null; HolyPartInfo xmlData = null; //先取得当前圣物部件等级 if (false == holyitemdata.TryGetValue(sShengWu_slot, out tmpdata)) { return(EHolyResult.Error); } if (false == tmpdata.m_PartArray.TryGetValue(sBuJian_slot, out tmppartdata)) { return(EHolyResult.Error); } //0 看看要升级的部件阶级是不是已经满级了 if (tmppartdata.m_sSuit >= MAX_HOLY_PART_LEVEL) { return(EHolyResult.PartSuitIsMax); } int nDataID = HolyPartInfo.GetBujianID(sShengWu_slot, sBuJian_slot, (sbyte)tmppartdata.m_sSuit); if (false == _partDataDic.TryGetValue(nDataID, out xmlData)) { return(EHolyResult.Error); } //1 绑金+金币是否足够 if (-1 != xmlData.m_nCostBandJinBi && xmlData.m_nCostBandJinBi > Global.GetTotalBindTongQianAndTongQianVal(client)) { return(EHolyResult.NeedGold); } //2 部件碎片是否足够 if (-1 != xmlData.m_nNeedGoodsCount && xmlData.m_nNeedGoodsCount > tmppartdata.m_nSlice) { return(EHolyResult.NeedHolyItemPart); } //3 以上均满足,判断成功率 bool bSuccess = false; int nRank = Global.GetRandomNumber(0, 100); if (-1 == xmlData.m_sSuccessProbability || tmppartdata.m_nFailCount >= xmlData.m_nMaxFailCount || //[bing] 2015,8,12 达到连续失败最大次数必成功 nRank < (int)(xmlData.m_sSuccessProbability)) { //4 合成成功:消耗金币、消耗部件碎片,阶数+1 bSuccess = true; //扣除金币 if (-1 != xmlData.m_nCostBandJinBi) { if (!Global.SubBindTongQianAndTongQian(client, xmlData.m_nCostBandJinBi, "圣物部件升级消耗")) { return(EHolyResult.Error); } } //扣除部件碎片 if (-1 != xmlData.m_nNeedGoodsCount) { tmppartdata.m_nSlice -= xmlData.m_nNeedGoodsCount; } if (tmppartdata.m_nSlice < 0) { tmppartdata.m_nSlice = 0; return(EHolyResult.Error); } //部件阶级提升 tmppartdata.m_sSuit += 1; //重置失败次数 tmppartdata.m_nFailCount = 0; } else { //5 合成失败:消耗金币、消耗部分部件碎片 //扣除金币 if (-1 != xmlData.m_nCostBandJinBi) { if (!Global.SubBindTongQianAndTongQian(client, xmlData.m_nCostBandJinBi, "圣物部件升级消耗")) { return(EHolyResult.Error); } } //扣除失败时的部件碎片 if (-1 != xmlData.m_nFailCostGoodsCount) { tmppartdata.m_nSlice -= xmlData.m_nFailCostGoodsCount; } if (tmppartdata.m_nSlice < 0) { tmppartdata.m_nSlice = 0; return(EHolyResult.Error); } //失败次数增加1 tmppartdata.m_nFailCount += 1; } if (true == bSuccess) { //计算部件属性 UpdateHolyItemBuJianAttr(client, sShengWu_slot, sBuJian_slot); //计算圣物额外属性 UpdataHolyItemExAttr(client, sShengWu_slot); // 通知客户端属性变化 GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); // 总生命值和魔法值变化通知(同一个地图才需要通知) GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); } //更新db UpdateHolyItemData2DB(client, sShengWu_slot, sBuJian_slot, tmppartdata); //发送给客户端更新数据 HolyItemSendToClient(client, sShengWu_slot, sBuJian_slot); //写log做进阶统计 GameManager.logDBCmdMgr.AddDBLogInfo( -1 , SliceNameSet[sShengWu_slot, sBuJian_slot] , /**/ "圣物进阶" , /**/ "系统" , client.ClientData.RoleName , bSuccess == true ? /**/ "成功" : /**/ "失败" , xmlData.m_nCostBandJinBi != -1 ? xmlData.m_nCostBandJinBi : 0 //消耗的金币数 , client.ClientData.ZoneID , client.strUserID , tmppartdata.m_nSlice , client.ServerId); if (client._IconStateMgr.CheckSpecialActivity(client)) { client._IconStateMgr.SendIconStateToClient(client); } return(bSuccess == true ? EHolyResult.Success : EHolyResult.Fail); }
//初始化静态数据 public void Initialize() { //从BuJian.xml读取数据 SystemXmlItems xml = new SystemXmlItems(); xml.LoadFromXMlFile("Config/BuJian.xml", "", "ID"); foreach (KeyValuePair <int, SystemXmlItem> item in xml.SystemXmlItemDict) { HolyPartInfo data = new HolyPartInfo(); data.m_nCostBandJinBi = item.Value.GetIntValue("CostBandJinBi"); //if (data.m_nCostBandJinBi < 0) //data.m_nCostBandJinBi = 0; data.m_sSuccessProbability = Convert.ToSByte(item.Value.GetDoubleValue("SuccessProbability") * 100); if (data.m_sSuccessProbability < 0) { data.m_sSuccessProbability = -1; } string[] strfiled = item.Value.GetStringValue("NeedGoods").Split(','); if (strfiled.Length > 1) { //data.m_nNeedGoodsID = Global.SafeConvertToInt32(strfiled[0]); data.m_nNeedGoodsCount = Global.SafeConvertToInt32(strfiled[1]); } strfiled = item.Value.GetStringValue("FailCost").Split(','); if (strfiled.Length > 1) { //data.m_nFailCostGoodsID = Global.SafeConvertToInt32(strfiled[0]); data.m_nFailCostGoodsCount = Global.SafeConvertToInt32(strfiled[1]); } string strParam = item.Value.GetStringValue("Property"); if (strParam != "-1") { data.m_PropertyList = GameManager.SystemMagicActionMgr.ParseActionsOutUse(strParam); } data.m_nMaxFailCount = item.Value.GetIntValue("FailMaxNum"); if (data.m_nMaxFailCount < 0) { data.m_nMaxFailCount = 0; } _partDataDic.Add(item.Value.GetIntValue("ID"), data); } //从ShengWu.xml读取数据 xml = new SystemXmlItems(); xml.LoadFromXMlFile("Config/ShengWu.xml", "", "ID"); foreach (KeyValuePair <int, SystemXmlItem> item in xml.SystemXmlItemDict) { HolyInfo data = new HolyInfo(); string strParam = item.Value.GetStringValue("ExtraProperty"); if (strParam != "-1") { data.m_ExtraPropertyList = GameManager.SystemMagicActionMgr.ParseActionsOutUse(strParam); } _holyDataDic.Add(item.Value.GetIntValue("ID"), data); } TCPCmdDispatcher.getInstance().registerProcessorEx((int)TCPGameServerCmds.CMD_DB_UPDATE_HOLYITEM, 2, 2, getInstance()); }
public void Initialize() { SystemXmlItems xml = new SystemXmlItems(); xml.LoadFromXMlFile("Config/BuJian.xml", "", "ID", 0); foreach (KeyValuePair <int, SystemXmlItem> item in xml.SystemXmlItemDict) { HolyPartInfo data = new HolyPartInfo(); data.m_nCostBandJinBi = item.Value.GetIntValue("CostBandJinBi", -1); data.m_sSuccessProbability = Convert.ToSByte(item.Value.GetDoubleValue("SuccessProbability") * 100.0); if (data.m_sSuccessProbability < 0) { data.m_sSuccessProbability = -1; } string[] strfiled = item.Value.GetStringValue("NeedGoods").Split(new char[] { ',' }); if (strfiled.Length > 1) { data.m_nNeedGoodsCount = Global.SafeConvertToInt32(strfiled[1]); } strfiled = item.Value.GetStringValue("FailCost").Split(new char[] { ',' }); if (strfiled.Length > 1) { data.m_nFailCostGoodsCount = Global.SafeConvertToInt32(strfiled[1]); } string strParam = item.Value.GetStringValue("Property"); if (strParam != "-1") { data.m_PropertyList = GameManager.SystemMagicActionMgr.ParseActionsOutUse(strParam); } data.m_nMaxFailCount = item.Value.GetIntValue("FailMaxNum", -1); if (data.m_nMaxFailCount < 0) { data.m_nMaxFailCount = 0; } data.NeedGoods = ConfigParser.ParserIntArrayList(item.Value.GetStringValue("NeedItem"), true, '|', ','); data.FaildNeedGoods = ConfigParser.ParserIntArrayList(item.Value.GetStringValue("FailureConsumption"), true, '|', ','); this._partDataDic.Add(item.Value.GetIntValue("ID", -1), data); int suitID = item.Value.GetIntValue("SuitID", -1); HolyItemManager.MAX_HOLY_PART_LEVEL = Math.Max(HolyItemManager.MAX_HOLY_PART_LEVEL, Convert.ToSByte(suitID)); } HolyItemManager.MAX_HOLY_PART_LEVEL = (sbyte)Global.GMin((int)HolyItemManager.MAX_HOLY_PART_LEVEL, (int)GameManager.systemParamsList.GetParamValueIntByName("ShengWuMax", 0)); xml = new SystemXmlItems(); xml.LoadFromXMlFile("Config/ShengWu.xml", "", "ID", 0); foreach (KeyValuePair <int, SystemXmlItem> item in xml.SystemXmlItemDict) { HolyInfo data2 = new HolyInfo(); string strParam = item.Value.GetStringValue("ExtraProperty"); if (strParam != "-1") { data2.m_ExtraPropertyList = GameManager.SystemMagicActionMgr.ParseActionsOutUse(strParam); } this._holyDataDic.Add(item.Value.GetIntValue("ID", -1), data2); } TCPCmdDispatcher.getInstance().registerProcessorEx(10206, 2, 2, HolyItemManager.getInstance(), TCPCmdFlags.IsStringArrayParams); }
private EHolyResult HolyItem_Suit_Up(GameClient client, sbyte sShengWu_slot, sbyte sBuJian_slot) { EHolyResult result; if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot7)) { result = EHolyResult.NotOpen; } else if (!GameManager.VersionSystemOpenMgr.IsVersionSystemOpen("HolyItem")) { result = EHolyResult.NotOpen; } else if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.HolyItem, true)) { result = EHolyResult.NotOpen; } else if (null == client.ClientData.MyHolyItemDataDic) { result = EHolyResult.Error; } else { Dictionary <sbyte, HolyItemData> holyitemdata = client.ClientData.MyHolyItemDataDic; HolyItemData tmpdata = null; HolyItemPartData tmppartdata = null; HolyPartInfo xmlData = null; if (!holyitemdata.TryGetValue(sShengWu_slot, out tmpdata)) { result = EHolyResult.Error; } else if (!tmpdata.m_PartArray.TryGetValue(sBuJian_slot, out tmppartdata)) { result = EHolyResult.Error; } else if (tmppartdata.m_sSuit >= HolyItemManager.MAX_HOLY_PART_LEVEL) { result = EHolyResult.PartSuitIsMax; } else { int nDataID = HolyPartInfo.GetBujianID(sShengWu_slot, sBuJian_slot, tmppartdata.m_sSuit); if (!this._partDataDic.TryGetValue(nDataID, out xmlData)) { result = EHolyResult.Error; } else if (-1 != xmlData.m_nCostBandJinBi && xmlData.m_nCostBandJinBi > Global.GetTotalBindTongQianAndTongQianVal(client)) { result = EHolyResult.NeedGold; } else if (-1 != xmlData.m_nNeedGoodsCount && xmlData.m_nNeedGoodsCount > tmppartdata.m_nSlice) { result = EHolyResult.NeedHolyItemPart; } else { bool bSuccess = false; int nRank = Global.GetRandomNumber(0, 100); if (-1 == xmlData.m_sSuccessProbability || tmppartdata.m_nFailCount >= xmlData.m_nMaxFailCount || nRank < (int)xmlData.m_sSuccessProbability) { bSuccess = true; for (int i = 0; i < xmlData.NeedGoods.Count; i++) { int goodsId = xmlData.NeedGoods[i][0]; int costCount = xmlData.NeedGoods[i][1]; int haveGoodsCnt = Global.GetTotalGoodsCountByID(client, goodsId); if (haveGoodsCnt < costCount) { return(EHolyResult.NeedGoods); } } if (-1 != xmlData.m_nCostBandJinBi) { if (!Global.SubBindTongQianAndTongQian(client, xmlData.m_nCostBandJinBi, "圣物部件升级消耗")) { return(EHolyResult.Error); } } if (-1 != xmlData.m_nNeedGoodsCount) { tmppartdata.m_nSlice -= xmlData.m_nNeedGoodsCount; } if (tmppartdata.m_nSlice < 0) { tmppartdata.m_nSlice = 0; return(EHolyResult.Error); } bool bUsedBinding_just_placeholder = false; bool bUsedTimeLimited_just_placeholder = false; for (int i = 0; i < xmlData.NeedGoods.Count; i++) { int goodsId = xmlData.NeedGoods[i][0]; int costCount = xmlData.NeedGoods[i][1]; if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodsId, costCount, false, out bUsedBinding_just_placeholder, out bUsedTimeLimited_just_placeholder, false)) { LogManager.WriteLog(LogTypes.Error, string.Format("圣物部件升级时,消耗{1}个GoodsID={0}的物品失败,但是已设置为升阶成功", goodsId, costCount), null, true); } GoodsData goodsData = new GoodsData(); goodsData.GoodsID = goodsId; goodsData.GCount = costCount; } HolyItemPartData holyItemPartData = tmppartdata; holyItemPartData.m_sSuit += 1; tmppartdata.m_nFailCount = 0; } else { for (int i = 0; i < xmlData.FaildNeedGoods.Count; i++) { int goodsId = xmlData.FaildNeedGoods[i][0]; int costCount = xmlData.FaildNeedGoods[i][1]; int haveGoodsCnt = Global.GetTotalGoodsCountByID(client, goodsId); if (haveGoodsCnt < costCount) { return(EHolyResult.NeedGoods); } } if (-1 != xmlData.m_nCostBandJinBi) { if (!Global.SubBindTongQianAndTongQian(client, xmlData.m_nCostBandJinBi, "圣物部件升级消耗")) { return(EHolyResult.Error); } } bool bUsedBinding_just_placeholder = false; bool bUsedTimeLimited_just_placeholder = false; for (int i = 0; i < xmlData.FaildNeedGoods.Count; i++) { int goodsId = xmlData.FaildNeedGoods[i][0]; int costCount = xmlData.FaildNeedGoods[i][1]; if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodsId, costCount, false, out bUsedBinding_just_placeholder, out bUsedTimeLimited_just_placeholder, false)) { LogManager.WriteLog(LogTypes.Error, string.Format("圣物部件升级时,消耗{1}个GoodsID={0}的物品失败", goodsId, costCount), null, true); } GoodsData goodsData2 = new GoodsData(); goodsData2.GoodsID = goodsId; goodsData2.GCount = costCount; } if (-1 != xmlData.m_nFailCostGoodsCount) { tmppartdata.m_nSlice -= xmlData.m_nFailCostGoodsCount; } if (tmppartdata.m_nSlice < 0) { tmppartdata.m_nSlice = 0; return(EHolyResult.Error); } tmppartdata.m_nFailCount++; } if (bSuccess) { this.UpdateHolyItemBuJianAttr(client, sShengWu_slot, sBuJian_slot); this.UpdataHolyItemExAttr(client, sShengWu_slot); GameManager.ClientMgr.NotifyUpdateEquipProps(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client); GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 7); } this.UpdateHolyItemData2DB(client, sShengWu_slot, sBuJian_slot, tmppartdata); this.HolyItemSendToClient(client, sShengWu_slot, sBuJian_slot); GameManager.logDBCmdMgr.AddDBLogInfo(-1, HolyItemManager.SliceNameSet[(int)sShengWu_slot, (int)sBuJian_slot], "圣物进阶", "系统", client.ClientData.RoleName, bSuccess ? "成功" : "失败", (xmlData.m_nCostBandJinBi != -1) ? xmlData.m_nCostBandJinBi : 0, client.ClientData.ZoneID, client.strUserID, tmppartdata.m_nSlice, client.ServerId, null); if (client._IconStateMgr.CheckSpecialActivity(client) || client._IconStateMgr.CheckEverydayActivity(client)) { client._IconStateMgr.SendIconStateToClient(client); } result = (bSuccess ? EHolyResult.Success : EHolyResult.Fail); } } } return(result); }