Tigran 3 éve
szülő
commit
a01a90a327

+ 13 - 6
CardCollector/Commands/CallbackQuery/ConfirmationSellingQuery.cs

@@ -14,12 +14,19 @@ namespace CardCollector.Commands.CallbackQuery
         public override async Task Execute()
         {
             var collectionModule = User.Session.GetModule<CollectionModule>();
-            EnterGemsPriceMessage.RemoveFromQueue(User.Id);
-            var income = await User.Cash.Payout(User.Stickers);
-            await MessageController.AnswerCallbackQuery(User, CallbackQueryId, $"{Messages.you_collected} {income}{Text.coin}");
-            User.Stickers[collectionModule.SelectedSticker.Md5Hash].Count -= collectionModule.Count;
-            AuctionController.SellCard(User.Id, collectionModule.SelectedSticker.Id, collectionModule.SellPrice, collectionModule.Count);
-            await MessageController.EditMessage(User, CallbackMessageId, Messages.successfully_selling);
+            if (collectionModule.SellPrice <= 0)
+                await MessageController.AnswerCallbackQuery(User, CallbackQueryId, Messages.cant_sell_zero, true);
+            else
+            {
+                EnterGemsPriceMessage.RemoveFromQueue(User.Id);
+                var income = await User.Cash.Payout(User.Stickers);
+                await MessageController.AnswerCallbackQuery(User, CallbackQueryId,
+                    $"{Messages.you_collected} {income}{Text.coin}");
+                User.Stickers[collectionModule.SelectedSticker.Md5Hash].Count -= collectionModule.Count;
+                AuctionController.SellCard(User.Id, collectionModule.SelectedSticker.Id, collectionModule.SellPrice,
+                    collectionModule.Count);
+                await MessageController.EditMessage(User, CallbackMessageId, Messages.successfully_selling);
+            }
         }
         public ConfirmationSellingQuery(){}
         public ConfirmationSellingQuery(UserEntity user, Update update) : base(user, update){}

+ 2 - 1
CardCollector/Commands/CallbackQuery/PutForAuctionQuery.cs

@@ -19,7 +19,8 @@ namespace CardCollector.Commands.CallbackQuery
                 Messages.comission_warning, true);
             await User.ClearChat();
             var module = User.Session.GetModule<CollectionModule>();
-            var lowerPrice = (await AuctionController.GetPriceList(module.SelectedSticker.Id)).Min();
+            var priceList = (await AuctionController.GetPriceList(module.SelectedSticker.Id)).ToList();
+            var lowerPrice = priceList.Count > 0 ? priceList.Min() : 0;
             var message = await MessageController.SendMessage(User,
                 $"{Messages.current_price} {module.SellPrice}{Text.gem}" +
                 $"\n{Messages.lower_price} {lowerPrice}{Text.gem}" +

+ 1 - 0
CardCollector/DataBase/EntityDao/SpecialOfferUsersDao.cs

@@ -21,6 +21,7 @@ namespace CardCollector.DataBase.EntityDao
                 UserId = userId,
                 OfferId = offerId
             });
+            await Instance.SaveChangesAsync();
         }
     }
 }

+ 4 - 2
CardCollector/DataBase/EntityDao/SpecificPackDao.cs

