Пример #1
0
        public StorageHelper(string storageId, ScriptedGameContext context)
        {
            this.storageId = storageId;
            this.context   = context;
            try
            {
                var winners = NoSQLFacade.Get <NoSqlDictionarySet>("LastGameWinners", storageId);
                if (winners != null)
                {
                    lastWinners.AddRange(winners.Values);
                }

                winners = NoSQLFacade.Get <NoSqlDictionarySet>("TopGameWinners", storageId);
                if (winners != null)
                {
                    topWinners.AddRange(winners.Values);
                }
            }
            catch (Exception ex)
            {
                context.Game.LogError(ex);
            }

            isRunning = true;
            var thread = new Thread(StorageBackgroundProc)
            {
                Name = "Storage background thread for {0}".FormatString(storageId)
            };

            thread.Start();
        }
Пример #2
0
        public RoundCounter(ScriptedGameContext context)
        {
            this.context = context;
            gameId       = context.Game.IdLong;

            currentValue = ExternalServiceFacade.GetGameCoreService().GetRoundId(gameId);
            if (currentValue == 0)
            {
                currentValue = increase();
            }

            var tmpResult = NoSQLFacade.Get <GenericNoSqlObject>("SavedGameRoundId", context.Game.IdLong);

            if (tmpResult != null)
            {
                var longValue = (long)tmpResult.Value;
                if (currentValue < longValue)
                {
                    context.Game.Log("Restoring round counter from NoSQL storage from value {0} to value {1}", currentValue, longValue);
                    currentValue      = longValue;
                    hasUnsyncedValues = true;
                    CheckSync();
                    NoSQLFacade.Delete("SavedGameRoundId", context.Game.IdLong);
                }
            }
        }
Пример #3
0
        public UserInfo(ScriptedGameContext context, string sessionId, long userId, long accountId, long casinoId, string externalSessionId, string externalSessionIp, string clientId, string locale, CurrencyTypeEnum currency, string nick, string clientType, IDictionary <string, object> features)
        {
            this.context      = context;
            this.sessionId    = sessionId;
            UserId            = userId;
            CasinoId          = casinoId;
            ExternalSessionId = externalSessionId;
            ExternalSessionIp = externalSessionIp;
            this.clientId     = clientId;
            UserNick          = nick;
            AccountId         = accountId;
            ClientType        = clientType;
            this.features     = features;
            this.locale       = new LocaleInfo(locale, currency);

            ExternalId = Guid.NewGuid().ToString().Replace("-", String.Empty).ToLower();

            if (userId != 0)
            {
                isLoggedIn = true;
            }

            if (isPlayingForFun)
            {
                Balance = FUN_BALANCE;
            }
        }
Пример #4
0
 public ScriptedGameRuntime(ScriptedGameContext context, ILiveReportTracker reportTracker, double externalDelay)
 {
     this.context              = context;
     this.reportTracker        = reportTracker;
     this.externalDelay        = externalDelay;
     userTimeoutInSecondsValue = context.Game.GetInstanceSetting("userTimeoutInSeconds", 600);
     gameTimeoutInSecondsValue = context.Game.GetInstanceSetting("gameTimeoutInSeconds", 600);
 }
Пример #5
0
 public AccountingHelper(ScriptedGameContext context, IAccountingFacade accountingFacade, ILiveReportTracker reportTracker, bool trackFunData)
 {
     this.context          = context;
     this.trackFunData     = trackFunData;
     this.reportTracker    = reportTracker;
     this.accountingFacade = accountingFacade;
     reportTracker.Clear(context.Game.IdLong, 0);
 }
Пример #6
0
 public ExternalDatasource(ScriptedGameContext context, Uri exchangeClientUri, string datasourceId)
 {
     this.context        = context;
     this.exchangeClient = new DataExchangeClient(exchangeClientUri);
     this.datasourceId   = datasourceId;
     exchangeClient.GetCurrent(datasourceId);
     processTimer = new Timer(OnChangeCheck, this, TimeSpan.FromSeconds(1), TimeSpan.FromMilliseconds(500));
 }
