Exemple #1
0
 public bool processCmdEx(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         if (nID == 2082)
         {
             BuyBoCaiResult mgsData   = new BuyBoCaiResult();
             int            BocaiType = Convert.ToInt32(cmdParams[1]);
             int            BuyNum    = Convert.ToInt32(cmdParams[2]);
             string         strBuyVal = cmdParams[3];
             mgsData.BocaiType = BocaiType;
             if (2 == BocaiType)
             {
                 this.BuyCaiShuzi(client, BuyNum, strBuyVal, ref mgsData);
             }
             else if (1 == BocaiType)
             {
                 this.BuyCaiDaXiao(client, BuyNum, strBuyVal, ref mgsData);
             }
             else
             {
                 mgsData.Info = 1;
             }
             client.sendCmd <BuyBoCaiResult>(nID, mgsData, false);
         }
         else if (nID == 2083)
         {
             GetBoCaiResult mgsData2 = new GetBoCaiResult();
             this.GetBoCai(client, nID, cmdParams, ref mgsData2);
             client.sendCmd <GetBoCaiResult>(nID, mgsData2, false);
         }
         else if (nID == 2086)
         {
             client.sendCmd(nID, this.BuyItem(client, nID, cmdParams), false);
         }
         else if (nID == 2085)
         {
             this.GetShopInfo(client, nID, client.ClientData.RoleID);
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_博彩]{0}", ex.ToString()), null, true);
     }
     return(true);
 }
