示例#1
0
 public long Spin(byte betType, byte roomID)
 {
     try
     {
         long   accountId   = AccountSession.AccountID;
         string accountName = AccountSession.AccountName;
         if (accountId < 1 || string.IsNullOrEmpty(accountName))
         {
             return(-1001);
         }
         if ((betType < 1 || betType > 2 || roomID < 1 || roomID > 4))
         {
             Logout();
             NLogManager.LogMessage(string.Format("BlockAcc=> {0} ({1}) Wrong Input.", accountName, accountId));
             return(-1001);
         }
         float maxSpinPerSecond =
             int.Parse(System.Configuration.ConfigurationManager.AppSettings["MAX_SPIN_PER_SECOND"]);
         if (maxSpinPerSecond % 2 > 0)
         {
             maxSpinPerSecond += 1;
         }
         if (CacheCounter.CheckAccountActionFrequencyMiliSecond(accountId.ToString(), 1000 / maxSpinPerSecond, "Spin") > 1)
         {
             NLogManager.LogMessage(string.Format("BlockAccFast=> {0} ({1}) quay liên tục 1 giây {2} lần.",
                                                  accountName, accountId, maxSpinPerSecond));
             return(-1001);
         }
         if (CacheCounter.AccountActionCounter(accountId.ToString(), "SpinAm") > 5)
         {
             NLogManager.LogMessage(string.Format("BlockAccAm=> {0} ({1}) bắn âm > 5 lần.", accountName, accountId));
             return(-1003);
         }
         MiniPokerHandler.Instance.UpdatePlayer(accountId);
         int res = MiniPokerHandler.Instance.MpSpin(accountId, accountName, betType, roomID, base.Context.ConnectionId, _isMobilePl);
         if (res < 0)
         {
             CacheCounter.CheckAccountActionFrequency(accountId.ToString(), 15, "SpinAm");
         }
         return(res);
     }
     catch (NotAuthorizedException notAuthorizedException)
     {
         NLogManager.PublishException(notAuthorizedException);
         return(-51);
     }
     catch (Exception exception)
     {
         NLogManager.PublishException(exception);
     }
     return(-99);
 }
示例#2
0
        public int Spin(MoneyType moneyType, int roomId, string lines)
        {
            long   accountId   = AccountSession.AccountID;
            string accountName = AccountSession.AccountName;

            try
            {
                if (accountId < 1 || String.IsNullOrEmpty(accountName))
                {
                    return((int)Enums.ErrorCode.NotAuthen);
                }

                if (CacheCounter.AccountActionCounter(accountId.ToString(), "BlockSpamSpin") > 0)
                {
                    NLogManager.LogMessage($"BlockSpinAm=>Acc:{accountId}|User:{accountName}|Lines:{lines}|Ip:{IPAddressHelper.GetClientIP()}");
                    return(-1002);
                }

                var spinData = GameHandler.Instance.Spin(accountId, accountName, lines, moneyType, roomId);
                if (spinData != null && spinData.ResponseStatus < 0)
                {
                    if (CacheCounter.CheckAccountActionFrequency(accountName, 10, "InvalidSpin") > 5)
                    {
                        //Block Spin 10s
                        CacheCounter.CheckAccountActionFrequency(accountName, 10, "BlockSpamSpin");
                    }
                    string message = "Rất tiếc hệ thống của chúng tôi đang bận!Mời bạn thử lại sau!";
                    if (spinData.ResponseStatus == -51)
                    {
                        message = "Số dư của bạn không đủ";
                    }
                    else if (spinData.ResponseStatus == -232)
                    {
                        message = "Số line chọn không hợp lệ";
                    }
                    Clients.Caller.message(spinData.ResponseStatus, message);
                }
                Clients.Caller.resultSpin(spinData);

                return((int)Enums.ErrorCode.SuccessRequest);
            }
            catch (Exception ex)
            {
                NLogManager.PublishException(ex);
                return((int)Enums.ErrorCode.Exception);
            }
        }