Пример #7
0
 public GameMediaHelper(ScriptedGameContext scriptedGameContext, IDictionary <string, object> vodData, IDictionary <string, object> virtualData, IDictionary <string, object> streamConfig, bool hasLiveStreams)
 {
     this.scriptedGameContext = scriptedGameContext;
     LoadVOD(vodData);
     LoadVirtualData(virtualData);
     SetStreamConfig(streamConfig);
     this.hasLiveStreams = hasLiveStreams;
 }
Пример #8
0
        public DelayedTask(ScriptedGameInstance gameInstance, ScriptedGameContext context, JavascriptContext javascriptContext, string id, object jsFunction, double period)
        {
            if (double.IsNaN(period))
            {
                throw new InvalidOperationException("Cannot initialize delayed task with NaN delay");
            }

            this.gameInstance      = gameInstance;
            this.context           = context;
            this.javascriptContext = javascriptContext;
            this.id         = id;
            this.jsFunction = jsFunction;
            executionTime   = DateTime.Now.Add(TimeSpan.FromMilliseconds(period));
        }
Пример #9
0
        public UserInfo GetUserInfo(ScriptedGameContext context, IDictionary <string, object> features, bool createNew = false)
        {
            if (createNew || (userInfo != null && userInfo.context != context))
            {
                userInfo?.Dispose();
                userInfo = null;
            }

            if (userInfo != null)
            {
                userInfo.UserNick = session.Nick;
                return(userInfo);
            }

            return(userInfo = new UserInfo(context, session.SessionId, session.UserId, session.AccountId, session.CasinoId, session.ExternalSessionId, session.ExternalSessionIp, clientId, session.Locale, session.Currency, session.Nick, session.ClientType, session.Features));
        }
Пример #10
0
            public void SendInitialPackets(ScriptedGameContext scriptedGameContext, string sessionId)
            {
                var items       = CurrentVOD;
                var itemsToPlay = items?.Where(i => !i.HasEnded).ToList();

                if (itemsToPlay?.Count > 0)
                {
                    foreach (var item in itemsToPlay)
                    {
                        if (item.HasStarted)
                        {
                            item.Data["offset"] = EnvironmentHelper.CurrentTime.Subtract(item.DateStart).TotalMilliseconds - 1000;
                        }
                    }

                    var packet = new Dictionary <string, object>
                    {
                        { "vodType", (int)VodPacketTypeEnum.Play },
                        { "target", "background" },
                        { "items", itemsToPlay.Select(i => i.Data).ToArray() }
                    };

                    scriptedGameContext.sendSystemInternal(sessionId, SessionMessageTypeEnum.VOD, packet);
                }

                var lastPacket = CurrentScreenPacket;

                if (lastPacket != null)
                {
                    scriptedGameContext.sendSystemInternal(sessionId, SessionMessageTypeEnum.VOD, lastPacket);
                }

                var lastOverlays = Overlays.Values.ToArray();

                if (lastOverlays.Length > 0)
                {
                    var packet = new Dictionary <string, object>
                    {
                        { "vodType", (int)VodPacketTypeEnum.Play },
                        { "target", "overlay" },
                        { "items", lastOverlays }
                    };

                    scriptedGameContext.sendSystemInternal(sessionId, SessionMessageTypeEnum.VOD, packet);
                }
            }
Пример #11
0
 public RNGWrapper(ScriptedGameContext context, string sessionId)
 {
     this.context   = context;
     this.sessionId = sessionId;
 }
Пример #12
0
 public UserInfo GetUserInfo(ScriptedGameContext context, bool createNew = false)
 {
     return(GetStreamWrapper(context.Game.Id).GetUserInfo(context, Features, createNew: createNew));
 }