public void RemoveTarotKingData(GameClient client) { TarotSystemData tarotData = client.ClientData.TarotData; if (tarotData.KingData.StartTime != 0L) { long nowTicks = TimeUtil.NOW(); if (nowTicks - tarotData.KingData.StartTime >= tarotData.KingData.BufferSecs * 1000L) { tarotData.KingData = new TarotKingData(); this.UpdataPalyerTarotAttr(client); TarotManager.UpdateTarotData2DB(client, null, tarotData.KingData); } } }
public TarotManager.ETarotResult ProcessSetTarotPosCmd(GameClient client, int goodID, byte pos) { TarotManager.ETarotResult result; if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.TarotCard, false)) { result = TarotManager.ETarotResult.NotOpen; } else if (pos < 0 || pos > 6) { result = TarotManager.ETarotResult.Error; } else { TarotSystemData tarotData = client.ClientData.TarotData; TarotCardData currentTarot = tarotData.TarotCardDatas.Find((TarotCardData x) => x.GoodId == goodID); if (currentTarot == null) { result = TarotManager.ETarotResult.Error; } else if (currentTarot.Postion == pos) { result = TarotManager.ETarotResult.Error; } else { if (pos > 0) { if (currentTarot.Postion > 0) { return(TarotManager.ETarotResult.Error); } TarotCardData targetTarot = tarotData.TarotCardDatas.Find((TarotCardData x) => x.Postion == pos); if (targetTarot != null) { targetTarot.Postion = 0; } } currentTarot.Postion = pos; this.UpdataPalyerTarotAttr(client); TarotManager.UpdateTarotData2DB(client, currentTarot, null); result = TarotManager.ETarotResult.Success; } } return(result); }
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 TarotManager.ETarotResult ProcessUseKingPrivilegeCmd(GameClient client, out string strret) { strret = string.Empty; TarotManager.ETarotResult result; if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.TarotCard, false)) { result = TarotManager.ETarotResult.NotOpen; } else { TarotSystemData tarotData = client.ClientData.TarotData; if (tarotData.KingData.StartTime > 0L) { tarotData.KingData = new TarotKingData(); this.UpdataPalyerTarotAttr(client); TarotManager.UpdateTarotData2DB(client, null, tarotData.KingData); result = TarotManager.ETarotResult.Success; } else { int kingItemCount = Global.GetTotalGoodsCountByID(client, TarotManager.KingItemId); if (kingItemCount < TarotManager.UseKingItemCount) { result = TarotManager.ETarotResult.ItemNotEnough; } else { bool usedBinding = false; bool usedTimeLimited = false; if (Global.UseGoodsBindOrNot(client, TarotManager.KingItemId, TarotManager.UseKingItemCount, true, out usedBinding, out usedTimeLimited) < 1) { result = TarotManager.ETarotResult.NeedPart; } else { tarotData.KingData.StartTime = TimeUtil.NOW(); tarotData.KingData.BufferSecs = TarotManager.KingBuffTime; TarotManager.TarotCardIds = Global.RandomSortList <int>(TarotManager.TarotCardIds); TarotManager.KingBuffValueList = Global.RandomSortList <int>(TarotManager.KingBuffValueList); tarotData.KingData.AddtionDict = new Dictionary <int, int>(); int totalNum = TarotManager.KingBuffValueList[0]; if (totalNum < 3) { result = TarotManager.ETarotResult.Error; } else { for (int i = 0; i < 3; i++) { int ranNum; if (i < 2) { ranNum = Global.GetRandomNumber(0, totalNum - 3); totalNum -= ranNum; } else { ranNum = totalNum - 3; } int ranGoodId = TarotManager.TarotCardIds[i]; object obj = strret; strret = string.Concat(new object[] { obj, ranGoodId, ":", ranNum + 1, ":" }); tarotData.KingData.AddtionDict.Add(ranGoodId, ranNum + 1); } this.UpdataPalyerTarotAttr(client); TarotManager.UpdateTarotData2DB(client, null, tarotData.KingData); strret = strret.TrimEnd(new char[] { ':' }); result = TarotManager.ETarotResult.Success; } } } } } return(result); }