Browse Source

Bug fix. Add descriptions to sticker effect

Tigran 3 years ago
parent
commit
7a5ff64e4b

+ 2 - 1
CardCollector.sln.DotSettings.user

@@ -16,8 +16,9 @@
 	
 	
 	
-	<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=CardCollector_002FResources_002FMessages/@EntryIndexedValue">True</s:Boolean>
+	<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=CardCollector_002FResources_002FMessages/@EntryIndexedValue">False</s:Boolean>
 	<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=CardCollector_002FResources_002FSortingTypes/@EntryIndexedValue">False</s:Boolean>
 	<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=CardCollector_002FResources_002FText/@EntryIndexedValue">False</s:Boolean>
+	<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=CardCollector_002FStickerEffects_002FEffectTranslations/@EntryIndexedValue">True</s:Boolean>
 	
 	<s:Boolean x:Key="/Default/ResxEditorPersonal/Initialized/@EntryValue">True</s:Boolean></wpf:ResourceDictionary>

+ 9 - 0
CardCollector/CardCollector.csproj

@@ -43,6 +43,10 @@
         <Generator>ResXFileCodeGenerator</Generator>
         <LastGenOutput>Descriptions.Designer.cs</LastGenOutput>
       </EmbeddedResource>
+      <EmbeddedResource Update="StickerEffects\EffectTranslations.resx">
+        <Generator>ResXFileCodeGenerator</Generator>
+        <LastGenOutput>EffectTranslations.Designer.cs</LastGenOutput>
+      </EmbeddedResource>
     </ItemGroup>
 
     <ItemGroup>
@@ -81,6 +85,11 @@
         <AutoGen>True</AutoGen>
         <DependentUpon>Description.resx</DependentUpon>
       </Compile>
+      <Compile Update="StickerEffects\EffectTranslations.Designer.cs">
+        <DesignTime>True</DesignTime>
+        <AutoGen>True</AutoGen>
+        <DependentUpon>EffectTranslations.resx</DependentUpon>
+      </Compile>
     </ItemGroup>
 
 </Project>

+ 1 - 1
CardCollector/Commands/InlineQuery/ShowTradersInBotChat.cs

@@ -19,7 +19,7 @@ namespace CardCollector.Commands.InlineQuery
             var traders = await AuctionController.GetTradersList(filter, module.SelectedSticker.Id);
             var results = User.Session.GetModule<FiltersModule>()
                 .ApplyPriceTo(traders)
-                .ToTelegramResults(Command.buy_sticker);
+                .ToTelegramResults(Command.buy_sticker, 1.0 - await User.AuctionDiscount()/100.0);
             // Посылаем пользователю ответ на его запрос
             await MessageController.AnswerInlineQuery(InlineQueryId, await results);
         }

+ 3 - 0
CardCollector/DataBase/Entity/StickerEntity.cs

@@ -2,6 +2,7 @@
 using System.ComponentModel.DataAnnotations.Schema;
 using System.Linq;
 using CardCollector.Resources;
+using CardCollector.StickerEffects;
 
 namespace CardCollector.DataBase.Entity
 {
@@ -49,6 +50,7 @@ namespace CardCollector.DataBase.Entity
                              $"\n{Text.emoji}: {Emoji}" +
                              $"\n{Text.author}: {Author}" +
                              $"\n{Income}{Text.coin} {IncomeTime}{Text.time}{Text.minutes}";
+            if (Effect != 0) str += $"\n{Text.effect}: {EffectTranslations.ResourceManager.GetString(Effect.ToString())}";
             if (Description != "") str += $"\n\n{Text.description}: {Description}";
             return str;
         }
@@ -60,6 +62,7 @@ namespace CardCollector.DataBase.Entity
                       $"\n{Text.author}: {Author}" +
                       $"\n{Text.count}: {(count != -1 ? count : "∞")}" +
                       $"\n{Income}{Text.coin} {IncomeTime}{Text.time}{Text.minutes}";
+            if (Effect != 0) str += $"\n{Text.effect}: {EffectTranslations.ResourceManager.GetString(Effect.ToString())}";
             if (Description != "") str += $"\n\n{Text.description}: {Description}";
             return str;
         }

+ 3 - 2
CardCollector/Extensions.cs

@@ -35,15 +35,16 @@ namespace CardCollector
         }
         /* Преобразует список продавцов в список результатов для телеграм */
         public static async Task<IEnumerable<InlineQueryResult>> ToTelegramResults
-            (this IEnumerable<AuctionEntity> list, string command)
+            (this IEnumerable<AuctionEntity> list, string command, double discount)
         {
             var result = new List<InlineQueryResult>();
             foreach (var item in list)
             {
+                var price = (int)(item.Price * discount);
                 var user = await UserDao.GetById(item.Trader);
                 result.Add(new InlineQueryResultArticle($"{command}={item.Id}",
                     $"{user.Username} {item.Count}{Text.items}", new InputTextMessageContent(Text.buy))
-                { Description = $"{item.Price}{Text.gem} {Text.per} 1{Text.items}" });
+                { Description = $"{price}{Text.gem} {Text.per} 1{Text.items}" });
                 /* Ограничение Telegram API по количеству результатов в 50 шт. */
                 if (result.Count > 49) return result;
             }

+ 1 - 1
CardCollector/Resources/Constants.cs

@@ -28,6 +28,6 @@ namespace CardCollector.Resources
         /* Время оповещения и сброса ежедневных заданий */
         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);
