Exemple #1
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 #2
0
        public bool saveData(string id, object data)
        {
            try
            {
                id = storageId.ConcatString("_", id);
                if (data == null)
                {
                    NoSQLFacade.Delete("GameDataRegistry", id);
                }

                var container = new GenericNoSqlObject(data);
                NoSQLFacade.Save("GameDataRegistry", id, container);
                return(true);
            }
            catch (Exception ex)
            {
                context.Game.LogError(ex);
                return(false);
            }
        }