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); }
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); } }