示例#3
0
        public int Spin(int roomId)
        {
            try
            {
                var moneyType = MoneyType.Gold;

                if (roomId < 1 || roomId > 4)
                {
                    return(-303);
                }
                //Kiểm tra xem tài khoản vi phạm bắn số lần respone âm
                var totalFailRequest = int.Parse(ConfigurationManager.AppSettings["TotalFailRq"]);
                if (CheckStatusFrequency("SpinLoi") >= totalFailRequest)
                {
                    var totalSecondFail = int.Parse(ConfigurationManager.AppSettings["TimmerFailRq"]);
                    AddStatusFrequency(totalSecondFail, "SpinLoi");
                    return(-1999);
                }
                long   accountId   = AccountSession.AccountID;
                string accountName = AccountSession.AccountName;


                if (accountId < 1 || String.IsNullOrEmpty(accountName))
                {
                    return((int)Enums.ErrorCode.NotAuthen);
                }

                float maxSpinPerSecond =
                    Config.GetIntegerAppSettings("MAX_SPIN_PER_SECOND", 5);
                if (maxSpinPerSecond % 2 > 0)
                {
                    maxSpinPerSecond += 1;
                }
                if (CacheCounter.CheckAccountActionFrequencyMiliSecond(accountId.ToString(), 1000 / maxSpinPerSecond, "Spin") > 1)
                {
                    NLogManager.LogMessage(string.Format("BlockAccFast=> {0} ({1}) quay liên tục 1 giây {2} lần.",
                                                         accountName, accountId, maxSpinPerSecond));
                    return(-1001);
                }
                if (CacheCounter.AccountActionCounter(accountId.ToString(), "SpinAm") > 5)
                {
                    NLogManager.LogMessage(string.Format("BlockAccAm=> {0} ({1}) bắn âm > 5 lần.", accountName, accountId));
                    return(-1003);
                }

                var spinData = GameHandler.Instance.PlaySpin(roomId, moneyType);

                if (spinData.ResponseStatus == -48)
                {
                    Clients.Caller.message("Error-48", 3);
                    return(-48);
                }

                if (spinData.ResponseStatus >= 0)
                {
                    Clients.Caller.ResultSpin(spinData);
                    return((int)Enums.ErrorCode.Success);
                }

                else
                {
                    return(spinData.ResponseStatus);
                }
            }
            catch (Exception ex)
            {
                NLogManager.PublishException(ex);
                return((int)Enums.ErrorCode.Exception);
            }
        }
示例#4
0
        public int SetBetHiLo(int betType, int stepType, int locationId, int roomId)
        {
            try
            {
                long   accountId   = AccountSession.AccountID;
                string accountName = AccountSession.AccountName;
                if (accountId < 1 || string.IsNullOrEmpty(accountName))
                {
                    NLogManager.LogMessage(string.Format("Chưa đăng nhập"));
                    return(-1001);
                }
                if (betType < 1 || betType > 2 || locationId < 0 || locationId > 1 || roomId < 1 || roomId > 5)
                {
                    Logout();
                    NLogManager.LogMessage(string.Format("BlockAcc=> {0} ({1}) Wrong Input.", accountName, accountId));
                    return(-212);
                }

                if (CacheCounter.CheckAccountActionFrequency(accountId.ToString(), 1, "SetBet") > 2)
                {
                    NLogManager.LogMessage(string.Format("BlockAccFast => {0} ({1}) bet liên tục 1 giây 2 lần.", accountName, accountId));
                    return(-1001);
                }
                if (CacheCounter.AccountActionCounter(accountId.ToString(), "SetBetAm") > 5)
                {
                    NLogManager.LogMessage(string.Format("BlockAccAm => {0} ({1}) bắn âm > 5 lần.", accountName, accountId));
                    return(-1003);
                }
                var result = AbstractDaoMinigame.Instance().CreateMiniHiloDao().
                             SetBet((int)accountId, accountName, roomId, betType, stepType, locationId, IPAddressHelper.GetClientIP(),
                                    1, 1);

                if (stepType == 2 || result.prizeValue == 0 || result.responseStatus < 0)
                {
                    //Kết thúc phiên hoặc thua cuộc
                    HiLoHandler.Instance.FinishAccSession(result.turnId);
                }
                else
                {
                    if (result.responseStatus < 0)
                    {
                        //Add vào list để duyệt check finish phiên
                        var accInfo = new HiLoGetAccountInfoResponse()
                        {
                            currentTurnId  = result.turnId,
                            currentRoomId  = roomId,
                            currentBetType = betType,
                            AccountId      = accountId,
                            AccountName    = accountName,
                            currentStep    = result.step
                        };
                        HiLoHandler.Instance.AddOrUpdateSession(accInfo);
                    }
                }
                if (result.responseStatus < 0)
                {
                    CacheCounter.CheckAccountActionFrequency(accountId.ToString(), 15, "SetBetAm");
                }
                Clients.Caller.resultHiLoSetBet(result);
                return(result.responseStatus);
            }
            catch (Exception exception)
            {
                NLogManager.PublishException(exception);
            }
            return(-99);
        }