Beispiel #1
0
        /// <summary>
        /// 处理塔罗牌升级或激活
        /// </summary>
        /// <param name="client"></param>
        /// <param name="goodID"></param>
        /// <param name="partCount"></param>
        /// <returns></returns>
        public ETarotResult ProcessTarotUpCmd(GameClient client, int goodID)
        {
            //判断功能是否开启
            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.TarotCard))
            {
                return(ETarotResult.NotOpen);
            }

            TarotSystemData tarotData = client.ClientData.TarotData;
            //获取要升级的塔罗牌数据
            TarotCardData currentTarot = tarotData.TarotCardDatas.Find(x => x.GoodId == goodID);

            if (currentTarot == null)
            {
                //激活
                currentTarot        = new TarotCardData();
                currentTarot.GoodId = goodID;
                tarotData.TarotCardDatas.Add(currentTarot);
            }
            //判断是否可以升级
            if (currentTarot.Level >= TarotMaxLevelDict[goodID])
            {
                return(ETarotResult.MaxLevel);
            }
            //获取下级塔罗牌对应配置模板
            TarotTemplate nextTemp = TarotTemplates.Find(x => x.GoodsID == goodID && x.Level == currentTarot.Level + 1);

            if (nextTemp == null)
            {
                return(ETarotResult.Error);
            }
            //判断背包碎片是否足够
            var hasPartCount = Global.GetTotalGoodsCountByID(client, nextTemp.NeedGoodID);

            if (hasPartCount < nextTemp.NeedPartCount)
            {
                return(ETarotResult.NeedPart);
            }

            //使用物品  优先使用绑定物品
            bool usedBinding     = false;
            bool usedTimeLimited = false;

            if (Global.UseGoodsBindOrNot(client, nextTemp.NeedGoodID, nextTemp.NeedPartCount, true, out usedBinding, out usedTimeLimited) < 1)
            {
                return(ETarotResult.NeedPart);
            }

            //处理升级
            currentTarot.Level += 1;
            //更新玩家数据
            UpdataPalyerTarotAttr(client);
            //向DB服更新数据
            UpdateTarotData2DB(client, currentTarot, null);
            return(ETarotResult.Success);
        }
Beispiel #2
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);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 设置塔罗牌上阵位置 (0=为上阵)
        /// </summary>
        /// <param name="client"></param>
        /// <param name="goodID"></param>
        /// <param name="pos"></param>
        /// <returns></returns>
        public ETarotResult ProcessSetTarotPosCmd(GameClient client, int goodID, byte pos)
        {
            //判断功能是否开启
            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.TarotCard))
            {
                return(ETarotResult.NotOpen);
            }

            //判断位置是否合法
            if (pos < 0 || pos > 6)
            {
                return(ETarotResult.Error);
            }
            TarotSystemData tarotData = client.ClientData.TarotData;
            //获取塔罗牌数据
            TarotCardData currentTarot = tarotData.TarotCardDatas.Find(x => x.GoodId == goodID);

            if (currentTarot == null)
            {
                return(ETarotResult.Error);
            }
            if (currentTarot.Postion == pos)
            {
                return(ETarotResult.Error);
            }
            //上阵
            if (pos > 0)
            {
                //判断当前卡牌是否已在阵上
                if (currentTarot.Postion > 0)
                {
                    return(ETarotResult.Error);
                }
                //判断装备的位置是否为空
                TarotCardData targetTarot = tarotData.TarotCardDatas.Find(x => x.Postion == pos);
                if (targetTarot != null)
                {
                    targetTarot.Postion = 0;
                }
            }
            currentTarot.Postion = pos;
            //更新玩家塔罗牌加成属性
            UpdataPalyerTarotAttr(client);
            //向DB服更新数据
            UpdateTarotData2DB(client, currentTarot, null);

            return(ETarotResult.Success);
        }
Beispiel #4
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);
 }
Beispiel #5
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);
 }
Beispiel #6
0
        /// <summary>
        /// 移除国王特权
        /// </summary>
        /// <param name="client"></param>
        public void RemoveTarotKingData(GameClient client)
        {
            TarotSystemData tarotData = client.ClientData.TarotData;

            if (tarotData.KingData.StartTime == 0)
            {
                return;
            }

            long nowTicks = TimeUtil.NOW();

            if ((nowTicks - tarotData.KingData.StartTime) >= (tarotData.KingData.BufferSecs * 1000))
            {
                tarotData.KingData = new TarotKingData();

                //更新玩家塔罗牌加成属性
                UpdataPalyerTarotAttr(client);

                //向DB服更新数据
                UpdateTarotData2DB(client, null, tarotData.KingData);
            }
        }
