Exemplo n.º 1
0
        public CeresSettings EnsureDefaultCeresSettings(string userID)
        {
            var           key = CeresSettings.GetKey(userID);
            CeresSettings ceresSettings;

            try
            {
                ceresSettings = this.redis.Get <CeresSettings>(key);
            }
            catch (System.Runtime.Serialization.SerializationException)
            {
                this.redis.Delete(key);
                ceresSettings = null;
            }

            if (ceresSettings == null)
            {
                ceresSettings = new CeresSettings
                {
                    ceresConfiguration = new Common.Models.CeresConfiguration
                    {
                        ceresEnabled           = false,
                        numberOfSecondsToGuess = 45,
                        staticRewards          = new List <Common.Models.CeresConfiguration.StaticReward>
                        {
                            new Common.Models.CeresConfiguration.StaticReward(0, 0, 1000),
                            new Common.Models.CeresConfiguration.StaticReward(1, 2, 500),
                            new Common.Models.CeresConfiguration.StaticReward(3, 4, 100),
                        },
                        closestRewards = new List <Common.Models.CeresConfiguration.ClosestReward>
                        {
                            new Common.Models.CeresConfiguration.ClosestReward(1, 100, false),
                            new Common.Models.CeresConfiguration.ClosestReward(2, 50, false),
                            new Common.Models.CeresConfiguration.ClosestReward(3, 10, false),
                        },
                        magicTimes = new List <Common.Models.CeresConfiguration.MagicTime>
                        {
                            new Common.Models.CeresConfiguration.MagicTime
                            {
                                ceresTime     = 4700,
                                pointsAwarded = 10000,
                            },
                            new Common.Models.CeresConfiguration.MagicTime
                            {
                                ceresTime     = 4600,
                                pointsAwarded = 1000,
                            },
                        }
                    },
                    userID = userID,
                };
                this.redis.Set(key, ceresSettings);
            }

            return(ceresSettings);
        }
Exemplo n.º 2
0
 public void SaveSettings(CeresSettings toSave)
 {
     this.redis.Set(toSave.GetKey(), toSave);
 }