Example #1
0
        public void setGameState(string sessionId, string state, string description)
        {
            var      roundState = state.ToEnum(GameStateEnum.Unknown);
            DateTime?endDate    = null;

            switch (roundState)
            {
            case GameStateEnum.Opened:

                Task.Run(delegate
                {
                    try
                    {
                        context.accountingHelper.SendWins(sessionId);
                    }
                    catch (Exception ex)
                    {
                        context.Game.LogError(ex);
                    }
                });

                foreach (var session in context.sessions)
                {
                    context.GetSession(session)?.GetUserInfo(context)?.CheckUserState();
                }

                if (roundLength >= 0)
                {
                    endDate = EnvironmentHelper.CurrentTime.AddSeconds(roundLength);
                }

                context.accountingHelper.RegisterNewRound(sessionId, description);
                break;

            case GameStateEnum.Closed:
                break;
            }

            context.Game.UpdateGameState(roundState, description, endDate);
        }
Example #2
0
        private void SendWin(string sessionId, UserWinData winData)
        {
            UserInfo userInfo    = null;
            decimal  moneyAmount = 0;

            try
            {
                userInfo    = context.GetSession(sessionId)?.GetUserInfo(context);
                moneyAmount = winData.WinData.Sum(a => a.Amount);

                if (!winData.IsPlayingForFun)
                {
                    var result = accountingFacade.RegisterPlayerWins(context.Game.IdLong, winData.CasinoId, winData.UserId, winData.AccountId, winData.RoundId, winData, winData.AccessPointId, winData.ExternalSessionId, winData.ExternalSessionIp, winData.SeamlessMode, winData.ClientType);
                    if (userInfo != null)
                    {
                        userInfo.SetBalance(result);
                        SendBalanceChanged(sessionId, userInfo.Balance, userInfo.totalLoss);
                    }

                    if (moneyAmount > 0)
                    {
                        accountingFacade.UpdateGameIncome(winData.CasinoId, context.Game.IdLong, EnvironmentHelper.CurrentTime, winData.Currency, 0.0m, moneyAmount, true);
                    }
                }
                else
                {
                    if (trackFunData && moneyAmount > 0)
                    {
                        accountingFacade.UpdateGameIncome(winData.CasinoId, context.Game.IdLong, EnvironmentHelper.CurrentTime, winData.Currency, 0.0m, moneyAmount, false);
                    }
                }

                if (moneyAmount > 0)
                {
                    foreach (var userWinItemData in winData.WinData)
                    {
                        context.Game.ExecuteCallback(this, winData.SuccessCallback, false, sessionId, userWinItemData.WinDataObject, userWinItemData.Amount);
                    }
                }
            }
            catch (Exception ex)
            {
                if (userInfo != null)
                {
                    userInfo.totalWinAmount -= moneyAmount;
                }

                context.Game.LogError(ex);

                try
                {
                    if (moneyAmount > 0)
                    {
                        context.Game.ExecuteCallback(this, winData.FailureCallback, false, sessionId);
                    }
                }
                catch (Exception exx)
                {
                    context.Game.LogError(exx);
                }
            }
        }