Exemple #2
0
 private void BuyCaiDaXiao(GameClient client, int BuyNum, string strBuyVal, ref BuyBoCaiResult mgsData)
 {
     try
     {
         int value = Convert.ToInt32(strBuyVal);
         if (1 > value || value > 3 || BuyNum < 1)
         {
             mgsData.Info = 2;
             LogManager.WriteLog(LogTypes.Warning, string.Format("[ljl_博彩]BuyCaiDaXiao 购买内容 {0}, BuyNum={1} ", strBuyVal, BuyNum), null, true);
         }
         else if (!BoCaiCaiDaXiao.GetInstance().IsCanBuy())
         {
             mgsData.Info = 7;
         }
         else
         {
             ReturnValue <bool> msgData = TcpCall.KFBoCaiManager.IsCanBuy(1, strBuyVal, BuyNum + BoCaiCaiDaXiao.GetInstance().GetBuyNum(client.ClientData.RoleID), BoCaiCaiDaXiao.GetInstance().GetDataPeriods());
             if (!msgData.IsReturn)
             {
                 mgsData.Info = 8;
             }
             else if (!msgData.Value)
             {
                 mgsData.Info = 7;
             }
             else
             {
                 int useItemNum = BoCaiCaiDaXiao.GetInstance().GetXiaoHaoDaiBi() * BuyNum;
                 if (useItemNum < 1)
                 {
                     mgsData.Info = 3;
                     LogManager.WriteLog(LogTypes.Error, "[ljl_博彩]XiaoHaoDaiBi /GuDingLeiXing<1", null, true);
                 }
                 else if (!HuanLeDaiBiManager.GetInstance().HuanledaibiEnough(client, useItemNum))
                 {
                     mgsData.Info = 4;
                 }
                 else
                 {
                     int          allNum = BuyNum;
                     BuyBoCai2SDB DbData = BoCaiCaiDaXiao.GetInstance().BuyBocai(client, BuyNum, strBuyVal, ref allNum);
                     if (null == DbData)
                     {
                         mgsData.Info = 8;
                         BoCaiCaiDaXiao.GetInstance().BuyBocai(client, -BuyNum, strBuyVal, ref allNum);
                         LogManager.WriteLog(LogTypes.Error, "[ljl_博彩]BoCaiCaiDaXiao.GetInstance().BuyBocai err", null, true);
                     }
                     else if (!HuanLeDaiBiManager.GetInstance().UseHuanledaibi(client, useItemNum))
                     {
                         mgsData.Info = 4;
                     }
                     else
                     {
                         ReturnValue <bool> msgData2 = TcpCall.KFBoCaiManager.BuyBoCai(new KFBuyBocaiData
                         {
                             BocaiType = 1,
                             RoleID    = DbData.m_RoleID,
                             RoleName  = DbData.m_RoleName,
                             ZoneID    = DbData.ZoneID,
                             ServerID  = DbData.ServerId,
                             BuyNum    = DbData.BuyNum,
                             BuyValue  = DbData.strBuyValue
                         });
                         if (!msgData2.IsReturn)
                         {
                             mgsData.Info = 8;
                         }
                         else if (!msgData2.Value)
                         {
                             GameManager.logDBCmdMgr.AddMessageLog(-1, "欢乐代币", "购买失败扣物品成功中心2次通信", client.ClientData.RoleName, client.ClientData.RoleName, "减少", useItemNum, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, "");
                             mgsData.Info = 5;
                         }
                         else
                         {
                             DbData.BuyNum = allNum;
                             BoCaiBuy2DBList.getInstance().AddData(DbData, useItemNum, true);
                             BoCaiCaiDaXiao.GetInstance().CopyBuyList(out mgsData.ItemList, DbData.m_RoleID);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         mgsData.Info = 100;
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_博彩]{0}", ex.ToString()), null, true);
     }
 }
Exemple #3
0
 private void BuyCaiShuzi(GameClient client, int BuyNum, string strBuyVal, ref BuyBoCaiResult mgsData)
 {
     try
     {
         List <int> buyList;
         BoCaiHelper.String2ListInt(strBuyVal, out buyList);
         if (buyList.Count != 5 || BuyNum < 1)
         {
             mgsData.Info = 2;
             LogManager.WriteLog(LogTypes.Warning, string.Format("[ljl_博彩] BuyCaiShuzi 购买内容 {0}, BuyNum={1} ", strBuyVal, BuyNum), null, true);
         }
         else
         {
             for (int i = 0; i < buyList.Count; i++)
             {
                 if (buyList[i] > 9 || buyList[i] < 0)
                 {
                     mgsData.Info = 2;
                     return;
                 }
             }
             if (!BoCaiCaiShuZi.GetInstance().IsCanBuy())
             {
                 mgsData.Info = 7;
             }
             else
             {
                 ReturnValue <bool> msgData = TcpCall.KFBoCaiManager.IsCanBuy(2, strBuyVal, BuyNum, BoCaiCaiShuZi.GetInstance().GetDataPeriods());
                 if (!msgData.IsReturn)
                 {
                     mgsData.Info = 8;
                 }
                 else if (!msgData.Value)
                 {
                     mgsData.Info = 5;
                 }
                 else
                 {
                     int XiaoHaoDaiBi = BoCaiCaiShuZi.GetInstance().GetXiaoHaoDaiBi();
                     if (XiaoHaoDaiBi < 1)
                     {
                         mgsData.Info = 3;
                         LogManager.WriteLog(LogTypes.Error, "[ljl_博彩]XiaoHaoDaiBi /GuDingLeiXing<1", null, true);
                     }
                     else
                     {
                         int useItemNum = BuyNum * XiaoHaoDaiBi;
                         if (!HuanLeDaiBiManager.GetInstance().HuanledaibiEnough(client, useItemNum))
                         {
                             mgsData.Info = 4;
                         }
                         else
                         {
                             int          allNum = BuyNum;
                             BuyBoCai2SDB DbData = BoCaiCaiShuZi.GetInstance().BuyBocai(client, BuyNum, strBuyVal, ref allNum);
                             if (null == DbData)
                             {
                                 mgsData.Info = 8;
                                 BoCaiCaiShuZi.GetInstance().BuyBocai(client, -BuyNum, strBuyVal, ref allNum);
                                 LogManager.WriteLog(LogTypes.Error, "[ljl_博彩]BoCaiCaiShuZi.GetInstance().BuyBocai err", null, true);
                             }
                             else if (!HuanLeDaiBiManager.GetInstance().UseHuanledaibi(client, useItemNum))
                             {
                                 mgsData.Info = 4;
                             }
                             else
                             {
                                 ReturnValue <bool> msgData2 = TcpCall.KFBoCaiManager.BuyBoCai(new KFBuyBocaiData
                                 {
                                     BocaiType = 2,
                                     RoleID    = DbData.m_RoleID,
                                     RoleName  = DbData.m_RoleName,
                                     ZoneID    = DbData.ZoneID,
                                     ServerID  = DbData.ServerId,
                                     BuyNum    = DbData.BuyNum,
                                     BuyValue  = DbData.strBuyValue
                                 });
                                 if (!msgData2.IsReturn)
                                 {
                                     mgsData.Info = 8;
                                 }
                                 else if (!msgData2.Value)
                                 {
                                     GameManager.logDBCmdMgr.AddMessageLog(-1, "欢乐代币", "购买失败扣物品成功中心2次通信", client.ClientData.RoleName, client.ClientData.RoleName, "减少", useItemNum, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, "");
                                     mgsData.Info = 5;
                                 }
                                 else
                                 {
                                     DbData.BuyNum = allNum;
                                     BoCaiBuy2DBList.getInstance().AddData(DbData, useItemNum, true);
                                     BoCaiCaiShuZi.GetInstance().CopyBuyList(out mgsData.ItemList, DbData.m_RoleID);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         mgsData.Info = 100;
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_博彩]{0}", ex.ToString()), null, true);
     }
 }