Beispiel #7
0
        /// <summary>
        /// 使用国王特权
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public ETarotResult ProcessUseKingPrivilegeCmd(GameClient client, out string strret)
        {
            strret = string.Empty;
            //判断功能是否开启
            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.TarotCard))
            {
                return(ETarotResult.NotOpen);
            }

            TarotSystemData tarotData = client.ClientData.TarotData;

            if (tarotData.KingData.StartTime > 0)
            {
                //重置
                tarotData.KingData = new TarotKingData();
                //更新玩家塔罗牌加成属性
                UpdataPalyerTarotAttr(client);
                //向DB服更新数据
                UpdateTarotData2DB(client, null, tarotData.KingData);
                return(ETarotResult.Success);
            }
            //判断背包碎片是否足够
            var kingItemCount = Global.GetTotalGoodsCountByID(client, KingItemId);

            if (kingItemCount < UseKingItemCount)
            {
                return(ETarotResult.ItemNotEnough);
            }

            //使用物品  优先使用绑定物品
            bool usedBinding     = false;
            bool usedTimeLimited = false;

            if (Global.UseGoodsBindOrNot(client, KingItemId, UseKingItemCount, true, out usedBinding, out usedTimeLimited) < 1)
            {
                return(ETarotResult.NeedPart);
            }

            tarotData.KingData.StartTime = TimeUtil.NOW();

            tarotData.KingData.BufferSecs = KingBuffTime;

            TarotCardIds = Global.RandomSortList(TarotCardIds);

            KingBuffValueList = Global.RandomSortList(KingBuffValueList);

            tarotData.KingData.AddtionDict = new Dictionary <int, int>();

            var totalNum = KingBuffValueList[0];

            if (totalNum < 3)
            {
                return(ETarotResult.Error);
            }

            for (var i = 0; i < 3; i++)
            {
                var ranNum = 1;
                if (i < 2)
                {
                    ranNum    = Global.GetRandomNumber(0, totalNum - 3);
                    totalNum -= ranNum;
                }
                else
                {
                    ranNum = totalNum - 3;
                }

                var ranGoodId = TarotCardIds[i];
                strret += ranGoodId + ":" + (int)(ranNum + 1) + ":";
                tarotData.KingData.AddtionDict.Add(ranGoodId, ranNum + 1);
            }

            //更新玩家塔罗牌加成属性
            UpdataPalyerTarotAttr(client);

            //向DB服更新数据
            UpdateTarotData2DB(client, null, tarotData.KingData);

            strret = strret.TrimEnd(':');

            return(ETarotResult.Success);
        }
Beispiel #8
0
        public bool processCmdEx(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            switch (nID)
            {
            //塔罗牌升级或激活
            case (int)TCPGameServerCmds.CMD_SPR_TAROT_UPORINIT:
            {
                if (cmdParams == null || cmdParams.Length != 1)
                {
                    return(false);
                }

                try
                {
                    int goodID = Convert.ToInt32(cmdParams[0]);
                    var strret = string.Format("{0}:{1}", Convert.ToInt32(ProcessTarotUpCmd(client, goodID)), goodID);

                    client.sendCmd(nID, strret);
                }
                catch (Exception ex)         //解析错误
                {
                    var strret = string.Format("{0}:{1}", (int)ETarotResult.Error, cmdParams[0]);
                    client.sendCmd(nID, strret);
                    DataHelper.WriteFormatExceptionLog(ex, "CMD_SPR_TAROT_UPORINIT", false);
                }
            }
            break;

            case (int)TCPGameServerCmds.CMD_SPR_SET_TAROTPOS:
            {
                if (cmdParams == null || cmdParams.Length != 2)
                {
                    return(false);
                }
                try
                {
                    int  goodID = Convert.ToInt32(cmdParams[0]);
                    byte pos    = Convert.ToByte(cmdParams[1]);

                    var strret = string.Format("{0}:{1}", Convert.ToInt32(ProcessSetTarotPosCmd(client, goodID, pos)), goodID);
                    client.sendCmd(nID, strret);
                }
                catch (Exception ex)         //解析错误
                {
                    var strret = string.Format("{0}:{1}", (int)ETarotResult.Error, cmdParams[0]);
                    client.sendCmd(nID, strret);
                    DataHelper.WriteFormatExceptionLog(ex, "CMD_SPR_SET_TAROTPOS", false);
                }
            }
            break;

            case (int)TCPGameServerCmds.CMD_SPR_USE_TAROTKINGPRIVILEGE:
            {
                try
                {
                    var strret  = string.Empty;
                    var restult = Convert.ToInt32(ProcessUseKingPrivilegeCmd(client, out strret));
                    client.sendCmd(nID, string.Format("{0}:{1}", restult, strret));
                }
                catch (Exception ex)         //解析错误
                {
                    client.sendCmd(nID, ((int)ETarotResult.Error).ToString());
                    DataHelper.WriteFormatExceptionLog(ex, "CMD_SPR_USE_TAROTKINGPRIVILEGE", false);
                }
            }
            break;

            case (int)TCPGameServerCmds.CMD_SPR_TAROT_DATA:
            {
                try
                {
                    TarotSystemData tarotData = client.ClientData.TarotData;
                    client.sendCmd <TarotSystemData>(nID, tarotData);
                }
                catch (Exception ex)         //解析错误
                {
                    client.sendCmd(nID, ((int)ETarotResult.Error).ToString());
                    DataHelper.WriteFormatExceptionLog(ex, "CMD_SPR_USE_TAROTKINGPRIVILEGE", false);
                }
            }
            break;
            }

            return(true);
        }
