Exemple #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();
        }
Exemple #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);
                }
            }
        }
Exemple #3
0
 public object getData(string id)
 {
     try
     {
         id = storageId.ConcatString("_", id);
         var result = NoSQLFacade.Get <GenericNoSqlObject>("GameDataRegistry", id);
         return(result?.Value);
     }
     catch (Exception ex)
     {
         context.Game.LogError(ex);
         return(null);
     }
 }