public TarotManager.ETarotResult ProcessTarotUpCmd(GameClient client, int goodID) { TarotManager.ETarotResult result; if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.TarotCard, false)) { result = TarotManager.ETarotResult.NotOpen; } else { TarotSystemData tarotData = client.ClientData.TarotData; TarotCardData currentTarot = tarotData.TarotCardDatas.Find((TarotCardData x) => x.GoodId == goodID); if (currentTarot == null) { currentTarot = new TarotCardData(); currentTarot.GoodId = goodID; tarotData.TarotCardDatas.Add(currentTarot); } if (currentTarot.Level >= TarotManager.TarotMaxLevelDict[goodID]) { result = TarotManager.ETarotResult.MaxLevel; } else { TarotManager.TarotTemplate nextTemp = TarotManager.TarotTemplates.Find((TarotManager.TarotTemplate x) => x.GoodsID == goodID && x.Level == currentTarot.Level + 1); if (nextTemp == null) { result = TarotManager.ETarotResult.Error; } else if (currentTarot.TarotMoney < nextTemp.NeedPartCount) { result = TarotManager.ETarotResult.NeedPart; } else { currentTarot.TarotMoney -= nextTemp.NeedPartCount; currentTarot.Level++; this.UpdataPalyerTarotAttr(client); TarotManager.UpdateTarotData2DB(client, currentTarot, null); result = TarotManager.ETarotResult.Success; } } } return(result); }
public TarotManager.ETarotResult ProcessTarotMoneyCmd(GameClient client, int goodId, int num, int dbid, out int resNum) { resNum = 0; TarotManager.ETarotResult result; if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.TarotCard, false)) { result = TarotManager.ETarotResult.NotOpen; } else { GoodsData Data = Global.GetGoodsByDbID(client, dbid); if (Data == null) { result = TarotManager.ETarotResult.Error; } else if (TarotManager.TarotNeedCardNum.ContainsKey(goodId)) { if (num < 0 || num > Data.GCount) { result = TarotManager.ETarotResult.MoneyNumError; } else { TarotManager.TarotTemplate nextTemp = TarotManager.TarotTemplates.Find((TarotManager.TarotTemplate x) => x.NeedGoodID == goodId); if (nextTemp == null) { result = TarotManager.ETarotResult.NotFindGood; } else { TarotSystemData tarotData = client.ClientData.TarotData; TarotCardData currentTarot = tarotData.TarotCardDatas.Find((TarotCardData x) => x.GoodId == nextTemp.GoodsID); if (currentTarot == null) { currentTarot = new TarotCardData(); currentTarot.GoodId = nextTemp.GoodsID; tarotData.TarotCardDatas.Add(currentTarot); } int reNum = TarotManager.TarotNeedCardNum[goodId] - this.CountTarotNowToCurrLevel(goodId, currentTarot.Level) - currentTarot.TarotMoney; if (reNum == 0) { result = TarotManager.ETarotResult.HasMaxNum; } else { if (num > reNum) { num = reNum; } if (GameManager.ClientMgr.NotifyUseGoodsByDbId(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, dbid, num, false, false)) { GoodsData goodsData = Global.GetGoodsByDbID(client, dbid); if (null != goodsData) { resNum = goodsData.GCount; } currentTarot.TarotMoney += num; EventLogManager.AddRoleEvent(client, OpTypes.Trace, OpTags.TarotMoney, LogRecordType.TarotMoney, new object[] { num, currentTarot.TarotMoney, dbid, "塔罗牌货币增加" }); this.UpdataPalyerTarotAttr(client); TarotManager.UpdateTarotData2DB(client, currentTarot, null); GameManager.logDBCmdMgr.AddDBLogInfo(dbid, "塔罗牌货币", "塔罗牌", client.ClientData.RoleName, "系统", "修改", 0, client.ClientData.ZoneID, client.strUserID, num, client.ServerId, null); result = TarotManager.ETarotResult.Success; } else { result = TarotManager.ETarotResult.UseGoodError; } } } } } else { result = TarotManager.ETarotResult.GoodIdError; } } return(result); }
public void Initialize() { string fileName = Global.GameResPath("Config/Tarot.xml"); XElement xml = XElement.Load(fileName); if (null == xml) { throw new Exception(string.Format("加载系统xml配置文件:{0}, 失败。没有找到相关XML配置文件!", fileName)); } IEnumerable <XElement> xmlItems = xml.Elements(); foreach (XElement xmlItem in xmlItems) { TarotManager.TarotTemplate data = new TarotManager.TarotTemplate(); data.Level = Convert.ToInt32(Global.GetSafeAttributeStr(xmlItem, "Level")); if (data.Level != 0) { data.ID = Convert.ToInt32(Global.GetSafeAttributeStr(xmlItem, "ID")); data.Name = Global.GetSafeAttributeStr(xmlItem, "Name"); data.GoodsID = Convert.ToInt32(Global.GetSafeAttributeStr(xmlItem, "GoodsID")); string[] needGoodsInfo = Global.GetSafeAttributeStr(xmlItem, "NeedGoods").Split(new char[] { ',' }); data.NeedGoodID = Convert.ToInt32(needGoodsInfo[0]); data.NeedPartCount = Convert.ToInt32(needGoodsInfo[1]); if (TarotManager.TarotNeedCardNum.ContainsKey(data.NeedGoodID)) { Dictionary <int, int> tarotNeedCardNum; int needGoodID; (tarotNeedCardNum = TarotManager.TarotNeedCardNum)[needGoodID = data.NeedGoodID] = tarotNeedCardNum[needGoodID] + data.NeedPartCount; } else { TarotManager.TarotNeedCardNum.Add(data.NeedGoodID, data.NeedPartCount); } if (TarotManager.TarotMaxLevelDict.ContainsKey(data.GoodsID) && TarotManager.TarotMaxLevelDict[data.GoodsID] < data.Level) { TarotManager.TarotMaxLevelDict[data.GoodsID] = data.Level; } else { TarotManager.TarotMaxLevelDict.Add(data.GoodsID, data.Level); } TarotManager.TarotTemplates.Add(data); } } TarotManager.TarotCardIds = TarotManager.TarotMaxLevelDict.Keys.ToList <int>(); string[] kingCost = GameManager.systemParamsList.GetParamValueByName("TarotKingCost").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); TarotManager.KingItemId = Convert.ToInt32(kingCost[0]); TarotManager.UseKingItemCount = Convert.ToInt32(kingCost[1]); TarotManager.KingBuffTime = (long)(Convert.ToInt32(kingCost[2]) * 60); string[] kingValueInfo = GameManager.systemParamsList.GetParamValueByName("TarotKingNum").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string info in kingValueInfo) { TarotManager.KingBuffValueList.Add(Convert.ToInt32(info)); } TCPCmdDispatcher.getInstance().registerProcessorEx(1701, 1, 1, TarotManager.getInstance(), TCPCmdFlags.IsStringArrayParams); TCPCmdDispatcher.getInstance().registerProcessorEx(1702, 2, 2, TarotManager.getInstance(), TCPCmdFlags.IsStringArrayParams); TCPCmdDispatcher.getInstance().registerProcessorEx(1703, 1, 1, TarotManager.getInstance(), TCPCmdFlags.IsStringArrayParams); TCPCmdDispatcher.getInstance().registerProcessorEx(1704, 1, 1, TarotManager.getInstance(), TCPCmdFlags.IsStringArrayParams); TCPCmdDispatcher.getInstance().registerProcessorEx(1705, 3, 3, TarotManager.getInstance(), TCPCmdFlags.IsStringArrayParams); }