Beispiel #9
0
        public bool processCmdEx(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            switch (nID)
            {
            case 1701:
                if (cmdParams == null || cmdParams.Length != 1)
                {
                    return(false);
                }
                try
                {
                    int    goodID = Convert.ToInt32(cmdParams[0]);
                    string strret = string.Format("{0}:{1}", Convert.ToInt32(this.ProcessTarotUpCmd(client, goodID)), goodID);
                    client.sendCmd(nID, strret, false);
                }
                catch (Exception ex)
                {
                    string strret = string.Format("{0}:{1}", -1, cmdParams[0]);
                    client.sendCmd(nID, strret, false);
                    DataHelper.WriteFormatExceptionLog(ex, "CMD_SPR_TAROT_UPORINIT", false, false);
                }
                break;

            case 1702:
                if (cmdParams == null || cmdParams.Length != 2)
                {
                    return(false);
                }
                try
                {
                    int    goodID = Convert.ToInt32(cmdParams[0]);
                    byte   pos    = Convert.ToByte(cmdParams[1]);
                    string strret = string.Format("{0}:{1}", Convert.ToInt32(this.ProcessSetTarotPosCmd(client, goodID, pos)), goodID);
                    client.sendCmd(nID, strret, false);
                }
                catch (Exception ex)
                {
                    string strret = string.Format("{0}:{1}", -1, cmdParams[0]);
                    client.sendCmd(nID, strret, false);
                    DataHelper.WriteFormatExceptionLog(ex, "CMD_SPR_SET_TAROTPOS", false, false);
                }
                break;

            case 1703:
                try
                {
                    string strret  = string.Empty;
                    int    restult = Convert.ToInt32(this.ProcessUseKingPrivilegeCmd(client, out strret));
                    client.sendCmd(nID, string.Format("{0}:{1}", restult, strret), false);
                }
                catch (Exception ex)
                {
                    client.sendCmd(nID, -1);
                    DataHelper.WriteFormatExceptionLog(ex, "CMD_SPR_USE_TAROTKINGPRIVILEGE", false, false);
                }
                break;

            case 1704:
                try
                {
                    TarotSystemData tarotData = client.ClientData.TarotData;
                    client.sendCmd <TarotSystemData>(nID, tarotData, false);
                }
                catch (Exception ex)
                {
                    client.sendCmd(nID, -1);
                    DataHelper.WriteFormatExceptionLog(ex, "CMD_SPR_USE_TAROTKINGPRIVILEGE", false, false);
                }
                break;

            case 1705:
                if (cmdParams == null || cmdParams.Length != 3)
                {
                    return(false);
                }
                try
                {
                    int    dbid    = Convert.ToInt32(cmdParams[0]);
                    int    goodID  = Convert.ToInt32(cmdParams[1]);
                    int    num     = Convert.ToInt32(cmdParams[2]);
                    int    resNum  = 0;
                    int    restult = Convert.ToInt32(this.ProcessTarotMoneyCmd(client, goodID, num, dbid, out resNum));
                    string strret  = string.Format("{0}:{1}:{2}:{3}", new object[]
                    {
                        restult,
                        goodID,
                        resNum,
                        dbid
                    });
                    client.sendCmd(nID, strret, false);
                }
                catch (Exception ex)
                {
                    client.sendCmd(nID, -1);
                    DataHelper.WriteFormatExceptionLog(ex, "CMD_SPR_TAROT_MONEY_NUM", false, false);
                }
                break;
            }
            return(true);
        }
Beispiel #10
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);
 }
Beispiel #11
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);
 }