@@ -19,17 +19,19 @@ namespace CardCollector.DataBase.EntityDao
 
         public static async Task<SpecificPacksEntity> AddNew(long userId, int packId, int count)
         {
-            return (await Table.AddAsync(new SpecificPacksEntity
+            var pack = await Table.FirstOrDefaultAsync(item => item.UserId == userId && item.PackId == packId) ??
+            (await Table.AddAsync(new SpecificPacksEntity
             {
                 UserId = userId,
                 PackId = packId,
                 Count = count
             })).Entity;
+            return pack;
         }
 
         public static async Task<int> GetCount(long userId)
         {
-            return await Table.SumAsync(item => Task.FromResult(item.Count));
+            return (await Table.WhereAsync(item => item.UserId == userId)).Sum(item => item.Count);
         }
 
         public static async Task<List<SpecificPacksEntity>> GetUserPacks(long userId)

+ 0 - 9
CardCollector/Resources/Command.Designer.cs

@@ -96,15 +96,6 @@ namespace CardCollector.Resources {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to AAE.
-        /// </summary>
-        internal static string back_to_sticker {
-            get {
-                return ResourceManager.GetString("back_to_sticker", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to ABI.
         /// </summary>

+ 0 - 3
CardCollector/Resources/Command.resx

@@ -87,9 +87,6 @@
     <data name="confirm_selling" xml:space="preserve">
         <value>AAM</value>
     </data>
-    <data name="back_to_sticker" xml:space="preserve">
-        <value>AAE</value>
-    </data>
     <data name="back_to_combine" xml:space="preserve">
         <value>AAD</value>
     </data>

+ 1 - 1
CardCollector/Resources/Constants.cs

@@ -26,7 +26,7 @@ namespace CardCollector.Resources
         public const int COMBINE_COUNT = 5;
         
         /* Время оповещения и сброса ежедневных заданий */
-        public static readonly TimeSpan DailyTaskAlert = DEBUG ? new TimeSpan(21, 0, 0) : new TimeSpan(12, 0, 0);
+        public static readonly TimeSpan DailyTaskAlert = DEBUG ? new TimeSpan(1, 36, 30) : new TimeSpan(12, 0, 0);
         public static readonly TimeSpan DailyTaskReset = DEBUG ? new TimeSpan(0, 13, 0) : new TimeSpan(0, 0, 0);
         public static readonly TimeSpan DailyStickerRewardCheck = DEBUG ? new TimeSpan(1, 9, 0) : new TimeSpan(1, 0, 0);
     }

+ 2 - 4
CardCollector/Resources/Keyboard.cs

@@ -213,7 +213,6 @@ namespace CardCollector.Resources
             /* Копируем список */
             foreach (var (item, i) in infoList.WithIndex())
             {
-                Logs.LogOut(i);
                 if (i % 2 == 0) keyboardList.Add(new [] {
                     InlineKeyboardButton.WithCallbackData(item.Author, $"{Command.open_pack}={item.Id}")
                 });
@@ -242,7 +241,6 @@ namespace CardCollector.Resources
             foreach (var (item, i) in infoList.WithIndex())
             {
                 var author = await PacksDao.GetById(item.PackId);
-                Logs.LogOut(i);
                 if (i % 2 == 0) keyboardList.Add(new [] {
                     InlineKeyboardButton.WithCallbackData($"{author.Author} {item.Count}", $"{Command.open_pack}={item.Id}")
                 });
@@ -276,7 +274,7 @@ namespace CardCollector.Resources
                     InlineKeyboardButton.WithCallbackData(Text.plus, $"{Command.count}+"),
                 }
             };
-            if (sticker.Tier != 5) keyboard.Add(new[] {InlineKeyboardButton.WithCallbackData($"{Text.combine} ({count})", Command.combine)});
+            if (sticker.Tier != 4) keyboard.Add(new[] {InlineKeyboardButton.WithCallbackData($"{Text.combine} ({count})", Command.combine)});
             keyboard.Add(new[] {InlineKeyboardButton.WithCallbackData(Text.back, $"{Command.back}={Command.clear_chat}")});
             return new InlineKeyboardMarkup(keyboard);
         }
@@ -316,7 +314,7 @@ namespace CardCollector.Resources
             return new InlineKeyboardMarkup(new[] {
                 new[]
                 {
-                    InlineKeyboardButton.WithCallbackData(Text.no, Command.back_to_sticker),
+                    InlineKeyboardButton.WithCallbackData(Text.no, Command.back),
                     InlineKeyboardButton.WithCallbackData(Text.yes, command)
                 }
             });

+ 5 - 32
CardCollector/Resources/Messages.Designer.cs

@@ -124,20 +124,11 @@ namespace CardCollector.Resources {
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Невозможно уменьшить количество стикеров!.
+        ///   Looks up a localized string similar to Нельзя продать товар за 0!.
         /// </summary>
-        internal static string cant_decrease {
+        internal static string cant_sell_zero {
             get {
-                return ResourceManager.GetString("cant_decrease", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Невозможно увеличить количество стикеров!.
-        /// </summary>
-        internal static string cant_increase {
-            get {
-                return ResourceManager.GetString("cant_increase", resourceCulture);
+                return ResourceManager.GetString("cant_sell_zero", resourceCulture);
             }
         }
         
@@ -232,7 +223,7 @@ namespace CardCollector.Resources {
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Подтвердите выставление.
+        ///   Looks up a localized string similar to Подтвердите выставление за.
         /// </summary>
         internal static string confirm_selling {
             get {
@@ -366,15 +357,6 @@ namespace CardCollector.Resources {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to Введите вашу стоимость в монетах.
-        /// </summary>
-        internal static string enter_your_coins_price {
-            get {
-                return ResourceManager.GetString("enter_your_coins_price", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Введите вашу стоимость в алмазах (за 1шт).
         /// </summary>
@@ -617,15 +599,6 @@ namespace CardCollector.Resources {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to Несобранная прибыль.
-        /// </summary>
-        internal static string uncllected_income {
-            get {
-                return ResourceManager.GetString("uncllected_income", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Произошла неожиданная ошибка, попробуйте еще раз..
         /// </summary>
@@ -663,7 +636,7 @@ namespace CardCollector.Resources {
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Получено.
+        ///   Looks up a localized string similar to Получено прибыли со стикеров:.
         /// </summary>
         internal static string you_collected {
             get {

+ 5 - 14
CardCollector/Resources/Messages.resx

@@ -93,11 +93,8 @@
     <data name="gems" xml:space="preserve">
         <value>Алмазы</value>
     </data>
-    <data name="uncllected_income" xml:space="preserve">
-        <value>Несобранная прибыль</value>
-    </data>
     <data name="you_collected" xml:space="preserve">
-        <value>Получено</value>
+        <value>Получено прибыли со стикеров:</value>
     </data>
     <data name="menu_message" xml:space="preserve">
         <value>Вы можете выбрать одну из опций ниже</value>
@@ -105,12 +102,6 @@
     <data name="your_cash" xml:space="preserve">
         <value>Баланс</value>
     </data>
-    <data name="cant_increase" xml:space="preserve">
-        <value>Невозможно увеличить количество стикеров!</value>
-    </data>
-    <data name="cant_decrease" xml:space="preserve">
-        <value>Невозможно уменьшить количество стикеров!</value>
-    </data>
     <data name="not_enougth_stickers" xml:space="preserve">
         <value>Недостаточно стикеров в магазине!</value>
     </data>
@@ -144,14 +135,11 @@
     <data name="current_price" xml:space="preserve">
         <value>Текущая стоимость</value>
     </data>
-    <data name="enter_your_coins_price" xml:space="preserve">
-        <value>Введите вашу стоимость в монетах</value>
-    </data>
     <data name="enter_your_gems_price" xml:space="preserve">
         <value>Введите вашу стоимость в алмазах (за 1шт)</value>
     </data>
     <data name="confirm_selling" xml:space="preserve">
-        <value>Подтвердите выставление</value>
+        <value>Подтвердите выставление за</value>
     </data>
     <data name="successfully_selling" xml:space="preserve">
         <value>Товар успешно попал на аукцион</value>
@@ -239,4 +227,7 @@
     <data name="effect_RandomSticker1Tier3Day" xml:space="preserve">
         <value>Поздравляем! Вы получили следующие стикеры:</value>
     </data>
+    <data name="cant_sell_zero" xml:space="preserve">
+        <value>Нельзя продать товар за 0!</value>
+    </data>
 </root>

+ 0 - 18
CardCollector/Resources/Text.Designer.cs

@@ -177,15 +177,6 @@ namespace CardCollector.Resources {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to Карта.
-        /// </summary>
-        internal static string card {
-            get {
-                return ResourceManager.GetString("card", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to 💰.
         /// </summary>
@@ -204,15 +195,6 @@ namespace CardCollector.Resources {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to Собрать прибыль.
-        /// </summary>
-        internal static string collect_income {
-            get {
-                return ResourceManager.GetString("collect_income", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Коллекция.
         /// </summary>

+ 0 - 6
CardCollector/Resources/Text.resx

@@ -39,9 +39,6 @@
     <data name="all" xml:space="preserve">
         <value>Все</value>
     </data>
-    <data name="collect_income" xml:space="preserve">
-        <value>Собрать прибыль</value>
-    </data>
     <data name="previous" xml:space="preserve">
         <value>←</value>
     </data>
@@ -195,9 +192,6 @@
     <data name="buy_gems" xml:space="preserve">
         <value>Купить алмазы</value>
     </data>
-    <data name="card" xml:space="preserve">
-        <value>Карта</value>
-    </data>
     <data name="tier2" xml:space="preserve">
         <value>Тира</value>
     </data>