コード例 #1
0
ファイル: UserHelper.cs プロジェクト: Komarulon/KomaruBotWeb
 public void SaveSettings(GambleSettings toSave)
 {
     this.redis.Set(toSave.GetKey(), toSave);
 }
コード例 #2
0
ファイル: UserHelper.cs プロジェクト: Komarulon/KomaruBotWeb
        public GambleSettings EnsureDefaultGambleSettings(string userID)
        {
            var            key = GambleSettings.GetKey(userID);
            GambleSettings gambleSettings;

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

            if (gambleSettings == null)
            {
                gambleSettings = new GambleSettings
                {
                    userID = userID,
                    gambleConfiguration = new Common.Models.GambleConfiguration
                    {
                        gambleEnabled            = false,
                        minBid                   = 10,
                        maxBid                   = 1000,
                        minMinutesBetweenGambles = 15,
                        gambleCommand            = "!gamble",
                        rollResults              = new List <Common.Models.GambleRewards>
                        {
                            new Common.Models.GambleRewards {
                                roll = 100, multiplier = 5m
                            },
                            new Common.Models.GambleRewards {
                                roll = 99, multiplier = 3m
                            },
                            new Common.Models.GambleRewards {
                                roll = 98, multiplier = 3m
                            },
                            new Common.Models.GambleRewards {
                                roll = 97, multiplier = 2.5m
                            },
                            new Common.Models.GambleRewards {
                                roll = 96, multiplier = 2.25m
                            },
                            new Common.Models.GambleRewards {
                                roll = 95, multiplier = 2m
                            },
                            new Common.Models.GambleRewards {
                                roll = 94, multiplier = 2m
                            },
                            new Common.Models.GambleRewards {
                                roll = 93, multiplier = 2m
                            },
                            new Common.Models.GambleRewards {
                                roll = 92, multiplier = 2m
                            },
                            new Common.Models.GambleRewards {
                                roll = 91, multiplier = 2m
                            },
                            new Common.Models.GambleRewards {
                                roll = 90, multiplier = 2m
                            },
                            new Common.Models.GambleRewards {
                                roll = 89, multiplier = 1.75m
                            },
                            new Common.Models.GambleRewards {
                                roll = 88, multiplier = 1.75m
                            },
                            new Common.Models.GambleRewards {
                                roll = 87, multiplier = 1.75m
                            },
                            new Common.Models.GambleRewards {
                                roll = 86, multiplier = 1.75m
                            },
                            new Common.Models.GambleRewards {
                                roll = 85, multiplier = 1.75m
                            },
                            new Common.Models.GambleRewards {
                                roll = 84, multiplier = 1.5m
                            },
                            new Common.Models.GambleRewards {
                                roll = 83, multiplier = 1.5m
                            },
                            new Common.Models.GambleRewards {
                                roll = 82, multiplier = 1.5m
                            },
                            new Common.Models.GambleRewards {
                                roll = 81, multiplier = 1.5m
                            },
                            new Common.Models.GambleRewards {
                                roll = 80, multiplier = 1.5m
                            },
                            new Common.Models.GambleRewards {
                                roll = 79, multiplier = 1.5m
                            },
                            new Common.Models.GambleRewards {
                                roll = 78, multiplier = 1.5m
                            },
                            new Common.Models.GambleRewards {
                                roll = 77, multiplier = 1.5m
                            },
                            new Common.Models.GambleRewards {
                                roll = 76, multiplier = 1.25m
                            },
                            new Common.Models.GambleRewards {
                                roll = 75, multiplier = 1.25m
                            },
                            new Common.Models.GambleRewards {
                                roll = 74, multiplier = 1.25m
                            },
                            new Common.Models.GambleRewards {
                                roll = 73, multiplier = 1.25m
                            },
                            new Common.Models.GambleRewards {
                                roll = 72, multiplier = 1.25m
                            },
                            new Common.Models.GambleRewards {
                                roll = 71, multiplier = 1.25m
                            },
                            new Common.Models.GambleRewards {
                                roll = 70, multiplier = 1.25m
                            },
                            new Common.Models.GambleRewards {
                                roll = 69, multiplier = 1.25m
                            },
                            new Common.Models.GambleRewards {
                                roll = 68, multiplier = 1.25m
                            },
                            new Common.Models.GambleRewards {
                                roll = 67, multiplier = 1.25m
                            },
                            new Common.Models.GambleRewards {
                                roll = 66, multiplier = 1.25m
                            },
                            new Common.Models.GambleRewards {
                                roll = 65, multiplier = 1m
                            },
                            new Common.Models.GambleRewards {
                                roll = 64, multiplier = 1m
                            },
                            new Common.Models.GambleRewards {
                                roll = 63, multiplier = 1m
                            },
                            new Common.Models.GambleRewards {
                                roll = 62, multiplier = 0.75m
                            },
                            new Common.Models.GambleRewards {
                                roll = 61, multiplier = 0.75m
                            },
                            new Common.Models.GambleRewards {
                                roll = 60, multiplier = 0.75m
                            },
                            new Common.Models.GambleRewards {
                                roll = 59, multiplier = 0.5m
                            },
                            new Common.Models.GambleRewards {
                                roll = 58, multiplier = 0.5m
                            },
                            new Common.Models.GambleRewards {
                                roll = 57, multiplier = 0.5m
                            },
                            new Common.Models.GambleRewards {
                                roll = 56, multiplier = 0.25m
                            },
                            new Common.Models.GambleRewards {
                                roll = 55, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 54, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 53, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 52, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 51, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 50, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 49, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 48, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 47, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 46, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 45, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 44, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 43, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 42, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 41, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 40, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 39, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 38, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 37, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 36, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 35, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 34, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 33, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 32, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 31, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 30, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 29, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 28, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 27, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 26, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 25, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 24, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 23, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 22, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 21, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 20, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 19, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 18, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 17, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 16, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 15, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 14, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 13, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 12, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 11, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 10, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 9, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 8, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 7, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 6, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 5, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 4, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 3, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 2, multiplier = 0m
                            },
                            new Common.Models.GambleRewards {
                                roll = 1, multiplier = 0m
                            }
                        },
                    }
                };
                this.redis.Set(key, gambleSettings);
            }

            return(gambleSettings);
        }