Пример #1
0
        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);
                }
            }
        }
Пример #2
0
 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);
 }
Пример #3
0
 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);
 }
Пример #4
0
 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);
 }
Пример #5
0
 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);
 }
Пример #6
0
        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);
        }