+        public static readonly TimeSpan DailyStickerRewardCheck = DEBUG ? new TimeSpan(2, 56, 40) : new TimeSpan(1, 0, 0);
     }
 }

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

@@ -276,6 +276,15 @@ namespace CardCollector.Resources {
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized string similar to Эффект.
+        /// </summary>
+        internal static string effect {
+            get {
+                return ResourceManager.GetString("effect", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   Looks up a localized string similar to Эмоция.
         /// </summary>

+ 3 - 0
CardCollector/Resources/Text.resx

@@ -225,4 +225,7 @@
     <data name="open_specific" xml:space="preserve">
         <value>Открыть авторский пак</value>
     </data>
+    <data name="effect" xml:space="preserve">
+        <value>Эффект</value>
+    </data>
 </root>

+ 1 - 1
CardCollector/StickerEffects/AuctionDiscount5.cs

@@ -12,7 +12,7 @@ namespace CardCollector.StickerEffects
             return await stickers.AnyAsync(async item =>
             {
                 var stickerInfo = await StickerDao.GetById(item.Value.StickerId);
-                return stickerInfo.Effect == (int) Effect.AuctionDiscount5;
+                return stickerInfo.Effect == (int) Effect.AuctionDiscount5 && item.Value.Count != 0;
             });
         }
     }

+ 117 - 0
CardCollector/StickerEffects/EffectTranslations.Designer.cs

@@ -0,0 +1,117 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.42000
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace CardCollector.StickerEffects {
+    using System;
+    
+    
+    /// <summary>
+    ///   A strongly-typed resource class, for looking up localized strings, etc.
+    /// </summary>
+    // This class was auto-generated by the StronglyTypedResourceBuilder
+    // class via a tool like ResGen or Visual Studio.
+    // To add or remove a member, edit your .ResX file then rerun ResGen
+    // with the /str option, or rebuild your VS project.
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class EffectTranslations {
+        
+        private static global::System.Resources.ResourceManager resourceMan;
+        
+        private static global::System.Globalization.CultureInfo resourceCulture;
+        
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal EffectTranslations() {
+        }
+        
+        /// <summary>
+        ///   Returns the cached ResourceManager instance used by this class.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CardCollector.StickerEffects.EffectTranslations", typeof(EffectTranslations).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+        
+        /// <summary>
+        ///   Overrides the current thread's CurrentUICulture property for all
+        ///   resource lookups using this strongly typed resource class.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
+                return resourceCulture;
+            }
+            set {
+                resourceCulture = value;
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to При первом получении стикера, ваша копилка увеличится на 200 монет! (эффект не складывается).
+        /// </summary>
+        internal static string _1 {
+            get {
+                return ResourceManager.GetString("1", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to При первом получении стикера, колиечство ваших алмазов увеличится на 25%! (эффект не складывается).
+        /// </summary>
+        internal static string _2 {
+            get {
+                return ResourceManager.GetString("2", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to При наличии этого стикера, вы будете получать скидку к покупкам на аукционе в размере 5% (эффект не складывается).
+        /// </summary>
+        internal static string _3 {
+            get {
+                return ResourceManager.GetString("3", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to За каждый такой стикер в коллекции, вы будете получать 1 случайный пак раз в 5 дней!.
+        /// </summary>
+        internal static string _4 {
+            get {
+                return ResourceManager.GetString("4", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to За каждый такой стикер в коллекции, вы будете получать 1 случайный стикер 2-го тира каждые 3 дня!.
+        /// </summary>
+        internal static string _5 {
+            get {
+                return ResourceManager.GetString("5", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to За каждый такой стикер в коллекции, вы будете получать 1 случайный стикер 1-го тира каждые 3 дня!.
+        /// </summary>
+        internal static string _6 {
+            get {
+                return ResourceManager.GetString("6", resourceCulture);
+            }
+        }
+    }
+}

+ 39 - 0
CardCollector/StickerEffects/EffectTranslations.resx

@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<root>
+    <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+        <xsd:element name="root" msdata:IsDataSet="true">
+            
+        </xsd:element>
+    </xsd:schema>
+    <resheader name="resmimetype">
+        <value>text/microsoft-resx</value>
+    </resheader>
+    <resheader name="version">
+        <value>1.3</value>
+    </resheader>
+    <resheader name="reader">
+        <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    </resheader>
+    <resheader name="writer">
+        <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    </resheader>
+    <data name="1" xml:space="preserve">
+        <value>При первом получении стикера, ваша копилка увеличится на 200 монет! (эффект не складывается)</value>
+    </data>
+    <data name="2" xml:space="preserve">
+        <value>При первом получении стикера, колиечство ваших алмазов увеличится на 25%! (эффект не складывается)</value>
+    </data>
+    <data name="3" xml:space="preserve">
+        <value>При наличии этого стикера, вы будете получать скидку к покупкам на аукционе в размере 5% (эффект не складывается)</value>
+    </data>
+    <data name="4" xml:space="preserve">
+        <value>За каждый такой стикер в коллекции, вы будете получать 1 случайный пак раз в 5 дней!</value>
+    </data>
+    <data name="5" xml:space="preserve">
+        <value>За каждый такой стикер в коллекции, вы будете получать 1 случайный стикер 2-го тира каждые 3 дня!</value>
+    </data>
+    <data name="6" xml:space="preserve">
+        <value>За каждый такой стикер в коллекции, вы будете получать 1 случайный стикер 1-го тира каждые 3 дня!</value>
+    </data>
+</root>