예제 #1
0
        public static ShopModel GetConfigValues()
        {
            if (_shopModelCache != null)
            {
                return(_shopModelCache);
            }
            var json      = File.ReadAllText(fullPath);
            var shopModel = JsonConvert.DeserializeObject <ShopModel>(json);

            _shopModelCache = shopModel;
            return(shopModel);
        }
예제 #2
0
        public static async Task UpdateOnNewDays()
        {
            var lastShop = GetConfigValues();

            if (lastShop.UpdateDate + new TimeSpan(24, 0, 0) > DateTime.Now)
            {
                return;
            }
            lastShop.UpdateDate += new TimeSpan(24, 0, 0);
            var items = await ItemsJsonController.GetConfigValuesAsync();

            lastShop.RndItemsId = new int[6]
            {
                GetRandomItem(GetOnlyCommonAndRare(items.Meals)).Id,
                GetRandomItem(GetOnlyCommonAndRare(items.Liquids)).Id,
                GetRandomItem(GetOnlyCommonAndRare(items.Hats)).Id,
                GetRandomItem(GetOnlyCommonAndRare(items.Jackets)).Id,
                GetRandomItem(GetOnlyCommonAndRare(items.Pants)).Id,
                GetRandomItem(GetOnlyCommonAndRare(items.Boots)).Id
            };
            _shopModelCache = lastShop;
            var newData = JsonConvert.SerializeObject(lastShop, Formatting.Indented);
            await File.WriteAllTextAsync(fullPath, newData);
        }